1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-17 01:53:36 -05:00

fix(#2211): problem that AAAA query returns A result

This commit is contained in:
mzz2017 2020-02-04 18:44:58 +08:00 committed by kslr
parent fa657b8681
commit 4a663f2b25
2 changed files with 9 additions and 1 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
*.DS_Store
bazel-*
.idea

View File

@ -185,7 +185,6 @@ func (s *DoHNameServer) Cleanup() error {
func (s *DoHNameServer) updateIP(req *dnsRequest, ipRec *IPRecord) {
elapsed := time.Since(req.start)
newError(s.name, " got answere: ", req.domain, " ", req.reqType, " -> ", ipRec.IP, " ", elapsed).AtInfo().WriteToLog()
s.Lock()
rec := s.ips[req.domain]
@ -198,11 +197,19 @@ func (s *DoHNameServer) updateIP(req *dnsRequest, ipRec *IPRecord) {
updated = true
}
case dnsmessage.TypeAAAA:
addr := make([]net.Address, 0)
for _, ip := range ipRec.IP {
if len(ip.IP()) == net.IPv6len {
addr = append(addr, ip)
}
}
ipRec.IP = addr
if isNewer(rec.AAAA, ipRec) {
rec.AAAA = ipRec
updated = true
}
}
newError(s.name, " got answere: ", req.domain, " ", req.reqType, " -> ", ipRec.IP, " ", elapsed).AtInfo().WriteToLog()
if updated {
s.ips[req.domain] = rec