diff --git a/app/dns/nameserver_doh.go b/app/dns/nameserver_doh.go index e7313194e..5e2a63d00 100644 --- a/app/dns/nameserver_doh.go +++ b/app/dns/nameserver_doh.go @@ -297,14 +297,6 @@ func (s *DoHNameServer) findIPsForDomain(domain string, option dns_feature.IPOpt var ips []net.Address var lastErr error - if option.IPv6Enable { - aaaa, err := record.AAAA.getIPs() - if err != nil { - lastErr = err - } - ips = append(ips, aaaa...) - } - if option.IPv4Enable { a, err := record.A.getIPs() if err != nil { @@ -313,6 +305,14 @@ func (s *DoHNameServer) findIPsForDomain(domain string, option dns_feature.IPOpt ips = append(ips, a...) } + if option.IPv6Enable { + aaaa, err := record.AAAA.getIPs() + if err != nil { + lastErr = err + } + ips = append(ips, aaaa...) + } + if len(ips) > 0 { return toNetIP(ips) } @@ -321,11 +321,7 @@ func (s *DoHNameServer) findIPsForDomain(domain string, option dns_feature.IPOpt return nil, lastErr } - if (option.IPv4Enable && record.A != nil) || (option.IPv6Enable && record.AAAA != nil) { - return nil, dns_feature.ErrEmptyResponse - } - - return nil, errRecordNotFound + return nil, dns_feature.ErrEmptyResponse } // QueryIP implements Server.