netutil: github.com/cybozu-go/netutil Index | Files

package netutil

import "github.com/cybozu-go/netutil"

Package netutil provides a few more network utilities over golang.org/x/net/netutil.

This package overrides netutil namespace since it provides all functions in golang.org/x/net/netutil.

Index

Package Files

doc.go errors.go halfclose.go tcpkeepalive.go tls.go v4util.go x.go

Variables

var (
    // ErrIPv6 is an error that a function does not support IPv6.
    ErrIPv6 = errors.New("only IPv4 address is supported")
)

func CipherSuiteString Uses

func CipherSuiteString(suite uint16) string

CipherSuiteString returns string ID for the given cipher suite defined in crypto/tls.

func HostsFunc Uses

func HostsFunc(n *net.IPNet) (func() net.IP, error)

HostsFunc returns a function to generate all IP addresses in a network. The network address and the broadcast address of the network will be excluded.

The returned function will finally generate nil to tell the end.

The network must be an IPv4 network.

func IP4ToInt Uses

func IP4ToInt(ip net.IP) uint32

IP4ToInt returns uint32 value for an IPv4 address. If ip is not an IPv4 address, this returns 0.

func IntToIP4 Uses

func IntToIP4(n uint32) net.IP

IntToIP4 does the reverse of IP4ToInt.

func IsConnectionRefused Uses

func IsConnectionRefused(err error) bool

IsConnectionRefused returns true if err indicates ECONNREFUSED errno.

func IsNetworkUnreachable Uses

func IsNetworkUnreachable(err error) bool

IsNetworkUnreachable returns true if err indicates ENETUNREACH errno.

func IsNoRouteToHost Uses

func IsNoRouteToHost(err error) bool

IsNoRouteToHost returns true if err indicates EHOSTUNREACH errno.

func KeepAliveListener Uses

func KeepAliveListener(l net.Listener) net.Listener

KeepAliveListener returns TCPKeepAliveListener if l is a *net.TCPListener. Otherwise, l is returned without change.

func LimitListener Uses

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

LimitListener is the same as https://godoc.org/golang.org/x/net/netutil#LimitListener

func SetKeepAlive Uses

func SetKeepAlive(c net.Conn)

SetKeepAlive enables TCP keep-alive if c is a *net.TCPConn.

func TLSVersionString Uses

func TLSVersionString(ver uint16) string

TLSVersionString returns string for the given SSL/TLS version.

type HalfCloser Uses

type HalfCloser interface {
    CloseRead() error
    CloseWrite() error
}

HalfCloser is an interface for connections that can be half-closed. TCPConn and UNIXConn implement this.

type TCPKeepAliveListener Uses

type TCPKeepAliveListener struct {
    *net.TCPListener
}

TCPKeepAliveListener wraps *net.TCPListener.

func (TCPKeepAliveListener) Accept Uses

func (l TCPKeepAliveListener) Accept() (c net.Conn, err error)

Accept returns a TCP keep-alive enabled connection.

Package netutil imports 7 packages (graph) and is imported by 11 packages. Updated 2019-03-19. Refresh now. Tools for package owners.