Documentation
¶
Index ¶
Constants ¶
const SO_ORIGINAL_DST = 80
Variables ¶
var ErrRedialAborted = errors.New("unable to restore the connection, aborting")
ErrRedialAborted is returned by Client.Start when the configured backoff strategy gives up.
Functions ¶
Types ¶
type Backoff ¶
type Backoff interface { // Next returns the duration to sleep before retrying reconnections. // If the returned value is negative, the retry is aborted. NextBackOff() time.Duration // Reset is used to signal a reconnection was successful and next // call to Next should return desired time duration for 1st reconnection // attempt. Reset() }
Backoff defines behavior of staggering reconnection retries.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is responsible for connecting to a tunnel server.
type ClientOptions ¶
type ClientOptions struct { // ServerAddr defines the TCP address of the tunnel server to be connected. ServerAddr string // Dial provides custom transport layer for client server communication. Dial func(network, address string) (net.Conn, error) //ProxyFunc provides a hook for forwarding a tunneled connection to its destination. //If non is given SourceRoutedProxy() is used by default. ProxyFunc ProxyFunc //ListenAddr optinally lets the Client open a listening socket and forward traffic //received on the listener to the tunnel server. ListenAddr string // Backoff is used to control behavior of staggering reconnection loop. // // If nil, default backoff policy is used which makes a client to never // give up on reconnection. // // If custom backoff is used, Start() will return ErrRedialAborted set // with ClientClosed event when no more reconnection atttemps should // be made. Backoff Backoff //Logger used by this service instance Logger log.Logger }
ClientOptions defines the configuration for the Client
type Header ¶
Header contains metadata about tunnel requests.
func (Header) Destination ¶
Destination returns the destination as ip:port
func (Header) DestinationIP ¶
DestinationIP returns the destination ip for a tunnel request.
func (Header) DestinationPort ¶
DestinationPort returns the destination port for a tunnle request.
type ProxyFunc ¶
ProxyFunc is responsible for forwarding a tunneled connection to a local destination and writing the response back.
func SourceRoutedProxy ¶
func SourceRoutedProxy() ProxyFunc
SourceRoutedProxy returns a ProxyFunc that honors the header information of the proxied request and forwards traffic to the given header information.
func StaticProxy ¶
StaticProxy ignores the request header and forwards traffic to a static destination
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a tunel Server accepting connections from tunnel clients
func (*Server) AddClientRoute ¶
AddClientRoute adds a route for specific tunnel client. Local tunnel requests for ips that match the given CIDR are routed to the specified client. If a request is matched by multiple routes a random route is choosen.
func (*Server) AddRoute ¶
AddRoute adds a generic route for all client. Incoming request that are matched by the given CIDR are routed to any active client. Generic routes are considered when no client route matched for the given request.
func (*Server) Close ¶
func (s *Server) Close()
Close signals a running server to stop. It returns immediately.
func (*Server) DeleteClientRoute ¶
DeleteClientRoute deletes a route created with AddClientRoute
func (*Server) DeleteRoute ¶
DeleteRoute deletes a generic route.
type ServerOptions ¶
type ServerOptions struct { //Listener is used for accepting tunnel clients. //Default: net.Listen("tcp", ":9090") Listener net.Listener //HijackAddr specifies a local address the server should //accept connections on and forward them to tunnel clients. //Default: 127.0.0.1:9191 HijackAddr string //ProxyFunc provides a hook for forwarding a tunneled connection to its destination. //If non is given NoProxy() is used by default. ProxyFunc ProxyFunc //Logger used by this service instance Logger log.Logger }
ServerOptions hold the configration of a tunnel server