Documentation ¶
Index ¶
- Constants
- func PreDetectFixedSSHVersion(versionPrefix string) multiplexer.PreDetectFunc
- func WrapSSHClientConn(ctx context.Context, nc net.Conn, redial redialFunc) (net.Conn, error)
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) LocalAddr() net.Addr
- func (c *Conn) Read(b []byte) (n int, err error)
- func (c *Conn) RemoteAddr() net.Addr
- func (c *Conn) SetDeadline(t time.Time) error
- func (c *Conn) SetReadDeadline(t time.Time) error
- func (c *Conn) SetWriteDeadline(t time.Time) error
- func (c *Conn) Write(b []byte) (n int, err error)
- type SSHServerWrapper
Constants ¶
const Component = "resumable"
Component is the logging "component" for connection resumption.
Variables ¶
This section is empty.
Functions ¶
func PreDetectFixedSSHVersion ¶
func PreDetectFixedSSHVersion(versionPrefix string) multiplexer.PreDetectFunc
PreDetectFixedSSHVersion returns a multiplexer.PreDetectFunc that sends a fixed SSH version identifier at connection open and wraps the connection with a sshutils.SSHServerVersionOverrider with the same version identifier. versionPrefix should not include the trailing CRLF.
func WrapSSHClientConn ¶
WrapSSHClientConn tries to detect if the server at the other end of nc is a resumption v1 server, and if so it returns a net.Conn that will transparently resume itself (using the provided redial func). If the connection is wrapped, the context applies to the lifetime of the returned connection, not just the duration of the function call.
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is a net.Conn whose underlying transport can be closed and reopened, to maintain the illusion of a perfect unbroken stream of bytes even if network conditions would otherwise terminate a normal connection.
func (*Conn) SetDeadline ¶
SetDeadline implements net.Conn.
func (*Conn) SetReadDeadline ¶
SetReadDeadline implements net.Conn.
func (*Conn) SetWriteDeadline ¶
SetWriteDeadline implements net.Conn.
type SSHServerWrapper ¶
type SSHServerWrapper struct {
// contains filtered or unexported fields
}
SSHServerWrapper wraps a SSH server, keeping track of which resumption v1 connections can be resumed by the client. Connections that stay without an active underlying connection for a given time ([detachedTimeout]) are forcibly closed.
func NewSSHServerWrapper ¶
func NewSSHServerWrapper(log logrus.FieldLogger, sshServer func(net.Conn), hostID string) *SSHServerWrapper
NewSSHServerWrapper wraps a given SSH server as to support connection resumption.
func (*SSHServerWrapper) HandleConnection ¶
func (r *SSHServerWrapper) HandleConnection(nc net.Conn)
HandleConnection generates the handshake ECDH key and sends it as the SSH server version identifier, then checks if the client supports resumption, running the connection as a resumable connection if that's the case, or handing the connection to the underlying SSH server otherwise.
func (*SSHServerWrapper) PreDetect ¶
func (r *SSHServerWrapper) PreDetect(nc net.Conn) (multiplexer.PostDetectFunc, error)
PreDetect is intended to be used in a multiplexer.Mux as the PreDetect hook; it generates the handshake ECDH key and sends it as the SSH server version identifier, then returns a post-detect hook to check if the client supports resumption and to hijack its connection if that's the case.