From ec1cd18e503fdbc003e01dc34fd7158d7b97b97d Mon Sep 17 00:00:00 2001 From: Chaz Lever Date: Fri, 10 Jul 2020 21:22:53 -0400 Subject: [PATCH] Use BPF filter when parsing PCAP file --- parser/parse.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/parser/parse.go b/parser/parse.go index 70e1dbd..0ddb4c6 100644 --- a/parser/parse.go +++ b/parser/parse.go @@ -43,6 +43,16 @@ func ParseFile(fname string) { } defer handle.Close() + // Setup BPF filter on handle + bpfFilter := "udp port 53" + if DoParseTcp { + bpfFilter = "port 53" + } + err = handle.SetBPFFilter(bpfFilter) + if err != nil { + log.Warnf("Could not set BPF filter: %v\n", err) + } + ParseDns(handle) }