mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-14 00:55:01 +03:00
2fab6c3d50
Every TCP connection through a built-in AmneziaWG inbound or outbound allocated two fresh 32 KiB copy buffers, because io.Copy on a *net.TCPConn goes through ReadFrom/WriteTo and ignores a caller's buffer. Under a stream of short connections that is a lot of garbage. The relays now copy with buffers from a sync.Pool; one side of each pair is always a userspace netstack connection, so no kernel splice path is given up. The connect to the local Xray bridge and its SOCKS5 handshake had no time limit, so a bridge that accepted and never answered pinned the relay's goroutines and descriptors forever. Both are now bounded at 10 s, and the deadline is cleared once the handshake succeeds so the relayed connection keeps its half-close behaviour.