xnet

package
v2.6.7 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 4 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssignRandPort

func AssignRandPort(ip ...string) (int, error)

AssignRandPort allocates a free random port, optionally bound to one of the given IP addresses.

func Bytes2IP added in v2.6.7

func Bytes2IP(v [16]byte) string

Bytes2IP converts a 16-byte network-order address into its string representation. IPv4-mapped addresses are rendered as dotted-decimal IPv4.

func ExternalIP

func ExternalIP() (string, error)

ExternalIP returns the external IP address.

func ExtractIP

func ExtractIP(addr net.Addr) (string, error)

ExtractIP extracts the host IP address from addr.

func ExtractPort

func ExtractPort(addr net.Addr) (int, error)

ExtractPort extracts the host port from addr.

func FulfillAddr

func FulfillAddr(addr string) string

FulfillAddr completes addr with the dual-stack wildcard host when the host is missing.

func IP2Bytes added in v2.6.7

func IP2Bytes(ip string) [16]byte

IP2Bytes converts an IP address into its 16-byte network-order representation. IPv4 addresses use the IPv4-mapped IPv6 form, so Bytes2IP can restore the dotted-decimal string. Invalid addresses return the zero value.

func IP2Long added in v2.1.0

func IP2Long(ip string) uint32

IP2Long converts an IPv4 address into its uint32 representation. It returns 0 when ip is not a valid IPv4 address.

func InternalIP

func InternalIP() (string, error)

InternalIP returns the internal (private) IP address.

func Long2IP added in v2.1.0

func Long2IP(v uint32) string

Long2IP converts a uint32 into its dotted-decimal IPv4 address string.

func PrivateIP added in v2.3.0

func PrivateIP() (string, error)

PrivateIP returns the private IP address.

func PublicIP added in v2.3.0

func PublicIP() (string, error)

PublicIP returns the public IP address.

Types

This section is empty.

Jump to

Keyboard shortcuts

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