-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Description
DNS服务器未返回有效的A记录或AAAA记录, 不存在TTL, 但是DNS解析结果仍然被xray内置DNS缓存, 发生这种情况后只能重启xray,
希望内置DNS仅缓存存在有效IP的, 有明确TTL的A记录或AAAA记录, 日志如下:
➜ ~ dig sdfsdf.sdf @127.0.0.1
; <<>> DiG 9.10.6 <<>> sdfsdf.sdf @127.0.0.1
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 16470
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;sdfsdf.sdf. IN A
;; Query time: 6 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed Sep 28 20:10:38 CST 2022
;; MSG SIZE rcvd: 28
日志:
2022/09/28 19:50:21 [Info] app/dns: UDP:119.29.29.29:53 got answer: sdfsdf.sdf. TypeA -> [] 10.821095ms
2022/09/28 19:50:21 [Debug] app/dns: UDP:119.29.29.29:53 updating IP records for domain:sdfsdf.sdf.
从日志中可以看出, DNS解析结果中TypeA对应的是一个空的数组, 此时是不存在带有TTL的有效A记录的, 此时不应该执行后续的“updating IP records for domain..."
https://github.com/XTLS/Xray-core/blob/main/app/dns/nameserver_udp.go
文件中的HandleResponse方法结尾处代码应考虑此类情况(空的数组?):
if len(req.domain) > 0 && (rec.A != nil || rec.AAAA != nil) { s.updateIP(req.domain, &rec) }