Documentation
¶
Index ¶
- Variables
- func DialMaybeSRV(ctx context.Context, network, addr string) (net.Conn, error)
- func GetServerTLSConfig(tlsCertFile, tlsKeyFile, tlsMinVersion string, tlsCipherSuites []string) (*tls.Config, error)
- func GetTCPNetwork() string
- func GetUDPNetwork() string
- func IsTrivialNetworkError(err error) bool
- func NewStatDialFunc(metricPrefix string) func(ctx context.Context, network, addr string) (net.Conn, error)
- func NewStatDialFuncWithDial(metricPrefix string, ...) func(ctx context.Context, network, addr string) (net.Conn, error)
- func ParseTLSVersion(s string) (uint16, error)
- func TCP6Enabled() bool
- type TCPListener
Constants ¶
This section is empty.
Variables ¶
var Dialer = &net.Dialer{ Timeout: 30 * time.Second, KeepAlive: 30 * time.Second, DualStack: TCP6Enabled(), }
Dialer is default network dialer.
var Resolver resolver
Resolver is default DNS resolver.
Functions ¶
func DialMaybeSRV ¶
DialMaybeSRV dials the given addr.
The addr may be either the usual TCP address or srv+host form, where host is SRV addr. If the addr has srv+host form, then the host is resolved with SRV into randomly chosen TCP address for the connection.
func GetServerTLSConfig ¶
func GetServerTLSConfig(tlsCertFile, tlsKeyFile, tlsMinVersion string, tlsCipherSuites []string) (*tls.Config, error)
GetServerTLSConfig returns TLS config for the server.
func IsTrivialNetworkError ¶
IsTrivialNetworkError returns true if the err can be ignored during logging.
func NewStatDialFunc ¶
func NewStatDialFunc(metricPrefix string) func(ctx context.Context, network, addr string) (net.Conn, error)
NewStatDialFunc returns dialer function that supports DNS SRV records and registers stats metrics for conns.
func NewStatDialFuncWithDial ¶
func NewStatDialFuncWithDial(metricPrefix string, dialFunc func(ctx context.Context, network, addr string) (net.Conn, error)) func(ctx context.Context, network, addr string) (net.Conn, error)
NewStatDialFuncWithDial returns dialer function that registers stats metrics for conns.
func ParseTLSVersion ¶
ParseTLSVersion returns tls version from the given string s.
func TCP6Enabled ¶
func TCP6Enabled() bool
TCP6Enabled returns true if dialing and listening for IPv4 TCP is enabled.
Types ¶
type TCPListener ¶
TCPListener listens for the addr passed to NewTCPListener.
It also gathers various stats for the accepted connections.
func NewTCPListener ¶
func NewTCPListener(name, addr string, useProxyProtocol bool, tlsConfig *tls.Config) (*TCPListener, error)
NewTCPListener returns new TCP listener for the given addr and optional tlsConfig.
name is used for metrics. Each listener in the program must have a distinct name.
If useProxyProtocol is set to true, then the returned listener accepts TCP connections via proxy protocol. See https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt