Documentation ¶
Index ¶
Constants ¶
const ( DefaultBackoffInterval = 500 * time.Millisecond DefaultBackoffMultiplier = 1.5 DefaultBackoffMaxInterval = 60 * time.Second DefaultBackoffMaxTime = 15 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
func ExpBackoff ¶
func ExpBackoff(c BackoffConfig) *backoff.ExponentialBackOff
Types ¶
type Backoff ¶
type Backoff interface { // Next returns the duration to sleep before retrying to reconnect. // 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 BackoffConfig ¶
type BackoffConfig struct { Interval time.Duration `yaml:"interval"` Multiplier float64 `yaml:"multiplier"` MaxInterval time.Duration `yaml:"max_interval"` MaxTime time.Duration `yaml:"max_time"` }
BackoffConfig defines behavior of staggering reconnection retries.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is responsible for creating connection to the server, handling control messages. It uses ProxyFunc for transferring data between server and local services.
func NewClient ¶
func NewClient(config *ClientConfig) (*Client, error)
NewClient creates a new unconnected Client based on configuration. Caller must invoke Start() on returned instance in order to connect server.
type ClientConfig ¶
type ClientConfig struct { // ServerAddress specifies TCP address of the tunnel server. ServerAddress string // Tunnels specifies the tunnels client requests to be opened on server. Tunnels map[string]*Tunnel // Logger is optional logger. If nil logging is disabled. Logger *log.Entry // AuthToken authentication token used to establish http tunnel AuthToken string // IdName optional name for client IdName string }
ClientConfig is configuration of the Client.
type ProxyFunc ¶
type ProxyFunc func(w io.Writer, r io.ReadCloser, msg *proto.ControlMessage)
ProxyFunc is responsible for forwarding a remote connection to local server and writing the response.
func Proxy ¶
func Proxy(p ProxyFuncs) ProxyFunc
Proxy returns a ProxyFunc that uses custom function if provided.
type ProxyFuncs ¶
type ProxyFuncs struct { // HTTP is custom implementation of HTTP proxing. HTTP ProxyFunc // TCP is custom implementation of TCP proxing. TCP ProxyFunc }
ProxyFuncs is a collection of ProxyFunc.