Skip to content

Commit

Permalink
Fix --input-raw-bpf-filter
Browse files Browse the repository at this point in the history
It was just ignored

Should fix #955
  • Loading branch information
buger committed Jul 1, 2021
1 parent de8a74f commit 2b993ed
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions capture/capture.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@ func (l *Listener) PcapHandle(ifi pcap.Interface) (handle *pcap.Handle, err erro
if err != nil {
return nil, fmt.Errorf("PCAP Activate device error: %q, interface: %q", err, ifi.Name)
}
l.BPFFilter = l.Filter(ifi)
if l.BPFFilter == "" {
l.BPFFilter = l.Filter(ifi)
}
fmt.Println("Interface:", ifi.Name, ". BPF Filter:", l.BPFFilter)
err = handle.SetBPFFilter(l.BPFFilter)
if err != nil {
Expand All @@ -303,7 +305,9 @@ func (l *Listener) SocketHandle(ifi pcap.Interface) (handle Socket, err error) {
if err = handle.SetPromiscuous(l.Promiscuous || l.Monitor); err != nil {
return nil, fmt.Errorf("promiscuous mode error: %q, interface: %q", err, ifi.Name)
}
l.BPFFilter = l.Filter(ifi)
if l.BPFFilter == "" {
l.BPFFilter = l.Filter(ifi)
}
fmt.Println("BPF Filter: ", l.BPFFilter)
if err = handle.SetBPFFilter(l.BPFFilter); err != nil {
handle.Close()
Expand Down Expand Up @@ -477,7 +481,9 @@ func (l *Listener) activateAFPacket() error {
continue
}

l.BPFFilter = l.Filter(ifi)
if l.BPFFilter == "" {
l.BPFFilter = l.Filter(ifi)
}
fmt.Println("Interface:", ifi.Name, ". BPF Filter:", l.BPFFilter)
handle.SetBPFFilter(l.BPFFilter, 64<<10)

Expand Down

0 comments on commit 2b993ed

Please sign in to comment.