Documentation ¶
Overview ¶
Package netutil provides network utility functions, complementing the more common ones in the net package.
Index ¶
- Variables
- func LimitListener(l net.Listener, n int) net.Listener
- func NewKeepAliveListener(l net.Listener, scheme string, info TLSInfo) (net.Listener, error)
- func NewListener(addr string, scheme string, info TLSInfo) (net.Listener, error)
- func NewTimeoutListener(addr string, scheme string, info TLSInfo, rdtimeoutd, wtimeoutd time.Duration) (net.Listener, error)
- func NewTimeoutTransport(info TLSInfo, dialtimeoutd, rdtimeoutd, wtimeoutd time.Duration) (*http.Transport, error)
- func NewTransport(info TLSInfo) (*http.Transport, error)
- type TLSInfo
Constants ¶
This section is empty.
Variables ¶
var (
ErrNotTCP = errors.New("only tcp connections have keepalive")
)
Functions ¶
func LimitListener ¶
LimitListener returns a Listener that accepts at most n simultaneous connections from the provided Listener.
func NewKeepAliveListener ¶
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 NewTimeoutListener ¶
func NewTimeoutListener(addr string, scheme string, info TLSInfo, 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.
Types ¶
type TLSInfo ¶
type TLSInfo struct { CertFile string KeyFile string CAFile string TrustedCAFile string ClientCertAuth bool // contains filtered or unexported fields }
func (TLSInfo) ClientConfig ¶
ClientConfig generates a tls.Config object for use by an HTTP client.
func (TLSInfo) ServerConfig ¶
ServerConfig generates a tls.Config object for use by an HTTP server.