Documentation ¶
Overview ¶
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 ¶
- Variables
- func CipherSuiteString(suite uint16) string
- func DetectMTU() (int, error)
- func EqualIP(ip net.IP) types.GomegaMatcher
- func HostsFunc(n *net.IPNet) (func() net.IP, error)deprecated
- func IP4ToInt(ip net.IP) uint32deprecated
- func IPAdd(ip net.IP, val int64) net.IP
- func IPDiff(ip1, ip2 net.IP) int64
- func IntToIP4(n uint32) net.IPdeprecated
- func IsConnectionRefused(err error) bool
- func IsNetworkUnreachable(err error) bool
- func IsNoRouteToHost(err error) bool
- func KeepAliveListener(l net.Listener) net.Listener
- func LimitListener(l net.Listener, n int) net.Listener
- func SetKeepAlive(c net.Conn)
- func TLSVersionString(ver uint16) string
- type HalfCloser
- type TCPKeepAliveListener
Constants ¶
This section is empty.
Variables ¶
var ( // ErrIPv6 is an error that a function does not support IPv6. ErrIPv6 = errors.New("only IPv4 address is supported") )
Functions ¶
func CipherSuiteString ¶ added in v1.1.0
CipherSuiteString returns string ID for the given cipher suite defined in crypto/tls.
func DetectMTU ¶ added in v1.4.0
DetectMTU returns the right MTU value for communications to the Internet. This may return zero if it fails to detect MTU.
func EqualIP ¶ added in v1.3.0
func EqualIP(ip net.IP) types.GomegaMatcher
EqualIP is a custom mather of Gomega to assert IP equivalence
func HostsFunc
deprecated
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.
Deprecated: this cannot be used for IPv6 networks.
func IPAdd ¶ added in v1.3.0
IPAdd adds `val` to `ip`. If `ip` is IPv4 address, the value returned is IPv4, or nil when over/underflowed. If `ip` is IPv6 address, the value returned is IPv6, or nil when over/underflowed.
func IPDiff ¶ added in v1.3.0
IPDiff calculates the numeric difference between two IP addresses. Intuitively, the calculation is done as `ip2 - ip1`. `ip1` and `ip2` must be the same IP version (4 or 6).
func IsConnectionRefused ¶ added in v1.0.1
IsConnectionRefused returns true if err indicates ECONNREFUSED errno.
func IsNetworkUnreachable ¶ added in v1.0.1
IsNetworkUnreachable returns true if err indicates ENETUNREACH errno.
func IsNoRouteToHost ¶ added in v1.0.1
IsNoRouteToHost returns true if err indicates EHOSTUNREACH errno.
func KeepAliveListener ¶
KeepAliveListener returns TCPKeepAliveListener if l is a *net.TCPListener. Otherwise, l is returned without change.
func LimitListener ¶
LimitListener is the same as https://godoc.org/golang.org/x/net/netutil#LimitListener
func SetKeepAlive ¶
SetKeepAlive enables TCP keep-alive if c is a *net.TCPConn.
func TLSVersionString ¶ added in v1.1.0
TLSVersionString returns string for the given SSL/TLS version.
Types ¶
type HalfCloser ¶
HalfCloser is an interface for connections that can be half-closed. TCPConn and UNIXConn implement this.
type TCPKeepAliveListener ¶
type TCPKeepAliveListener struct {
*net.TCPListener
}
TCPKeepAliveListener wraps *net.TCPListener.