Documentation ¶
Overview ¶
Package netutil contains network-related utility functions.
Index ¶
- func DNSTracker(host string) func() (bool, error)
- func FullyQualifiedHostname() (string, error)
- func FullyQualifiedHostnameOrPanic() string
- func JoinHostPort(host string, port int32) string
- func NormalizeIP(s string) string
- func ResolveIPv4Addrs(addr string) ([]string, error)
- func SortRfc2782(srvs []*net.SRV)
- func SplitHostPort(addr string) (string, int, error)
- type ConnWithTimeouts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DNSTracker ¶ added in v0.12.0
DNSTracker is a closure that persists state for
tracking changes in the DNS resolution of a target dns name returns true if the DNS name resolution has changed If there is a lookup problem, we pretend nothing has changed
func FullyQualifiedHostname ¶
FullyQualifiedHostname returns the FQDN of the machine.
func FullyQualifiedHostnameOrPanic ¶
func FullyQualifiedHostnameOrPanic() string
FullyQualifiedHostnameOrPanic is the same as FullyQualifiedHostname but panics in case of an error.
func JoinHostPort ¶
JoinHostPort is an extension to net.JoinHostPort that also formats the integer port.
func NormalizeIP ¶ added in v0.12.0
NormalizeIP normalizes loopback addresses to avoid spurious errors when communicating to different representations of the loopback.
Note: this also maps IPv6 localhost to IPv4 localhost, as TabletManagerClient.GetReplicas() (the only place this function is used on) will return only IPv4 addresses.
func ResolveIPv4Addrs ¶
ResolveIPv4Addrs resolves the address:port part into IP address:port pairs
func SortRfc2782 ¶
SortRfc2782 reorders SRV records as specified in RFC 2782.
Types ¶
type ConnWithTimeouts ¶
A ConnWithTimeouts is a wrapper to net.Comm that allows to set a read and write timeouts.
func NewConnWithTimeouts ¶
func NewConnWithTimeouts(conn net.Conn, readTimeout time.Duration, writeTimeout time.Duration) ConnWithTimeouts
NewConnWithTimeouts wraps a net.Conn with read and write deadilnes.
func (ConnWithTimeouts) Read ¶
func (c ConnWithTimeouts) Read(b []byte) (int, error)
Read sets a read deadilne and delegates to conn.Read.
func (ConnWithTimeouts) SetDeadline ¶
func (c ConnWithTimeouts) SetDeadline(t time.Time) error
SetDeadline implements the Conn SetDeadline method.
func (ConnWithTimeouts) SetReadDeadline ¶
func (c ConnWithTimeouts) SetReadDeadline(t time.Time) error
SetReadDeadline implements the Conn SetReadDeadline method.
func (ConnWithTimeouts) SetWriteDeadline ¶
func (c ConnWithTimeouts) SetWriteDeadline(t time.Time) error
SetWriteDeadline implements the Conn SetWriteDeadline method.