Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var SSHDialFunc = DefaultSSHDial
SSHDialFunc is a variable that references the SSH dial function to use so that it can be mocked for tests.
Functions ¶
This section is empty.
Types ¶
type DialCloser ¶
DialCloser defines the required functions implemented by an SSH Client.
func DefaultSSHDial ¶
func DefaultSSHDial(n, addr string, config *ssh.ClientConfig) (DialCloser, error)
DefaultSSHDial is the default implementation to use for SSH Dial.
type Tunnel ¶
type Tunnel struct { // The address of the SSH server. SSH net.Addr // Config is the configuration to use to dial to the SSH server. Config *ssh.ClientConfig // The local address on which the tunnel is exposed. Local net.Addr // The remote address to connect to via the SSH connection. Remote net.Addr // The duration after which the tunnel is closed if there is no // activity. IdleTimeout time.Duration // The expvar tunnel statistics. Stats *expvar.Map // The channel to send errors to. If nil, the errors are logged. // If the send would block, the error is dropped. It is the responsibility // of the caller to close the channel once the Tunnel is stopped. ErrChan chan<- error // The function to cancel the context of the Tunnel. KillFunc func() // contains filtered or unexported fields }
Tunnel represents an SSH tunnel that connects to Remote via the Dialer (an SSH connection) and forwards the data between Remote and Local addresses.
func (*Tunnel) KillAndWait ¶
func (t *Tunnel) KillAndWait()
KillAndWait stops the tunnel by cancelling its context using KillFunc and waits for a clean termination to complete before returning.
func (*Tunnel) PrepareForServe ¶
PrepareForServe prepares the Tunnel for serving connections. It must be called before Serve, which typically runs in a separate goroutine.