TUN inbound: Make udp_fullcone pure side effect free udp connection#5525
TUN inbound: Make udp_fullcone pure side effect free udp connection#5525
Conversation
|
虽然 #5521 (comment) ,不过对 UDP 来说似乎应该仅看上行五分钟活跃而不是还看下行, 等我合并了 #5522 你 rebase 一下 |
|
@Owersun rebase |
…plementing net.Conn Decouple udp connection from gVisor primitives, making handler/stack/udp_connection implementation independent of each other
2dced0c to
322a2c2
Compare
|
done |
|
@Owersun 加上“指定网关 IP”和“自动设置系统路由”这两个选项吧, Windows 用一条 |
|
I will take a look, sure. |
|
I think my google translate is failing me... |
|
如果是那样的话,那个 LogInfo processing TCP 改了吗 |
|
nono, I didn't touch the handler at all in my changes, only udp_fullcone.go and stack_gvisor.go were in the pull request |
|
那还是重新 PR 一下吧,那个被我改成了 LogInfo processing TCP,需要改一下 net type |
|
ah you mean handler.go line 130 "processing TCP from "...? |
|
done #5526 BTW: net.DestinationFromAddr() panics in case network protocol is unknown. I don't know how that could happen, but I already saw it once, a packet arrived for TCP connection with unknown network protocol, and the whole app closed on "panic". |
|
|
|
I'll keep an eye on that and try to figure out where it came from if I see it again. |
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.