-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
752ef15
commit b3c5e5d
Showing
5 changed files
with
176 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
//go:build linux || freebsd | ||
// +build linux freebsd | ||
//go:build linux | ||
// +build linux | ||
|
||
package collectors | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
//go:build freebsd | ||
// +build freebsd | ||
|
||
package collectors | ||
|
||
import ( | ||
"github.com/dmachard/go-dnscollector/dnsutils" | ||
"github.com/dmachard/go-logger" | ||
) | ||
|
||
type AfpacketSniffer struct { | ||
done chan bool | ||
exit chan bool | ||
loggers []dnsutils.Worker | ||
config *dnsutils.Config | ||
logger *logger.Logger | ||
name string | ||
} | ||
|
||
// workaround for freebsd, not yet supported | ||
func NewAfpacketSniffer(loggers []dnsutils.Worker, config *dnsutils.Config, logger *logger.Logger, name string) *AfpacketSniffer { | ||
logger.Info("[%s] AFPACKET sniffer - enabled", name) | ||
s := &AfpacketSniffer{ | ||
done: make(chan bool), | ||
exit: make(chan bool), | ||
config: config, | ||
loggers: loggers, | ||
logger: logger, | ||
name: name, | ||
} | ||
s.ReadConfig() | ||
return s | ||
} | ||
|
||
func (c *AfpacketSniffer) GetName() string { return c.name } | ||
|
||
func (c *AfpacketSniffer) SetLoggers(loggers []dnsutils.Worker) { | ||
c.loggers = loggers | ||
} | ||
|
||
func (c *AfpacketSniffer) LogInfo(msg string, v ...interface{}) { | ||
c.logger.Info("["+c.name+"] AFPACKET sniffer - "+msg, v...) | ||
} | ||
|
||
func (c *AfpacketSniffer) LogError(msg string, v ...interface{}) { | ||
c.logger.Error("["+c.name+"] AFPACKET sniffer - "+msg, v...) | ||
} | ||
|
||
func (c *AfpacketSniffer) Loggers() []chan dnsutils.DnsMessage { | ||
channels := []chan dnsutils.DnsMessage{} | ||
for _, p := range c.loggers { | ||
channels = append(channels, p.Channel()) | ||
} | ||
return channels | ||
} | ||
|
||
func (c *AfpacketSniffer) ReadConfig() { | ||
} | ||
|
||
func (c *AfpacketSniffer) Channel() chan dnsutils.DnsMessage { | ||
return nil | ||
} | ||
|
||
func (c *AfpacketSniffer) Stop() { | ||
c.LogInfo("stopping...") | ||
|
||
// exit to close properly | ||
c.exit <- true | ||
|
||
// read done channel and block until run is terminated | ||
<-c.done | ||
close(c.done) | ||
} | ||
|
||
func (c *AfpacketSniffer) Run() { | ||
c.LogInfo("Not supported") | ||
c.done <- true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
//go:build freebsd | ||
// +build freebsd | ||
|
||
package collectors | ||
|
||
import ( | ||
"github.com/dmachard/go-dnscollector/dnsutils" | ||
"github.com/dmachard/go-logger" | ||
) | ||
|
||
type TzspSniffer struct { | ||
done chan bool | ||
exit chan bool | ||
loggers []dnsutils.Worker | ||
config *dnsutils.Config | ||
logger *logger.Logger | ||
name string | ||
} | ||
|
||
// workaround for macos, not yet supported | ||
func NewTzsp(loggers []dnsutils.Worker, config *dnsutils.Config, logger *logger.Logger, name string) *AfpacketSniffer { | ||
logger.Info("[%s] tzsp collector - enabled", name) | ||
s := &AfpacketSniffer{ | ||
done: make(chan bool), | ||
exit: make(chan bool), | ||
config: config, | ||
loggers: loggers, | ||
logger: logger, | ||
name: name, | ||
} | ||
s.ReadConfig() | ||
return s | ||
} | ||
|
||
func (c *TzspSniffer) GetName() string { return c.name } | ||
|
||
func (c *TzspSniffer) SetLoggers(loggers []dnsutils.Worker) { | ||
c.loggers = loggers | ||
} | ||
|
||
func (c *TzspSniffer) LogInfo(msg string, v ...interface{}) { | ||
c.logger.Info("["+c.name+"] tzsp collector - "+msg, v...) | ||
} | ||
|
||
func (c *TzspSniffer) LogError(msg string, v ...interface{}) { | ||
c.logger.Error("["+c.name+"] tzsp collector - "+msg, v...) | ||
} | ||
|
||
func (c *TzspSniffer) Loggers() []chan dnsutils.DnsMessage { | ||
channels := []chan dnsutils.DnsMessage{} | ||
for _, p := range c.loggers { | ||
channels = append(channels, p.Channel()) | ||
} | ||
return channels | ||
} | ||
|
||
func (c *TzspSniffer) ReadConfig() { | ||
} | ||
|
||
func (c *TzspSniffer) Channel() chan dnsutils.DnsMessage { | ||
return nil | ||
} | ||
|
||
func (c *TzspSniffer) Stop() { | ||
c.LogInfo("stopping...") | ||
|
||
// exit to close properly | ||
c.exit <- true | ||
|
||
// read done channel and block until run is terminated | ||
<-c.done | ||
close(c.done) | ||
} | ||
|
||
func (c *TzspSniffer) Run() { | ||
c.LogInfo("run terminated") | ||
c.done <- true | ||
} |