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) }