Repository navigation
TUN inbound: Half-close the app connection when the outbound is done, instead of waiting for uplinkOnly - #7347
StarProxima wants to merge 2 commits into
Conversation
|
这个 PR 修复了 #5845 吗 |
|
先全部修完看看代码吧 |
@RPRX Done, XHTTP, Vision and REALITY are in now and the description lists what each one does stream-one over HTTP/1.1 and HTTP/2 still waits since net/http can't end the response and keep reading the request, I have a commit for that if you want it |
|
|
|
我是不赞成这么弄 conn接口硬整这个 之前我已经关掉一个了 那个moonlight远古玩意硬依赖半关闭特性才出问题 现代协议早就不这样了 |
|
|
|
downlink要是结束了往客户端发半关闭只在tun内部是可以接受的 我不知道之前的有没有 |
|
@StarProxima 先把这个 PR 改为只留 TUN 支持半关闭吧,正好发版测测 |
|
@Fangliding 不对等下,“往客户端发半关闭”,然而 core 那些出站只能把“完全关闭”传给 TUN,它咋知道要不要半关闭 |
|
downlink/uplink两条路一边关了不就是关了 虽然不知道有谁会写( |
|
嘛 其实不改也行 直接RST 99%的情况下都没啥问题 现代软件大都不把半关闭特性视作多可靠 |
|
半关闭特性处理起来贼拉头疼的 go http库最底层甚至都有一些这个workaround |
|
说错了,不是“只能”而是没人这么写,core 中 link 都是成对关闭的,且
|
|
@StarProxima 要不你看看有什么 workaround 能修 #5845 , |
b888859 to
fe29876
Compare
uplinkOnlyuplinkOnly
|
Left the |
fe29876 to
d0a5fe7
Compare
|
也就是说 VMess、Freedom 这俩 outbound 实现了只调用到 TUN 的 CloseWrite() 而非 Close()? |
@RPRX No, they all just call Close on the output like VLESS does. TUN turns it into FIN now the difference is when they know the response is over. Freedom gets EOF from the target, VMess gets the end chunk, VLESS only sees the server close the whole connection after |
|
@StarProxima 给一下代码调用链, |
@RPRX the early one is this the one you remember is in Handler.Dispatch, both get closed there but only after Process returns, so after uplinkOnly. VMess has the same task.Close |
9ade89d to
5d17b87
Compare
|
@RPRX only the TUN part is left now, as you asked. Anything you'd like changed before it goes in? |
|
I tested #7347 on When aborting a connection with unread incoming data, RFC 9293, §3.6.1 recommends sending |
|
|
… instead of waiting for `uplinkOnly`
… of sending FIN first
d0a5fe7 to
7f7865c
Compare
|
@svlavr good catch, thanks. |
Why
With Xray's TUN as the system VPN, an app that reads a response until the server closes waits about 1 s more than it should on every such connection. The outbound already knows the response is over, but TUN keeps the app's connection open until the whole dispatch ends, and that happens only after
uplinkOnly. Examples are HTTP/1.0 withoutContent-Length, RTSP (Moonlight in #5845) and simple request and reply protocols. With this change the app gets the end of the response right awayWhat changed
CloseWritefor thatTesting and limits
TestTCPCloseWritechecks that FIN goes out, that data from the app is still read after it and thatClosesends nothing more.go test -race ./proxy/tunpassesuplinkOnlyon the server, so the wait there staysRelated #5845 #7345