resumption

package
v0.0.0-...-5c79d48 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2024 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
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

func WrapSSHClientConn(ctx context.Context, nc net.Conn, redial redialFunc) (net.Conn, error)

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

func (c *Conn) Close() error

Close implements net.Conn.

func (*Conn) LocalAddr

func (c *Conn) LocalAddr() net.Addr

LocalAddr implements net.Conn.

func (*Conn) Read

func (c *Conn) Read(b []byte) (n int, err error)

Read implements net.Conn.

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() net.Addr

RemoteAddr implements net.Conn.

func (*Conn) SetDeadline

func (c *Conn) SetDeadline(t time.Time) error

SetDeadline implements net.Conn.

func (*Conn) SetReadDeadline

func (c *Conn) SetReadDeadline(t time.Time) error

SetReadDeadline implements net.Conn.

func (*Conn) SetWriteDeadline

func (c *Conn) SetWriteDeadline(t time.Time) error

SetWriteDeadline implements net.Conn.

func (*Conn) Write

func (c *Conn) Write(b []byte) (n int, err error)

Write 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

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL