tunnel

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2017 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

type DialCloser interface {
	Dial(n, addr string) (net.Conn, error)
	Close() error
}

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

func (t *Tunnel) PrepareForServe() error

PrepareForServe prepares the Tunnel for serving connections. It must be called before Serve, which typically runs in a separate goroutine.

func (*Tunnel) Serve

func (t *Tunnel) Serve(ctx context.Context, l net.Listener) error

Serve starts the tunnel's server on the local address. It is a blocking call that always returns an error.

func (*Tunnel) Touch

func (t *Tunnel) Touch() bool

Touch generates activity on the tunnel to prevent it from closing due to inactivity. It returns true if the tunnel was active when this was called, false otherwise.

Jump to

Keyboard shortcuts

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