netutil

package
v0.12.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2022 License: Apache-2.0 Imports: 9 Imported by: 15

Documentation

Overview

Package netutil contains network-related utility functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DNSTracker added in v0.12.0

func DNSTracker(host string) func() (bool, error)

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

func FullyQualifiedHostname() (string, error)

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

func JoinHostPort(host string, port int32) string

JoinHostPort is an extension to net.JoinHostPort that also formats the integer port.

func NormalizeIP added in v0.12.0

func NormalizeIP(s string) string

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

func ResolveIPv4Addrs(addr string) ([]string, error)

ResolveIPv4Addrs resolves the address:port part into IP address:port pairs

func SortRfc2782

func SortRfc2782(srvs []*net.SRV)

SortRfc2782 reorders SRV records as specified in RFC 2782.

func SplitHostPort

func SplitHostPort(addr string) (string, int, error)

SplitHostPort is an alternative to net.SplitHostPort that also parses the integer port. In addition, it is more tolerant of improperly escaped IPv6 addresses, such as "::1:456", which should actually be "[::1]:456".

Types

type ConnWithTimeouts

type ConnWithTimeouts struct {
	net.Conn
	// contains filtered or unexported fields
}

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.

func (ConnWithTimeouts) Write

func (c ConnWithTimeouts) Write(b []byte) (int, error)

Write sets a write deadline and delegates to conn.Write

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL