Files
sub2api/backend/internal/repository/http_upstream_keepalive_other.go
T
Anankke 5854a1db43 fix(upstream): detect dead upstream connections in about 30s
Connections from newUpstreamDialer were dialed with net.Dialer{KeepAlive: 30s}. Go then keeps TCP_KEEPINTVL 15 s and TCP_KEEPCNT 9, so a peer that stops answering is declared dead 165 s after its last packet, and no TCP_USER_TIMEOUT is set.

The dialer now sets KeepAliveConfig{Idle 15 s, Interval 5 s, Count 3} and, on Linux, TCP_USER_TIMEOUT 30 s (idle + interval x count) through Dialer.Control. Other platforms keep the keep-alive configuration only.

SOCKS5 and TLS fingerprint transports keep their own dialers.
2026-11-14 04:13:19 -08:00

10 lines
287 B
Go

//go:build !linux
package repository
import "syscall"
// upstreamDialControl is nil off Linux: TCP_USER_TIMEOUT is a Linux socket
// option, and the keep-alive configuration alone bounds idle connections.
var upstreamDialControl func(network, address string, c syscall.RawConn) error