Documentation
¶
Index ¶
- Variables
- type ConnectionState
- type Forward
- type TunnelManager
- func (tm *TunnelManager) AddForward(localPort, remotePort int) error
- func (tm *TunnelManager) Close() error
- func (tm *TunnelManager) Connect(ctx context.Context, host string, port int) error
- func (tm *TunnelManager) Exec(cmd string) ([]byte, error)
- func (tm *TunnelManager) ExecContext(ctx context.Context, cmd string) ([]byte, error)
- func (tm *TunnelManager) IsConnected() bool
- func (tm *TunnelManager) ListListeningPorts() ([]int, error)
- func (tm *TunnelManager) OpenShell() error
- func (tm *TunnelManager) RemoveForward(localPort int)
- func (tm *TunnelManager) SetConnectionStateCallback(cb func(ConnectionState))
- func (tm *TunnelManager) SetKeepAliveRTTCallback(cb func(time.Duration))
- func (tm *TunnelManager) SetReconnectTargetProvider(fn func(context.Context) (string, int, error))
- func (tm *TunnelManager) StartAutoDetect(interval time.Duration, configured map[int]struct{}, exclude map[int]struct{}, ...)
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrLocalPortInUse = errors.New("local port already in use")
Functions ¶
This section is empty.
Types ¶
type ConnectionState ¶
type ConnectionState string
const ( StateDisconnected ConnectionState = "disconnected" StateReconnecting ConnectionState = "reconnecting" StateConnected ConnectionState = "connected" )
type TunnelManager ¶
type TunnelManager struct {
SSHUser string
SSHKeyPath string
RemotePort int
Env map[string]string
KeepAliveInterval time.Duration
KeepAliveTimeout time.Duration
// contains filtered or unexported fields
}
TunnelManager manages one SSH client connection and a set of local forwards.
func (*TunnelManager) AddForward ¶
func (tm *TunnelManager) AddForward(localPort, remotePort int) error
AddForward starts a local listener and forwards accepted connections to remotePort.
func (*TunnelManager) Close ¶
func (tm *TunnelManager) Close() error
Close tears down all listeners and the SSH connection.
func (*TunnelManager) Exec ¶
func (tm *TunnelManager) Exec(cmd string) ([]byte, error)
Exec runs a remote command on the connected SSH client.
func (*TunnelManager) ExecContext ¶
func (*TunnelManager) IsConnected ¶
func (tm *TunnelManager) IsConnected() bool
IsConnected reports if an SSH client is present.
func (*TunnelManager) ListListeningPorts ¶
func (tm *TunnelManager) ListListeningPorts() ([]int, error)
ListListeningPorts queries remote TCP listeners.
func (*TunnelManager) OpenShell ¶
func (tm *TunnelManager) OpenShell() error
OpenShell opens an interactive shell over the current SSH client.
func (*TunnelManager) RemoveForward ¶
func (tm *TunnelManager) RemoveForward(localPort int)
RemoveForward stops a local listener for localPort.
func (*TunnelManager) SetConnectionStateCallback ¶
func (tm *TunnelManager) SetConnectionStateCallback(cb func(ConnectionState))
func (*TunnelManager) SetKeepAliveRTTCallback ¶
func (tm *TunnelManager) SetKeepAliveRTTCallback(cb func(time.Duration))
func (*TunnelManager) SetReconnectTargetProvider ¶
func (*TunnelManager) StartAutoDetect ¶
func (tm *TunnelManager) StartAutoDetect(interval time.Duration, configured map[int]struct{}, exclude map[int]struct{}, onAdd func(port int), onRemove func(port int))
StartAutoDetect polls listening ports and calls onAdd/onRemove for diffs.
Click to show internal directories.
Click to hide internal directories.