Documentation
¶
Overview ¶
Package client wraps a wsmux client session in a net.Listener interface. It attempts to reconnect to the proxy in case of a connection failure. It can be configured by setting the appropriate parameters in the Config object passed to client.New().
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrRetryTimedOut is returned when Reconnect() time exceeds MaxElapsedTime. ErrRetryTimedOut = Error{/* contains filtered or unexported fields */} // ErrBadToken is returned when a usable token can not be generated by the authorizer. ErrBadToken = Error{/* contains filtered or unexported fields */} // ErrRetryFailed is returned when retry attempts fail. ErrRetryFailed = Error{/* contains filtered or unexported fields */} // ErrClientReconnecting is returned when the connection is reconnecting. // This is a temporary error, and callers should retry the operation after // a delay. ErrClientReconnecting = Error{/* contains filtered or unexported fields */} // ErrClientClosed is returned from an Accept call when the client is closed. ErrClientClosed = Error{/* contains filtered or unexported fields */} // ErrAuthFailed is returned when authentication with the proxy fails ErrAuthFailed = Error{/* contains filtered or unexported fields */} )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is used to connect to a websocktunnel instance and serve content over the tunnel. Client implements net.Listener.
func (*Client) Accept ¶
Accept is used to accept multiplexed streams from the tunnel as a net.Conn implementer.
This is a net.Listener interface method.
func (*Client) Addr ¶
Addr returns the net.Addr of the underlying wsmux session
This is a net.Listener method. Its return value in this case is not especially useful.
type Config ¶
type Config struct { // The client ID to register ID string // The address of the websocktunnel server (https:// or wss://) TunnelAddr string // The JWT to authenticate to the websocktunnel server. This should be // a "fresh" token for each call to the Configurer. Token string // Configuration for retrying connections to the server Retry RetryConfig // A Logger for logging status updates; default is no logging Logger util.Logger }
Config contains the configuration for a Client. This is generated by a Configurer.
type Configurer ¶
Configurer is a function which can generate a Config object to be used by the client. This is called whenever a reconnection is made, and should return a Config with a "fresh" token at that time.
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error represents an error from the client package. It implements net.Error, and in particular the err.Temporary() function is useful for distinguishing temporary, retryable errors from permanent errors.
type RetryConfig ¶
type RetryConfig struct { // InitialDelay is the delay after which the first reconnect // attempt takes place. // Default = 500 * time.Millisecond InitialDelay time.Duration // MaxDelay is the maximum possible delay between two consecutive // reconnect attempts. // Default = 60 * time.Second MaxDelay time.Duration // MaxElapsedTime is the time after which reconnect will time out // Default = 3 * time.Minute MaxElapsedTime time.Duration // Multplier is the rate at which the delay will increase // Default = 1.5 Multiplier float64 // RandomizationFactor is the extent to which the delay values will be randomized // Default = 0.5 RandomizationFactor float64 }
RetryConfig contains exponential backoff parameters for retrying connections. In most cases, the default values are good enough.