Documentation
¶
Index ¶
- Constants
- Variables
- func AllocSSHSessionID() int32
- func FingerprintKey(k ssh.PublicKey) string
- func GenerateKey(seed string) ([]byte, error)
- func GoStats()
- func HandleTCPStream(l Logger, connStats *ConnStats, src io.ReadWriteCloser, remote string)
- func NewDetermRand(seed []byte) io.Reader
- func ParseAuth(auth string) (string, string)
- func SleepSignal(d time.Duration)
- type Client
- func (c *Client) GetLoopServer() *LoopServer
- func (c *Client) GetSSHConn() (ssh.Conn, error)
- func (c *Client) GetSocksServer() *socks5.Server
- func (c *Client) HandleOnceShutdown(completionErr error) error
- func (c *Client) IsServer() bool
- func (c *Client) Run(ctx context.Context) error
- func (c *Client) Start(ctx context.Context) error
- type Config
- type ConnStats
- type DetermRand
- type GetSSHConn
- type HTTPServer
- type ProxyServerConfig
- type SSHSession
- type Server
- type ServerSSHSession
- type SessionConfigRequest
- type TCPProxy
- type User
- type UserIndex
- type Users
Constants ¶
const DetermRandIter = 2048
DetermRandIter is the number of times a seed is hashed with SHA-512 to produce starting state of a pseudo-random stream
const ProtocolVersion = "sammck-wstunnel-v1"
ProtocolVersion of wstunnel. When backwards incompatible changes are made, this will be incremented to signify a protocol mismatch.
Variables ¶
var BuildVersion = "1.0.0-src"
BuildVersion is the build version for this release
var LastSSHSessionID int32
LastSSHSessionID is the last allocated ID for SSH sessions, for logging purposes
var UserAllowAll = regexp.MustCompile("")
UserAllowAll is a regular expression used to match any address
Functions ¶
func AllocSSHSessionID ¶
func AllocSSHSessionID() int32
AllocSSHSessionID allocates a monotonically incresing session ID number (for debugging/logging only)
func FingerprintKey ¶
FingerprintKey returns a standard fingerprint hash string for an SSH public key, which clients can use to authenticate the SSH server.
func GenerateKey ¶
GenerateKey generates a keypair to use for the SSH server end, using an optional seed that will produce the same keypair every time. If seed is "", a random key will be generated.
func HandleTCPStream ¶
func HandleTCPStream(l Logger, connStats *ConnStats, src io.ReadWriteCloser, remote string)
HandleTCPStream handles a new ssh.Conn from a remote Stub that needs to Dial to a local network resource and pipe between them. Returns when the connection is complete. src will be closed before returning.
func NewDetermRand ¶
NewDetermRand creates an io.Reader that produces pseudo random bytes that are deterministic from a seed
func ParseAuth ¶
ParseAuth parses a ":"-delimited authorization string pair. Returns two empty strings if the input does not contain ":"
func SleepSignal ¶
SleepSignal sleeps for the given duration, or until a SIGHUP is received
Types ¶
type Client ¶
type Client struct { ShutdownHelper // contains filtered or unexported fields }
Client represents a client instance
func (*Client) GetLoopServer ¶
func (c *Client) GetLoopServer() *LoopServer
GetLoopServer returns the shared LoopServer if loop protocol is enabled; nil otherwise
func (*Client) GetSSHConn ¶
GetSSHConn waits for and returns the main ssh.Conn that this proxy is using to communicate with the remote proxy. It is possible that goroutines servicing local stub sockets will ask for this before it is available (if for example a listener on the client accepts a connection before the server has ackknowledged configuration.
func (*Client) GetSocksServer ¶
GetSocksServer returns the shared socks5 server if socks protocol is enabled; nil otherwise
func (*Client) HandleOnceShutdown ¶
HandleOnceShutdown will be called exactly once, in its own goroutine. It should take completionError as an advisory completion value, actually shut down, then return the real completion value.
type Config ¶
type Config struct { Debug bool Fingerprint string Auth string KeepAlive time.Duration MaxRetryCount int MaxRetryInterval time.Duration Server string HTTPProxy string ChdStrings []string HostHeader string // contains filtered or unexported fields }
Config represents a client configuration
type ConnStats ¶
type ConnStats struct {
// contains filtered or unexported fields
}
ConnStats keep track of both currently open and total connection counts for an entity
func (*ConnStats) Close ¶
func (c *ConnStats) Close()
Close subtracts one from the current open connection count in a ConnStats
type DetermRand ¶
type DetermRand struct {
// contains filtered or unexported fields
}
DetermRand keeps running state for a pseudorandom byte stream
type GetSSHConn ¶
GetSSHConn is a callback that is used to defer fetching of the ssh.Conn until after it is established
type HTTPServer ¶
HTTPServer extends net/http Server and adds graceful shutdowns
func NewHTTPServer ¶
func NewHTTPServer(logger Logger) *HTTPServer
NewHTTPServer creates a new HTTPServer
func (*HTTPServer) Close ¶
func (h *HTTPServer) Close() error
Close completely shuts down the server, then returns the final completion code
func (*HTTPServer) HandleOnceShutdown ¶
func (h *HTTPServer) HandleOnceShutdown(completionErr error) error
HandleOnceShutdown will be called exactly once, in its own goroutine. It should take completionError as an advisory completion value, actually shut down, then return the real completion value.
func (*HTTPServer) ListenAndServe ¶
ListenAndServe Runs the HTTP server on the given bind address, invoking the provided handler for each request. It returns after the server has shutdown. The server can be shutdown either by cancelling the context or by calling Shutdown().
func (*HTTPServer) Shutdown ¶
func (h *HTTPServer) Shutdown(completionError error) error
Shutdown completely shuts down the server, then returns the final completion code
type ProxyServerConfig ¶
type ProxyServerConfig struct { KeySeed string AuthFile string Auth string Proxy string Socks5 bool NoLoop bool Reverse bool Debug bool }
ProxyServerConfig is the configuration for the wstunnel service
type SSHSession ¶
type SSHSession struct { ShutdownHelper // contains filtered or unexported fields }
SSHSession wraps a primary SSH connection to the remote proxy
func (*SSHSession) HandleOnceShutdown ¶
func (s *SSHSession) HandleOnceShutdown(completionErr error) error
HandleOnceShutdown will be called exactly once, in its own goroutine. It should take completionError as an advisory completion value, actually shut down, then return the real completion value.
func (*SSHSession) InitSSHSession ¶
func (s *SSHSession) InitSSHSession(logger Logger, localChannelEnv LocalChannelEnv)
InitSSHSession initializes a new SSHSession
func (*SSHSession) String ¶
func (s *SSHSession) String() string
type Server ¶
type Server struct { ShutdownHelper // contains filtered or unexported fields }
Server respresent a wstunnel service
func NewServer ¶
func NewServer(config *ProxyServerConfig) (*Server, error)
NewServer creates and returns a new wstunnel server
func (*Server) DeleteUser ¶
DeleteUser removes a user from the server user index
func (*Server) GetFingerprint ¶
GetFingerprint is used to access the server fingerprint
func (*Server) HandleOnceShutdown ¶
HandleOnceShutdown will be called exactly once, in its own goroutine. It should take completionError as an advisory completion value, actually shut down, then return the real completion value.
type ServerSSHSession ¶
type ServerSSHSession struct { SSHSession // contains filtered or unexported fields }
ServerSSHSession wraps a primary SSH connection with a single client proxy
func NewServerSSHSession ¶
func NewServerSSHSession(server *Server) (*ServerSSHSession, error)
NewServerSSHSession creates a server-side proxy session object
func (*ServerSSHSession) GetLoopServer ¶
func (s *ServerSSHSession) GetLoopServer() *LoopServer
GetLoopServer returns the shared LoopServer if loop protocol is enabled; nil otherwise
func (*ServerSSHSession) GetSSHConn ¶
func (s *ServerSSHSession) GetSSHConn() (ssh.Conn, error)
GetSSHConn waits for and returns the main ssh.Conn that this proxy is using to communicate with the remote proxy. It is possible that goroutines servicing local stub sockets will ask for this before it is available (if for example a listener on the client accepts a connection before the server has ackknowledged configuration. An error response indicates that the SSH connection failed to initialize.
func (*ServerSSHSession) GetSocksServer ¶
func (s *ServerSSHSession) GetSocksServer() *socks5.Server
GetSocksServer returns the shared socks5 server if socks protocol is enabled; nil otherwise
func (*ServerSSHSession) IsServer ¶
func (s *ServerSSHSession) IsServer() bool
IsServer returns true if this is a proxy server; false if it is a cliet
type SessionConfigRequest ¶
type SessionConfigRequest struct { Version string ChannelDescriptors []*ChannelDescriptor }
SessionConfigRequest describes a wstunnel proxy/client session configuration. It is sent from the client to the server during initialization
func PbToSessionConfigRequest ¶
func PbToSessionConfigRequest(pb *interproxy.PbSessionConfigRequest) *SessionConfigRequest
PbToSessionConfigRequest returns a SessionConfigRequest from its protobuf value
func (*SessionConfigRequest) FromPb ¶
func (c *SessionConfigRequest) FromPb(pb *interproxy.PbSessionConfigRequest)
FromPb initializes a SessionConfigRequest from its protobuf value
func (*SessionConfigRequest) Marshal ¶
func (c *SessionConfigRequest) Marshal() ([]byte, error)
Marshal serializes a SessionConfigRequest to protobuf bytes
func (*SessionConfigRequest) ToPb ¶
func (c *SessionConfigRequest) ToPb() *interproxy.PbSessionConfigRequest
ToPb converts a SessionConfigRequest to its protobuf value
func (*SessionConfigRequest) Unmarshal ¶
func (c *SessionConfigRequest) Unmarshal(b []byte) error
Unmarshal unserializes a SessionConfigRequest from protobuf bytes
type TCPProxy ¶
type TCPProxy struct { ShutdownHelper // contains filtered or unexported fields }
TCPProxy proxies a single channel between a local stub endpoint and a remote skeleton endpoint
func NewTCPProxy ¶
func NewTCPProxy(logger Logger, localChannelEnv LocalChannelEnv, index int, chd *ChannelDescriptor) *TCPProxy
NewTCPProxy creates a new TCPProxy
func (*TCPProxy) HandleOnceShutdown ¶
HandleOnceShutdown will be called exactly once, in its own goroutine. It should take completionError as an advisory completion value, actually shut down, then return the real completion value.
type User ¶
User describes a single user's authorization info, including name, password, and a list of channel endpoint regular expressions that are allowed
type UserIndex ¶
type UserIndex struct { Logger *Users // contains filtered or unexported fields }
UserIndex is a reloadable user source
func NewUserIndex ¶
func NewUserIndex(logger Logger) *UserIndex
NewUserIndex creates a source for users