fix(handler/forward): split readTimeout from pipe idleTimeout to prevent 15s download abort
The readTimeout field (default 15s) was being applied via xnet.Pipe to both directions of a bidirectional proxy connection. During asymmetric transfers (e.g. HTTP file download), the direction reading from the tunnel sees no data after the initial request is forwarded, causing SetReadDeadline to fire after 15s and abort the entire transfer. Fix: add a separate idleTimeout field (default 0=disabled) to the metadata structs in both forward/local and forward/remote handlers, and switch xnet.Pipe to use idleTimeout instead of readTimeout. The readTimeout field now only applies to the initial protocol sniffing/handshake phase. Also document readTimeout vs idleTimeout semantics across all 24 locations in the x/ module where these timeouts appear: - readTimeout: handshake sniffing deadline (handlers), upstream response header timeout (http.Transport), or transport-level read deadline - idleTimeout: idle read deadline per Pipe direction (0=disabled) - ReadTimeout on Sniffer/SnifferBuilder: upstream response header/TLS handshake read timeout during sniffing
This commit is contained in:
@@ -15,6 +15,12 @@ import (
|
||||
|
||||
type metadata struct {
|
||||
publicAddr string
|
||||
// readTimeout is the deadline for reading the initial SOCKS5
|
||||
// handshake (auth + connect/associate/udp request) from the client
|
||||
// connection. The deadline is cleared after the handshake, so it
|
||||
// does not affect subsequent data transfer. Also passed to
|
||||
// SnifferBuilder for the upstream response header read timeout.
|
||||
// 0 or negative defaults to 15s.
|
||||
readTimeout time.Duration
|
||||
noTLS bool
|
||||
enableBind bool
|
||||
|
||||
Reference in New Issue
Block a user