Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnectionState ¶
type ConnectionState int
ConnectionState represents the state of the SSH tunnel. It's returned to an optional function provided to SetConnState.
const ( // StateStopped represents a stopped tunnel. A call to Start will make the state to transition to StateStarting. StateStopped ConnectionState = iota // StateStarting represents a tunnel initializing and preparing to listen for connections. // A successful initialization will make the state to transition to StateStarted, otherwise it will transition to StateStopped. StateStarting // StateStarted represents a tunnel ready to accept connections. // A call to stop or an error will make the state to transition to StateStopped. StateStarted )
type Endpoint ¶
type Endpoint struct {
// contains filtered or unexported fields
}
func NewTCPEndpoint ¶
func NewUnixEndpoint ¶
type SshTunnel ¶
type SshTunnel struct {
// contains filtered or unexported fields
}
func New ¶
func New(tsnetConn *tsnet.Server, localPort int, server string, serverPort, remotePort int) *SshTunnel
New creates a new SSH tunnel to the specified server redirecting a port on local localhost to a port on remote localhost. The states of the tunnel can be received through a callback function with SetConnState. The states of the tunneled connections can be received through a callback function with SetTunneledConnState.
func NewUnix ¶
func NewUnix(tsnetConn *tsnet.Server, localUnixSocket, server string, serverPort int, remoteUnixSocket string) *SshTunnel
NewUnix does the same as New but using unix sockets.
func (*SshTunnel) SetConnState ¶
func (tun *SshTunnel) SetConnState(connStateFun func(*SshTunnel, ConnectionState))
SetConnState specifies an optional callback function that is called when a SSH tunnel changes state. See the ConnState type and associated constants for details.
func (*SshTunnel) SetTunneledConnState ¶
func (tun *SshTunnel) SetTunneledConnState(tunneledConnStateFun func(*SshTunnel, *TunneledConnectionState))
SetTunneledConnState specifies an optional callback function that is called when the underlying tunneled connections change state.
type TunneledConnectionState ¶
type TunneledConnectionState struct { // From is the address initating the connection. From string // Info holds a message with info on the state of the connection (useful for debug purposes). Info string // Error holds an error on the connection or nil if the connection is successful. Error error // Ready indicates if the connection is established. Ready bool // Closed indicates if the coonnection is closed. Closed bool }
TunneledConnectionState represents the state of the final connections made through the tunnel.
func (*TunneledConnectionState) String ¶
func (s *TunneledConnectionState) String() string