TUN inbound: Make udp_fullcone pure side effect free udp connection#5526
TUN inbound: Make udp_fullcone pure side effect free udp connection#5526
Conversation
…plementing net.Conn Decouple udp connection from gVisor primitives, making handler/stack/udp_connection implementation independent of each other
|
为了防止 #5525 (comment) ,顺便把 gVisor 升级到最新稳定版本吧, |
|
I will try to upgrade the gVisor to latest possible version. |
|
你先看一下 latest gVisor 有没有 breaking changes,如果有的话就不放这个 PR 里了,等我合了这个 PR 后你另开一个 PR |
|
Opened as separate #5527 to be reviewed separately, due to small modification for proxy/wireguard needed for latest gVisor version. |
|
|
|
This makes udp_fullcone usage independent side effect free implementation of net.Conn
This allows to substitute other imeplentations ip stacks could use, but with custom logic allowing FullCone NAT
The code is clearly split to the places it belong, and handler/stack_gvisor/udp_fullcone don't depend on each other and don't know about each others implementation as they should be.
Both stack and connection are nice 200-300 line files.
Connection handling was remove from udp_fullcone and delegated to be part of lifecycle handler should do.
Handler will close connections calling .Close() on net.Conn, when outbound signal that the connection is complete, which will make udp connections close and clean up.
Running for 12 hours with two devices behind a router shows proper gofunc cleanup, keeping the number of running coroutines going up and down with connection number.
Log message of processed connection made more generic "processing connection" with source and destination including network protocol info