Xray-core icon indicating copy to clipboard operation
Xray-core copied to clipboard

Freedom: Cache UDP resolve result

Open Fangliding opened this issue 6 months ago • 8 comments

https://github.com/XTLS/Xray-core/issues/4800#issuecomment-2959273169 道理上udp就不该有fqdn当目标(((((

Fangliding avatar Jun 10 '25 15:06 Fangliding

早看到了 已经改了 不过我回头问了一下 这和你遇到的东西没关系 这只是一个小小的refine

Fangliding avatar Jun 10 '25 17:06 Fangliding

@Fangliding

line 380 and 381 should be swapped

patterniha avatar Jun 10 '25 18:06 patterniha

@Fangliding

line 389 and 390 should be swapped

patterniha avatar Jun 10 '25 20:06 patterniha

这两行换不换有什么区别么

Fangliding avatar Jun 10 '25 20:06 Fangliding

yes ip.domain() is panic

patterniha avatar Jun 10 '25 20:06 patterniha

道理上udp就不该有fqdn当目标(((((

@Fangliding

or we have multiple-IP or we have only-one-domain on single-UDP.

if we have multiple-domain it is impossible to connect response to request.

for example if we have two domain example-1.com and example-2.com, and both resolved to "2.2.2.2" so if we receive response from "2.2.2.2" this is for example-1.com or example-2.com ???

this is logically impossible, and has nothing to do with code.

///

So we never have multiple-domain on single-UDP and there is no need for resolvedUDPAddr-map, only single variable is enough(of course, I haven't deleted it from my PR yet.)

///

patterniha avatar Jun 12 '25 21:06 patterniha

TestCommanderListHandlers 极其容易炸

rebase 到 v25.6.8 fbae89d017aee5947598d0a82945b316fdc688ab 就好了

Meo597 avatar Jun 13 '25 15:06 Meo597

@Fangliding

~I separated my PR from your PR.‍~

this PR fix WriteMultiBuffer and my PR fix ReadMultiBuffer, and these two PR will solve the UDP problem in Freedom when address is domain or fakedns.

also, you missed a few things in your code:

  1. even if hasStrategy is false, we should load and store from cache.

  2. if ForceIP is true, and built-in-DNS fail to resolve-IP, we should not fallback to system-DNS (net.ResolveUDPAddr)

////////////////////

@RPRX

these two PR should merge as soon as possible, and new version should be released.

I think you are aware of the sensitive situation in Iran. we are at war and the internet is very limited.

patterniha avatar Jun 15 '25 05:06 patterniha

~~话说现在伊朗基本断外网了还能 Serverless-for-Iran 吗~~

RPRX avatar Jun 23 '25 12:06 RPRX

~Now that Iran is basically disconnected from the Internet, is Serverless-for-Iran still available?~

only youtube ~and porn sites~ (of course, I have to change the DNS, I'm waiting for the freedom-UDP problem to be resolved)

///

but the reverse(bridge-portal) method is working great on home-internet with static-IP.

patterniha avatar Jun 23 '25 19:06 patterniha

The internet is back to normal. but ipv6 and UDP are still not available.

patterniha avatar Jun 25 '25 13:06 patterniha

also, you missed a few things in your code:

  1. even if hasStrategy is false, we should load and store from cache.
  2. if ForceIP is true, and built-in-DNS fail to resolve-IP, we should not fallback to system-DNS (net.ResolveUDPAddr)

/////////////////

@Fangliding

Fix 1 and 2, thx.

patterniha avatar Jun 27 '25 16:06 patterniha

It's done

Fangliding avatar Jun 28 '25 11:06 Fangliding

算了还是改成之前那样吧 我只是不想把continue写两次 这个use真是烦死了。。

Fangliding avatar Jun 28 '25 16:06 Fangliding

Fix 0 len outbounds

How can the length of outbounds be zero?

And if it is zero, ‍‍NewPacketWriter will not be executed at all:

we have:

https://github.com/XTLS/Xray-core/blob/1976d02ec9aaff3d34221a18b4ec8869437e2dc6/proxy/freedom/freedom.go#L105-L107

before that and it will panic.

patterniha avatar Jul 15 '25 21:07 patterniha

Fix 0 len outbounds

How can the length of outbounds be zero?

And if it is zero, ‍‍NewPacketWriter will not be executed at all:

we have:

https://github.com/XTLS/Xray-core/blob/1976d02ec9aaff3d34221a18b4ec8869437e2dc6/proxy/freedom/freedom.go#L105-L107

before that and it will panic.

我这么写可能清楚点 那个ctx可能不是上面看到的ctx 你可以自己用先前的版本试试 就是我在测你昨天那个pr的时候遇到的

Fangliding avatar Jul 16 '25 03:07 Fangliding

i tested and see len(outbounds) is always 0 and your initial-set-map does not perform at all.

NewPacketWriter/NewPacketReader ctx is newCtx define in line-174 and has no outbounds.

so we should copy ctx-outbounds to newCtx-outbounds.

///

I fix it in https://github.com/XTLS/Xray-core/pull/4816.

patterniha avatar Jul 16 '25 06:07 patterniha

就这样就行了 不要破坏timeoutonly的语义

Fangliding avatar Jul 16 '25 08:07 Fangliding

~Forget what I said, I hadn't seen your last force-pushed~

patterniha avatar Jul 16 '25 19:07 patterniha