docs update

This commit is contained in:
mmatczuk 2017-02-15 22:01:32 +01:00
parent 8da19da161
commit e8fdccb05a
6 changed files with 19 additions and 20 deletions

View file

@ -8,7 +8,7 @@ type Auth struct {
Password string
}
// NewAuth creates new auth from string representation.
// NewAuth creates new auth from string representation "user:password".
func NewAuth(auth string) *Auth {
if auth == "" {
return nil

View file

@ -30,15 +30,15 @@ type ClientConfig struct {
// DialTLS specifies an optional dial function that creates a tls
// connection to the server. If DialTLS is nil, tls.Dial is used.
DialTLS func(network, addr string, config *tls.Config) (net.Conn, error)
// Backoff specifies wait before retry policy when server ch fails.
// If nil when ch fails it would immediately return error.
// Backoff specifies backoff policy on server connection retry. If nil
// when dial fails it will not be retried.
Backoff Backoff
// Tunnels specifies tunnels client requests to be opened on server.
// Tunnels specifies the tunnels client requests to be opened on server.
Tunnels map[string]*proto.Tunnel
// Proxy is ProxyFunc responsible for transferring data between server
// and local services.
Proxy ProxyFunc
// Logger is optional logger. If nil no logs will be printed.
// Logger is optional logger. If nil logging is disabled.
Logger log.Logger
}
@ -84,9 +84,10 @@ func NewClient(config *ClientConfig) *Client {
return c
}
// Start connects client to the server, it returns error if there is a dial
// error, otherwise it spawns a new goroutine with http/2 server handling
// ControlMessages.
// Start connects client to the server, it returns error if there is a
// connection error, or server cannot open requested tunnels. On connection
// error a backoff policy is used to reestablish the connection. When connected
// HTTP/2 server is started to handle ControlMessages.
func (c *Client) Start() error {
c.logger.Log(
"level", 1,
@ -285,8 +286,7 @@ func (c *Client) handleHandshake(w http.ResponseWriter, r *http.Request) {
w.Write(b)
}
// Stop closes the connection between client and server. After stopping client
// can be started again.
// Stop disconnects client from server.
func (c *Client) Stop() {
c.connMu.Lock()
defer c.connMu.Unlock()

View file

@ -52,8 +52,7 @@ func NewHTTPProxy(localURL *url.URL, logger log.Logger) *HTTPProxy {
}
// NewMultiHTTPProxy creates a new dispatching HTTPProxy, requests may go to
// different backends based on localURLMap, see HTTPProxy localURLMap docs for
// more details.
// different backends based on localURLMap.
func NewMultiHTTPProxy(localURLMap map[string]*url.URL, logger log.Logger) *HTTPProxy {
if localURLMap == nil || len(localURLMap) == 0 {
panic("Empty localURLMap")

View file

@ -9,8 +9,8 @@ type Logger interface {
Log(keyvals ...interface{}) error
}
// Context is simplified version of
// [go-kit log Context](https://godoc.org/github.com/go-kit/kit/log#Context).
// Context is simplified version of go-kit log Context
// https://godoc.org/github.com/go-kit/kit/log#Context.
type Context struct {
prefix []interface{}
suffix []interface{}

View file

@ -20,14 +20,15 @@ import (
// ServerConfig defines configuration for the Server.
type ServerConfig struct {
// Addr is tcp address to listen on for client connections, ":0" if empty.
// Addr is TCP address to listen for client connections. If empty ":0"
// is used.
Addr string
// TLSConfig specifies the tls configuration to use with tls.Listener.
TLSConfig *tls.Config
// Listener specifies optional listener that clients would connect to.
// If Listener is nil tls.Listen("tcp", Addr, TLSConfig) is used.
// Listener specifies optional listener for client connections. If nil
// tls.Listen("tcp", Addr, TLSConfig) is used.
Listener net.Listener
// Logger is optional logger. If nil no logs will be printed.
// Logger is optional logger. If nil logging is disabled.
Logger log.Logger
}

View file

@ -42,8 +42,7 @@ func NewTCPProxy(localAddr string, logger log.Logger) *TCPProxy {
}
// NewMultiTCPProxy creates a new dispatching TCPProxy, connections may go to
// different backends based on localAddrMap, see TCPProxy localAddrMap docs for
// more details.
// different backends based on localAddrMap.
func NewMultiTCPProxy(localAddrMap map[string]string, logger log.Logger) *TCPProxy {
if localAddrMap == nil || len(localAddrMap) == 0 {
panic("Empty localAddrMap")