net

package
v2.5.2 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 7 Imported by: 0

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 v2.3.0, 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 v2.3.0, 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

func PrivateIP() (string, error)

PrivateIP 获取私网IP

func PublicIP

func PublicIP() (string, error)

PublicIP 获取公网IP

func SetPrivateIPResolver

func SetPrivateIPResolver(resolver IPResolver)

SetPrivateIPResolver 设置私网IP解析器

func SetPublicIPResolver

func SetPublicIPResolver(resolver IPResolver)

SetPublicIPResolver 设置公网IP解析器

Types

type IPResolver

type IPResolver func() (string, error)

Jump to

Keyboard shortcuts

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