mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-06-13 03:10:44 +00:00
Feat: refine find IPs logic for DoH
This commit is contained in:
parent
2dc4ee2d51
commit
975f78a7ce
|
@ -297,14 +297,6 @@ func (s *DoHNameServer) findIPsForDomain(domain string, option dns_feature.IPOpt
|
||||||
|
|
||||||
var ips []net.Address
|
var ips []net.Address
|
||||||
var lastErr error
|
var lastErr error
|
||||||
if option.IPv6Enable {
|
|
||||||
aaaa, err := record.AAAA.getIPs()
|
|
||||||
if err != nil {
|
|
||||||
lastErr = err
|
|
||||||
}
|
|
||||||
ips = append(ips, aaaa...)
|
|
||||||
}
|
|
||||||
|
|
||||||
if option.IPv4Enable {
|
if option.IPv4Enable {
|
||||||
a, err := record.A.getIPs()
|
a, err := record.A.getIPs()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -313,6 +305,14 @@ func (s *DoHNameServer) findIPsForDomain(domain string, option dns_feature.IPOpt
|
||||||
ips = append(ips, a...)
|
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 {
|
if len(ips) > 0 {
|
||||||
return toNetIP(ips)
|
return toNetIP(ips)
|
||||||
}
|
}
|
||||||
|
@ -321,11 +321,7 @@ func (s *DoHNameServer) findIPsForDomain(domain string, option dns_feature.IPOpt
|
||||||
return nil, lastErr
|
return nil, lastErr
|
||||||
}
|
}
|
||||||
|
|
||||||
if (option.IPv4Enable && record.A != nil) || (option.IPv6Enable && record.AAAA != nil) {
|
return nil, dns_feature.ErrEmptyResponse
|
||||||
return nil, dns_feature.ErrEmptyResponse
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, errRecordNotFound
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryIP implements Server.
|
// QueryIP implements Server.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user