ippkg

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

README

ip

IP 字符串、本机 IP 和私网 IPv4 探测辅助。

基础用法

localIP := ippkg.LocalIP()
ok := ippkg.IsValidIP(localIP)
privateIP := ippkg.PrivateIPv4()

注意事项

LocalIP 会缓存首次探测结果;网络不可用时会回退到 127.0.0.1

验证

go test ./ip

Documentation

Index

Constants

View Source
const (

	// DefaultDNSAddress 用于探测本地出口 IP 的 DNS 服务器地址(Google Public DNS)
	DefaultDNSAddress = "8.8.8.8:53"
)

Variables

This section is empty.

Functions

func IsValidIP

func IsValidIP(ip string) bool

IsValidIP 有效的ip

func LocalIP

func LocalIP() string

LocalIP 本地IP

func NetLocalIP

func NetLocalIP() (net.IP, error)

func NewLocalIP

func NewLocalIP() string

NewLocalIP ...

func PrivateIPv4

func PrivateIPv4() net.IP

PrivateIPv4 ...

Types

This section is empty.

Jump to

Keyboard shortcuts

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