netutil

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllIPAddr

func AllIPAddr() string

AllIPAddr returns a catch-all IP address to bind. If the machine supports IP dual stack, "::" is returned. Otherwise "0.0.0.0" is returned.

func IsIPDualStack

func IsIPDualStack() bool

IsIPDualStack returns true if an IPv6 socket is able to send and receive both IPv4 and IPv6 packets.

This function only supports Linux. It always returns false if running other operating systems.

func MaybeDecorateIPv6

func MaybeDecorateIPv6(addr string) string

MaybeDecorateIPv6 adds [ and ] before and after an IPv6 address. If the input string is a IPv4 address or not a valid IP address (e.g. is a domain), the same string is returned.

func ReuseAddrPort added in v1.4.0

func ReuseAddrPort(network, address string, conn syscall.RawConn) error

ReuseAddrPort sets SO_REUSEADDR and SO_REUSEPORT options to a given connection.

Types

type IPVersion added in v1.4.0

type IPVersion int
const (
	IP_VERSION_UNKNOWN IPVersion = iota
	IP_VERSION_4
	IP_VERSION_6
)

func GetIPVersion added in v1.4.0

func GetIPVersion(addr string) IPVersion

GetIPVersion returns the IP version of the given network address.

Jump to

Keyboard shortcuts

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