Skip to content

intra/ipn: turn off TCP keepalive by default #148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: n2
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions intra/ipn/auto.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,5 +497,9 @@ func maybeKeepAlive(c net.Conn) {
if settings.GetDialerOpts().LowerKeepAlive {
// adjust TCP keepalive config if c is a TCPConn
core.SetKeepAliveConfigSockOpt(c)
} else {
if tcpConn, ok := c.(*net.TCPConn); ok {
Copy link
Contributor

@ignoramous ignoramous Apr 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

This change could be made in rwext instead and a call to core.SetKeepAliveConfSockOpt be removed from all other places (like auto.go)?

rwext will also have to set the kacfg for DialerOpts.LowerKeepAlive now.

func (rw rwext) SetAsTCPSockOpt() (c *net.TCPConn, ok bool) {
r, w := rw.deadlines()
timeout := max(int(r), int(w))
c, ok = rw.Conn.(*net.TCPConn) // no-op for tcp conns
if ok && r > 0 {
// always returns false for udp conns
ok = core.SetTimeoutSockOpt(c, timeout*1000)
}
return c, ok
}

tcpConn.SetKeepAlive(false)
}
}
}
Loading