Browse Source

Feat: refine find IPs logic for DoH

秋のかえで 3 years ago
parent
commit
975f78a7ce
1 changed files with 7 additions and 11 deletions
  1. 7 11
      app/dns/nameserver_doh.go

+ 7 - 11
app/dns/nameserver_doh.go

@@ -297,20 +297,20 @@ 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 option.IPv4Enable {
+		a, err := record.A.getIPs()
 		if err != nil {
 			lastErr = err
 		}
-		ips = append(ips, aaaa...)
+		ips = append(ips, a...)
 	}
 
-	if option.IPv4Enable {
-		a, err := record.A.getIPs()
+	if option.IPv6Enable {
+		aaaa, err := record.AAAA.getIPs()
 		if err != nil {
 			lastErr = err
 		}
-		ips = append(ips, a...)
+		ips = append(ips, aaaa...)
 	}
 
 	if len(ips) > 0 {
@@ -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.