Skip to content

Commit

Permalink
fix(#2211): problem that AAAA query returns A result
Browse files Browse the repository at this point in the history
  • Loading branch information
mzz2017 committed Feb 4, 2020
1 parent 5dd8571 commit d520bc2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.DS_Store
bazel-*
.idea
9 changes: 8 additions & 1 deletion app/dns/dohdns.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand Down

0 comments on commit d520bc2

Please sign in to comment.