package transport

import "github.com/coreos/etcd/pkg/transport"

Package transport implements various HTTP transport utilities based on Go net package.

Package transport provides network utility functions, complementing the more common ones in the net package.

Index

Variables

var (
	ErrNotTCP = errors.New("only tcp connections have keepalive")
)

Functions

func LimitListener

func LimitListener(l net.Listener, n int) net.Listener

LimitListener returns a Listener that accepts at most n simultaneous connections from the provided Listener.

func NewKeepAliveListener

func NewKeepAliveListener(l net.Listener, scheme string, tlscfg *tls.Config) (net.Listener, error)

NewKeepAliveListener returns a listener that listens on the given address. Be careful when wrap around KeepAliveListener with another Listener if TLSInfo is not nil. Some pkgs (like go/http) might expect Listener to return TLSConn type to start TLS handshake. http://tldp.org/HOWTO/TCP-Keepalive-HOWTO/overview.html

func NewListener

func NewListener(addr string, scheme string, tlscfg *tls.Config) (l net.Listener, err error)

func NewTimeoutListener

func NewTimeoutListener(addr string, scheme string, tlscfg *tls.Config, rdtimeoutd, wtimeoutd time.Duration) (net.Listener, error)

NewTimeoutListener returns a listener that listens on the given address. If read/write on the accepted connection blocks longer than its time limit, it will return timeout error.

func NewTimeoutTransport

func NewTimeoutTransport(info TLSInfo, dialtimeoutd, rdtimeoutd, wtimeoutd time.Duration) (*http.Transport, error)

NewTimeoutTransport returns a transport created using the given TLS info. If read/write on the created connection blocks longer than its time limit, it will return timeout error. If read/write timeout is set, transport will not be able to reuse connection.

func NewTransport

func NewTransport(info TLSInfo, dialtimeoutd time.Duration) (*http.Transport, error)

func NewUnixListener

func NewUnixListener(addr string) (net.Listener, error)

func ShallowCopyTLSConfig

func ShallowCopyTLSConfig(cfg *tls.Config) *tls.Config

ShallowCopyTLSConfig copies *tls.Config. This is only work-around for go-vet tests, which complains

assignment copies lock value to p: crypto/tls.Config contains sync.Once contains sync.Mutex

Keep up-to-date with 'go/src/crypto/tls/common.go'

func ValidateSecureEndpoints

func ValidateSecureEndpoints(tlsInfo TLSInfo, eps []string) ([]string, error)

ValidateSecureEndpoints scans the given endpoints against tls info, returning only those endpoints that could be validated as secure.

Types

type TLSInfo

type TLSInfo struct {
	CertFile       string
	KeyFile        string
	CAFile         string
	TrustedCAFile  string
	ClientCertAuth bool

	// ServerName ensures the cert matches the given host in case of discovery / virtual hosting
	ServerName string
	// contains filtered or unexported fields
}

func SelfCert

func SelfCert(dirpath string, hosts []string) (info TLSInfo, err error)

func (TLSInfo) ClientConfig

func (info TLSInfo) ClientConfig() (*tls.Config, error)

ClientConfig generates a tls.Config object for use by an HTTP client.

func (TLSInfo) Empty

func (info TLSInfo) Empty() bool

func (TLSInfo) ServerConfig

func (info TLSInfo) ServerConfig() (*tls.Config, error)

ServerConfig generates a tls.Config object for use by an HTTP server.

func (TLSInfo) String

func (info TLSInfo) String() string

Source Files

doc.go keepalive_listener.go limit_listen.go listener.go timeout_conn.go timeout_dialer.go timeout_listener.go timeout_transport.go tls.go transport.go unix_listener.go

Version
v3.0.16+incompatible
Published
Jan 13, 2017
Platform
js/wasm
Imports
19 packages
Last checked
2 hours ago

Tools for package owners.