XTLS / Xray-core

Xray, Penetrates Everything. Also the best v2ray-core, with XTLS support. Fully compatible configuration.
https://t.me/projectXray
Mozilla Public License 2.0
24.42k stars 3.82k forks source link

无效DNS结果被缓存, 只能重启xray进程 #1231

Closed gubiao closed 1 week ago

gubiao commented 1 year ago

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) }

yuhan6665 commented 1 year ago

感谢你的详细分析 待修复

BI7PRK commented 1 year ago

怪不得更新后就断断续续,"disableCache": true, 选项有作用么? 另外发现设置了 clientIP 后会上不了“远程”网。不知道是不是bug?

"dns": {
        "disableCache": true,
        "disableFallback": false,
        "disableFallbackIfMatch": false,
        "skipFallback": false,
        "queryStrategy": "UseIP",
        "tag": "dns_servers",
        "servers": [
            {
                "address": "223.5.5.5",
                "port": 53,
                "domains": [
                    "geosite:geolocation-cn"
                ],
                "expectIPs": [
                    "geoip:cn"
                ]
            },
            "208.67.222.222",
            "1.1.1.1"
        ]
    },
Smallthing commented 1 year ago

你们都是直接用xray代理dns的吗。我独立使用unbound dns缓存服务器会被影响吗

changyp6 commented 1 year ago

不只是nameserver_udp.go里有这个问题。所有的nameserver_tcp/quic/doh.go里都有这个问题。

yuhan6665 @.***> 于2022年9月28日周三 20:47写道:

感谢你的详细分析 待修复

— Reply to this email directly, view it on GitHub https://github.com/XTLS/Xray-core/issues/1231#issuecomment-1260854107, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABPLTYOD7DZQELWAWGEW67DWAQ44TANCNFSM6AAAAAAQXXBWO4 . You are receiving this because you are subscribed to this thread.Message ID: @.***>

yuhan6665 commented 5 months ago

Pending issue as far as I know

yuhan6665 commented 1 week ago

Fixed