Skip to content

Commit

Permalink
fix fakedns instance resolution leak by avoid using require
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaokangwang committed Jan 14, 2022
1 parent a10f7b3 commit 17a5aae
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/dispatcher/fakednssniffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ import (
// newFakeDNSSniffer Creates a Fake DNS metadata sniffer
func newFakeDNSSniffer(ctx context.Context) (protocolSnifferWithMetadata, error) {
var fakeDNSEngine dns.FakeDNSEngine
err := core.RequireFeatures(ctx, func(fdns dns.FakeDNSEngine) {
fakeDNSEngine = fdns
})
if err != nil {
return protocolSnifferWithMetadata{}, err
{
fakeDNSEngineFeat := core.MustFromContext(ctx).GetFeature(fakeDNSEngine)
if fakeDNSEngineFeat != nil {
fakeDNSEngine = fakeDNSEngineFeat.(dns.FakeDNSEngine)
}
}

if fakeDNSEngine == nil {
errNotInit := newError("FakeDNSEngine is not initialized, but such a sniffer is used").AtError()
return protocolSnifferWithMetadata{}, errNotInit
Expand Down

0 comments on commit 17a5aae

Please sign in to comment.