diff --git a/capture/capture.go b/capture/capture.go index 074c24d2..93fb6683 100644 --- a/capture/capture.go +++ b/capture/capture.go @@ -284,14 +284,16 @@ 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) } - if l.BPFFilter == "" { - l.BPFFilter = l.Filter(ifi) + + bpfFilter := l.BPFFilter + if bpfFilter == "" { + bpfFilter = l.Filter(ifi) } - fmt.Println("Interface:", ifi.Name, ". BPF Filter:", l.BPFFilter) - err = handle.SetBPFFilter(l.BPFFilter) + fmt.Println("Interface:", ifi.Name, ". BPF Filter:", bpfFilter) + err = handle.SetBPFFilter(bpfFilter) if err != nil { handle.Close() - return nil, fmt.Errorf("BPF filter error: %q%s, interface: %q", err, l.BPFFilter, ifi.Name) + return nil, fmt.Errorf("BPF filter error: %q%s, interface: %q", err, bpfFilter, ifi.Name) } return }