net

package
v2.6.5 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const (
	IPv4Zero     = "0.0.0.0"
	IPv4Loopback = "127.0.0.1"
)

Variables

This section is empty.

Functions

func AssignRandPort

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

AssignRandPort assigns a random port, optionally bound to ip.

func ExternalIP deprecated

func ExternalIP() (string, error)

ExternalIP returns the external IP address.

Deprecated: As of due v2.3.0, this function simply calls net.PublicIP.

func ExtractIP

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

ExtractIP extracts the host from addr.

func ExtractPort

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

ExtractPort extracts the port from addr.

func FulfillAddr

func FulfillAddr(addr string) string

FulfillAddr completes addr with the default host when it is missing.

func InternalIP deprecated

func InternalIP() (string, error)

InternalIP returns the internal IP address.

Deprecated: As of due v2.3.0, this function simply calls net.PublicIP.

func ParseAddr

func ParseAddr(addr string, expose ...bool) (string, string, error)

ParseAddr parses addr into a listen address and an expose address.

The expose IP is only resolved automatically from the expose argument when addr is 0.0.0.0:[port] or :[port].

func ParseHostPort added in v2.6.0

func ParseHostPort(endpoint string) (string, uint64, error)

ParseHostPort parses an endpoint into a host and a port.

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.

func SetPrivateIPResolver added in v2.3.3

func SetPrivateIPResolver(resolver IPResolver)

SetPrivateIPResolver sets the private IP resolver.

func SetPublicIPResolver added in v2.3.3

func SetPublicIPResolver(resolver IPResolver)

SetPublicIPResolver sets the public IP resolver.

Types

type IPResolver added in v2.3.3

type IPResolver func() (string, error)

Jump to

Keyboard shortcuts

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