transport

package
v0.0.0-...-d04734d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2017 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotConnected = errors.New("client is not connected")
)

Functions

func Dial

func Dial(c *Config, network, address string) (net.Conn, error)

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(c *Config, network, host string, defaultPort int) (*Client, error)

func NewClientWithDialer

func NewClientWithDialer(d Dialer, network, host string, defaultPort int) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) Connect

func (c *Client) Connect() error

func (*Client) IsConnected

func (c *Client) IsConnected() bool

func (*Client) LocalAddr

func (c *Client) LocalAddr() net.Addr

func (*Client) Read

func (c *Client) Read(b []byte) (int, error)

func (*Client) RemoteAddr

func (c *Client) RemoteAddr() net.Addr

func (*Client) SetDeadline

func (c *Client) SetDeadline(t time.Time) error

func (*Client) SetReadDeadline

func (c *Client) SetReadDeadline(t time.Time) error

func (*Client) SetWriteDeadline

func (c *Client) SetWriteDeadline(t time.Time) error

func (*Client) Write

func (c *Client) Write(b []byte) (int, error)

type Config

type Config struct {
	Proxy   *ProxyConfig
	TLS     *TLSConfig
	Timeout time.Duration
	Stats   *IOStats
}

type Dialer

type Dialer interface {
	Dial(network, address string) (net.Conn, error)
}

func ConnWrapper

func ConnWrapper(d Dialer, w func(net.Conn) net.Conn) Dialer

func MakeDialer

func MakeDialer(c *Config) (Dialer, error)

func NetDialer

func NetDialer(timeout time.Duration) Dialer

func ProxyDialer

func ProxyDialer(config *ProxyConfig, forward Dialer) (Dialer, error)

func StatsDialer

func StatsDialer(d Dialer, s *IOStats) Dialer

func TLSDialer

func TLSDialer(
	forward Dialer,
	config *TLSConfig,
	timeout time.Duration,
) (Dialer, error)

type DialerFunc

type DialerFunc func(network, address string) (net.Conn, error)

func (DialerFunc) Dial

func (d DialerFunc) Dial(network, address string) (net.Conn, error)

type IOStats

type IOStats struct {
	Read, Write, ReadErrors, WriteErrors *expvar.Int
}

type ProxyConfig

type ProxyConfig struct {
	// URL of the SOCKS proxy. Scheme must be socks5. Username and password can be
	// embedded in the URL.
	URL string `config:"proxy_url"`

	// Resolve names locally instead of on the SOCKS server.
	LocalResolve bool `config:"proxy_use_local_resolver"`
}

ProxyConfig holds the configuration information required to proxy connections through a SOCKS5 proxy server.

func (*ProxyConfig) Validate

func (c *ProxyConfig) Validate() error

type TLSConfig

type TLSConfig struct {
	// List of allowed SSL/TLS protocol versions. Connections might be dropped
	// after handshake succeeded, if TLS version in use is not listed.
	Versions []TLSVersion

	// Configure SSL/TLS verification mode used during handshake. By default
	// VerifyFull will be used.
	Verification TLSVerificationMode

	// List of certificate chains to present to the other side of the
	// connection.
	Certificates []tls.Certificate

	// Set of root certificate authorities use to verify server certificates.
	// If RootCAs is nil, TLS might use the system its root CA set (not supported
	// on MS Windows).
	RootCAs *x509.CertPool

	// List of supported cipher suites. If nil, a default list provided by the
	// implementation will be used.
	CipherSuites []uint16

	// Types of elliptic curves that will be used in an ECDHE handshake. If empty,
	// the implementation will choose a default.
	CurvePreferences []tls.CurveID
}

func (*TLSConfig) BuildModuleConfig

func (c *TLSConfig) BuildModuleConfig(host string) *tls.Config

type TLSVerificationMode

type TLSVerificationMode uint8
const (
	VerifyFull TLSVerificationMode = iota
	VerifyNone
)

func (TLSVerificationMode) String

func (m TLSVerificationMode) String() string

func (*TLSVerificationMode) Unpack

func (m *TLSVerificationMode) Unpack(in interface{}) error

type TLSVersion

type TLSVersion uint16
const (
	TLSVersionSSL30 TLSVersion = tls.VersionSSL30
	TLSVersion10    TLSVersion = tls.VersionTLS10
	TLSVersion11    TLSVersion = tls.VersionTLS11
	TLSVersion12    TLSVersion = tls.VersionTLS12
)

func (TLSVersion) String

func (v TLSVersion) String() string

func (*TLSVersion) Unpack

func (v *TLSVersion) Unpack(s string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL