From 24aa4fa88ba6d643fa21d655dc010d554ce20d15 Mon Sep 17 00:00:00 2001 From: Ivan Date: Thu, 20 Nov 2025 18:14:57 -0600 Subject: [PATCH] remove default RTT implementation for non-Linux platforms and enhance keepalive period configuration for FreeBSD and Windows --- pkg/interfaces/tcp_common.go | 10 ---------- pkg/interfaces/tcp_freebsd.go | 7 ++++++- pkg/interfaces/tcp_linux.go | 4 ++-- pkg/interfaces/tcp_windows.go | 7 ++++++- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pkg/interfaces/tcp_common.go b/pkg/interfaces/tcp_common.go index 622cceb..1763e27 100644 --- a/pkg/interfaces/tcp_common.go +++ b/pkg/interfaces/tcp_common.go @@ -2,13 +2,3 @@ // +build !linux package interfaces - -import ( - "time" -) - -// platformGetRTT is defined in OS-specific files -// Default implementation for non-Linux platforms -func platformGetRTT(fd uintptr) time.Duration { - return 0 -} diff --git a/pkg/interfaces/tcp_freebsd.go b/pkg/interfaces/tcp_freebsd.go index eb59626..b5920c1 100644 --- a/pkg/interfaces/tcp_freebsd.go +++ b/pkg/interfaces/tcp_freebsd.go @@ -20,7 +20,12 @@ func (tc *TCPClientInterface) setTimeoutsLinux() error { return fmt.Errorf("failed to enable keepalive: %v", err) } - if err := tcpConn.SetKeepAlivePeriod(TCP_PROBE_INTERVAL * time.Second); err != nil { + keepalivePeriod := TCP_PROBE_INTERVAL_SEC * time.Second + if tc.i2pTunneled { + keepalivePeriod = I2P_PROBE_INTERVAL_SEC * time.Second + } + + if err := tcpConn.SetKeepAlivePeriod(keepalivePeriod); err != nil { debug.Log(debug.DEBUG_VERBOSE, "Failed to set keepalive period", "error", err) } diff --git a/pkg/interfaces/tcp_linux.go b/pkg/interfaces/tcp_linux.go index 7378961..db51e26 100644 --- a/pkg/interfaces/tcp_linux.go +++ b/pkg/interfaces/tcp_linux.go @@ -86,8 +86,8 @@ func platformGetRTT(fd uintptr) time.Duration { fd, syscall.IPPROTO_TCP, 11, // TCP_INFO - uintptr(unsafe.Pointer(&info)), - uintptr(unsafe.Pointer(&infoLen)), + uintptr(unsafe.Pointer(&info)), //nolint:gosec + uintptr(unsafe.Pointer(&infoLen)), //nolint:gosec 0, ) diff --git a/pkg/interfaces/tcp_windows.go b/pkg/interfaces/tcp_windows.go index 09d1b94..489f0d6 100644 --- a/pkg/interfaces/tcp_windows.go +++ b/pkg/interfaces/tcp_windows.go @@ -26,7 +26,12 @@ func (tc *TCPClientInterface) setTimeoutsWindows() error { return fmt.Errorf("failed to enable keepalive: %v", err) } - if err := tcpConn.SetKeepAlivePeriod(TCP_PROBE_INTERVAL); err != nil { + keepalivePeriod := TCP_PROBE_INTERVAL_SEC * time.Second + if tc.i2pTunneled { + keepalivePeriod = I2P_PROBE_INTERVAL_SEC * time.Second + } + + if err := tcpConn.SetKeepAlivePeriod(keepalivePeriod); err != nil { debug.Log(debug.DEBUG_VERBOSE, "Failed to set keepalive period", "error", err) }