From c278db5b77f58918d0b4971d8790814ac8306e81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Fri, 24 Sep 2021 13:46:34 +0800 Subject: [PATCH] Fix queryStrategy ignored (#1285) --- app/dns/dns.go | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/app/dns/dns.go b/app/dns/dns.go index 93d248edd2d..f0fcf490fe4 100644 --- a/app/dns/dns.go +++ b/app/dns/dns.go @@ -172,29 +172,27 @@ func (s *DNS) IsOwnLink(ctx context.Context) bool { // LookupIP implements dns.Client. func (s *DNS) LookupIP(domain string) ([]net.IP, error) { - return s.lookupIPInternal(domain, dns.IPOption{ - IPv4Enable: true, - IPv6Enable: true, - FakeEnable: s.ipOption.FakeEnable, - }) + return s.lookupIPInternal(domain, *s.ipOption) } // LookupIPv4 implements dns.IPv4Lookup. func (s *DNS) LookupIPv4(domain string) ([]net.IP, error) { - return s.lookupIPInternal(domain, dns.IPOption{ - IPv4Enable: true, - IPv6Enable: false, - FakeEnable: s.ipOption.FakeEnable, - }) + if !s.ipOption.IPv4Enable { + return nil, dns.ErrEmptyResponse + } + o := *s.ipOption + o.IPv6Enable = false + return s.lookupIPInternal(domain, o) } // LookupIPv6 implements dns.IPv6Lookup. func (s *DNS) LookupIPv6(domain string) ([]net.IP, error) { - return s.lookupIPInternal(domain, dns.IPOption{ - IPv4Enable: false, - IPv6Enable: true, - FakeEnable: s.ipOption.FakeEnable, - }) + if !s.ipOption.IPv6Enable { + return nil, dns.ErrEmptyResponse + } + o := *s.ipOption + o.IPv4Enable = false + return s.lookupIPInternal(domain, o) } func (s *DNS) lookupIPInternal(domain string, option dns.IPOption) ([]net.IP, error) {