Skip to content

Commit

Permalink
don't create dns nfqueue if it isn't needed
Browse files Browse the repository at this point in the history
  • Loading branch information
capnspacehook committed Nov 27, 2021
1 parent 68eb77d commit 4958ef9
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,13 @@ func startFilter(ctx context.Context, logger *zap.Logger, opts *FilterOptions, i
}
}

dnsNF, err := startNfQueue(ctx, logger, opts.DNSQueue, opts.IPv6, newDNSRequestCallback(&f))
if err != nil {
return nil, fmt.Errorf("error opening nfqueue: %v", err)
if opts.DNSQueue != 0 {
dnsNF, err := startNfQueue(ctx, logger, opts.DNSQueue, opts.IPv6, newDNSRequestCallback(&f))
if err != nil {
return nil, fmt.Errorf("error opening nfqueue: %v", err)
}
f.dnsReqNF = dnsNF
}
f.dnsReqNF = dnsNF

return &f, nil
}
Expand Down Expand Up @@ -202,7 +204,9 @@ func (f *filter) cacheHostnames(ctx context.Context, logger *zap.Logger) {
}

func (f *filter) close() {
f.dnsReqNF.Close()
if f.dnsReqNF != nil {
f.dnsReqNF.Close()
}
if f.genericNF != nil {
f.genericNF.Close()
}
Expand Down

0 comments on commit 4958ef9

Please sign in to comment.