Skip to content

Commit

Permalink
Merge pull request #201 from adubovikov/master
Browse files Browse the repository at this point in the history
added custom bpf filter
  • Loading branch information
adubovikov authored Dec 7, 2020
2 parents 3247e01 + 95d9d01 commit 668870f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ type InterfacesConfig struct {
Loop int `config:"loop"`
FanoutID uint `config:"fanout_id"`
FanoutWorker int `config:"fanout_worker"`
CustomBPF string `config:"custom_bpf"`
}
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func createFlags() {
flag.BoolVar(&ifaceConfig.ReadSpeed, "rs", false, "Use packet timestamps with maximum pcap read speed")
flag.IntVar(&ifaceConfig.Snaplen, "s", 8192, "Snaplength")
flag.StringVar(&ifaceConfig.PortRange, "pr", "5060-5090", "Portrange to capture SIP")
flag.StringVar(&ifaceConfig.CustomBPF, "bpf", "", "Custom BPF to capture packets")
flag.BoolVar(&ifaceConfig.WithVlan, "vlan", false, "vlan")
flag.BoolVar(&ifaceConfig.WithErspan, "erspan", false, "erspan")
flag.IntVar(&ifaceConfig.BufferSizeMb, "b", 32, "Interface buffersize (MB)")
Expand Down
3 changes: 3 additions & 0 deletions sniffer/sniffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ func (sniffer *SnifferSetup) setFromConfig() error {
if sniffer.config.WithVlan {
sniffer.bpf = fmt.Sprintf("%s or (vlan and (%s))", sniffer.bpf, sniffer.bpf)
}
if sniffer.config.CustomBPF != "" {
sniffer.bpf = sniffer.config.CustomBPF
}

if config.Cfg.Filter != "" {
sniffer.filter = strings.Split(config.Cfg.Filter, ",")
Expand Down

0 comments on commit 668870f

Please sign in to comment.