Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gubiao opened this issue Sep 28, 2022 · 5 comments
Open

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

gubiao opened this issue Sep 28, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@gubiao
Copy link

gubiao commented Sep 28, 2022

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
Copy link
Member

感谢你的详细分析 待修复

@yuhan6665 yuhan6665 added the bug Something isn't working label Sep 28, 2022
@BI7PRK
Copy link

BI7PRK commented Sep 29, 2022

怪不得更新后就断断续续,"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
Copy link

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

@changyp6
Copy link

changyp6 commented Oct 11, 2022 via email

@yuhan6665
Copy link
Member

Pending issue as far as I know

@yuhan6665 yuhan6665 reopened this Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants