From 7e82418a40da537a9e3e5a3e781421bd8cd64f6f Mon Sep 17 00:00:00 2001 From: Shelikhoo Date: Fri, 9 Apr 2021 23:19:06 +0100 Subject: [PATCH] make fake dns aware of resolution IP proto requirement in fake dns server --- app/dns/nameserver_fakedns.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/dns/nameserver_fakedns.go b/app/dns/nameserver_fakedns.go index 9fb48bebd..65a0ca1b6 100644 --- a/app/dns/nameserver_fakedns.go +++ b/app/dns/nameserver_fakedns.go @@ -22,7 +22,7 @@ func (FakeDNSServer) Name() string { return "FakeDNS" } -func (f *FakeDNSServer) QueryIP(ctx context.Context, domain string, _ net.IP, _ dns.IPOption, _ bool) ([]net.IP, error) { +func (f *FakeDNSServer) QueryIP(ctx context.Context, domain string, _ net.IP, opt dns.IPOption, _ bool) ([]net.IP, error) { if f.fakeDNSEngine == nil { if err := core.RequireFeatures(ctx, func(fd dns.FakeDNSEngine) { f.fakeDNSEngine = fd @@ -30,7 +30,12 @@ func (f *FakeDNSServer) QueryIP(ctx context.Context, domain string, _ net.IP, _ return nil, newError("Unable to locate a fake DNS Engine").Base(err).AtError() } } - ips := f.fakeDNSEngine.GetFakeIPForDomain(domain) + var ips []net.Address + if fkr0, ok := f.fakeDNSEngine.(dns.FakeDNSEngineRev0); ok { + ips = fkr0.GetFakeIPForDomain3(domain, opt.IPv4Enable, opt.IPv6Enable) + } else { + ips = f.fakeDNSEngine.GetFakeIPForDomain(domain) + } netIP, err := toNetIP(ips) if err != nil {