xjasonlyu / tun2socks

tun2socks - powered by gVisor TCP/IP stack
https://github.com/xjasonlyu/tun2socks/wiki
GNU General Public License v3.0
2.85k stars 404 forks source link

Feat: support setting TCP half-close timeout #273

Closed myloft closed 9 months ago

myloft commented 12 months ago

Hi, in memory insufficient system like ios (limit 15/50 MB). If set to 60s, the release of relay buffer is slower.So adding a setting function would be useful.

xjasonlyu commented 12 months ago

The tcpWaitTimeout works only as a precaution for half-close TCP connections. It usually won't be used for most TCPs.

60s is the default timeout for this kind of scenario in most routers/firewalls. So I think keep it to 60s wouldn't affect much on memory insufficient systems. (this value changing is trivial for the memory efficiency/use)

myloft commented 12 months ago

This is my scenario: unidirectionalStream1: TCP ---- buffer ----> QUIC unidirectionalStream2: TCP <---- buffer ---- QUIC If client close TCP and QUIC have no data to write. Stream1 will read EOF from TCP connection and exit immediately. QUIC will receive eof after 60 seconds and close instead of closing immediately. So stream2 will continue to maintain a 20k buffer for 60 seconds.