Documentation
¶
Overview ¶
Package sshkeepalive runs an OpenSSH-style keepalive heartbeat over an ssh.Client (or any compatible Pinger), so long-lived SSH sessions don't get reaped by NAT/firewall idle timeouts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Start ¶
Start launches a goroutine that sends an OpenSSH "keepalive@openssh.com" global request on p every interval. It returns a stop function the caller MUST invoke when shutting down. stop is idempotent.
An interval <= 0 disables the heartbeat: no goroutine is started and the returned stop is a no-op. This lets callers honor a "keepalive off" setting without special-casing it.
If SendRequest returns an error, the goroutine exits silently. Start does NOT close the underlying connection — the read loop on the client will detect EOF and surface it through the existing close path.
Types ¶
type Pinger ¶
type Pinger interface {
SendRequest(name string, wantReply bool, payload []byte) (bool, []byte, error)
}
Pinger is the subset of *ssh.Client used to send keepalive global requests. Defining it as an interface keeps this package decoupled from net/ssh and makes it trivial to test with a fake.