Documentation ¶
Index ¶
Constants ¶
const ( // MagicNr is the bytes sent during handshake to identity a tcprouter client connection // TODO: chose a valid magic number MagicNr = 0x1111 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client connect to a tpc router server and opens a reverse tunnel
type Config ¶
type Config struct {
Server ServerConfig `toml:"server"`
}
Config hold the server configuration
type Conn ¶
type Conn struct { // Peeked are the bytes that have been read from Conn for the // purposes of route matching, but have not yet been consumed // by Read calls. It set to nil by Read when fully consumed. Peeked []byte // Conn is the underlying connection. // It can be type asserted against *net.TCPConn or other types // as needed. It should not be read from directly unless // Peeked is nil. WriteCloser }
Conn is a connection proxy that handles Peeked bytes
type DbBackendConfig ¶
type DbBackendConfig struct { DbType string `toml:"type"` Host string `toml:"addr"` Port uint `toml:"port"` Username string `toml:"username"` Password string `toml:"password"` Token string `toml:"token"` Refresh uint `toml:"refresh"` }
DbBackendConfig define the connection to a backend store
func (DbBackendConfig) Addr ¶
func (b DbBackendConfig) Addr() string
Addr returns the listenting address of the server
func (DbBackendConfig) Backend ¶
func (b DbBackendConfig) Backend() store.Backend
Backend return the Backend object of the b.DbType
type Handler ¶
type Handler interface {
ServeTCP(conn WriteCloser)
}
Handler is the TCP Handlers interface
type HandlerFunc ¶
type HandlerFunc func(conn WriteCloser)
The HandlerFunc type is an adapter to allow the use of ordinary functions as handlers.
type Server ¶
type Server struct { ServerOptions ServerOptions DbStore store.Store Services map[string]Service // contains filtered or unexported fields }
Server is tcp router server
type ServerConfig ¶
type ServerConfig struct { Host string `toml:"addr"` Port uint `toml:"port"` HTTPPort uint `toml:"httpport"` ClientsPort uint `toml:"clientsport"` DbBackend DbBackendConfig `toml:"dbbackend"` Services map[string]Service `toml:"services"` }
ServerConfig configures the server listeners and backend
func (ServerConfig) Addr ¶
func (s ServerConfig) Addr() string
Addr returns the listenting address of the server
type ServerOptions ¶
type ServerOptions struct { ListeningAddr string ListeningTLSPort uint ListeningHTTPPort uint ListeningForClientsPort uint }
ServerOptions hold the configuration of server listeners
func (ServerOptions) ClientsAddr ¶
func (o ServerOptions) ClientsAddr() string
ClientsAddr returns the client listener address
func (ServerOptions) HTTPAddr ¶
func (o ServerOptions) HTTPAddr() string
HTTPAddr returns the HTTP listener address
func (ServerOptions) TLSAddr ¶
func (o ServerOptions) TLSAddr() string
TLSAddr returns the TLS listener address
type Service ¶
type Service struct { Addr string `toml:"addr"` ClientSecret string `toml:"clientsecret` // will forward connection to it directly instead of hitting the Addr. TLSPort int `toml:"tlsport"` HTTPPort int `toml:"httpport"` }
Service defines a proxy configuration
type WriteCloser ¶
type WriteCloser interface { net.Conn // CloseWrite on a network connection, indicates that the issuer of the call // has terminated sending on that connection. // It corresponds to sending a FIN packet. CloseWrite() error }
WriteCloser describes a net.Conn with a CloseWrite method.
func GetConn ¶
func GetConn(conn WriteCloser, peeked string) WriteCloser
GetConn creates a connection proxy with a peeked string
func WrapConn ¶
func WrapConn(conn *yamux.Stream) WriteCloser
WrapConn wraps a stream into a wrappedCon so it implements the WriteCloser interface