Skip to content

Conversation

patterniha
Copy link
Collaborator

@patterniha patterniha commented Mar 27, 2025

First, I have to thank @Fangliding for his guidance on #4558 (comment).

I mistakenly think that the problem is related to log, but in fact log is just log and has nothing to do with performance.

in #3784 @Fangliding change the original code err != errRecordNotFound to err == nil || err == dns_feature.ErrEmptyResponse To be more accurate.

but in android some apps send thousands of requests in a matter of seconds, that return NXDOMAIN.

This causes performance to drop drastically, and many people have complained about this.

So I also added NXDOMAIN to the modes that should use cache.

photo_2025-03-28_02-10-14

@patterniha patterniha changed the title DNS: use cache for NXDOMAIN DNS: use cache for NXDOMAIN Mar 27, 2025
@xqzr
Copy link
Contributor

xqzr commented Mar 27, 2025

@Meo597
Copy link
Contributor

Meo597 commented Mar 28, 2025

家用路由器上的dnsmasq不会面临此问题,因为它的upstream就是tcp udp

鉴于xray特有场景,应像isp的递归dns一样,防御nxdomain flood

针对nxdomain应不遵守rfc,强制缓存10或者60秒

过大的值会导致网站管理员遇到困扰不得不重启xray

@RPRX RPRX changed the title DNS: use cache for NXDOMAIN DNS: Use cache for "NXDOMAIN" Mar 29, 2025
@RPRX RPRX changed the title DNS: Use cache for "NXDOMAIN" DNS: Use cache for NXDOMAIN (rcode 3) Mar 29, 2025
@RPRX RPRX merged commit a2bc732 into XTLS:main Mar 29, 2025
35 checks passed
@RPRX
Copy link
Member

RPRX commented Mar 29, 2025

话说我之前改 DNS 时也注意到了,ray 每多支持一种 DNS 查询方式就是 copy 整份代码,这挺劣质的,有空把它们改为复用吗?

@RPRX RPRX changed the title DNS: Use cache for NXDOMAIN (rcode 3) DNS: Use cache for NXDOMAIN (rcode 3 error) Mar 29, 2025
@patterniha patterniha mentioned this pull request Apr 13, 2025
maoxikun added a commit to maoxikun/Xray-core that referenced this pull request Aug 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants