net

package
v2.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2025 License: MIT Imports: 7 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 分配一个随机端口

func ExternalIP deprecated

func ExternalIP() (string, error)

ExternalIP 获取外网IP地址

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

func ExtractIP

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

ExtractIP 提取主机地址

func ExtractPort

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

ExtractPort 提取主机端口

func FulfillAddr

func FulfillAddr(addr string) string

FulfillAddr 补全地址

func InternalIP deprecated

func InternalIP() (string, error)

InternalIP 获取内网IP地址

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

func ParseAddr

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

ParseAddr 解析地址 注:仅在addr为0.0.0.0:[port]或:[port]时才会根据wan参数自动获取暴露IP

func PrivateIP added in v2.3.1

func PrivateIP() (string, error)

PrivateIP 获取私网IP

func PublicIP added in v2.3.1

func PublicIP() (string, error)

PublicIP 获取公网IP

Types

This section is empty.

Jump to

Keyboard shortcuts

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