gipv4
2 分钟阅读
原文:https://pkg.go.dev/github.com/gogf/gf/v2@v2.6.4/net/gipv4
Package gipv4 provides useful API for IPv4 address handling.
软件包 gipv4 为 IPv4 地址处理提供了有用的 API。
常量
This section is empty.
变量
This section is empty.
函数
func GetHostByName
| |
GetHostByName returns the IPv4 address corresponding to a given Internet host name.
GetHostByName 返回与给定 Internet 主机名对应的 IPv4 地址。
func GetHostsByName
| |
GetHostsByName returns a list of IPv4 addresses corresponding to a given Internet host name.
GetHostsByName 返回与给定 Internet 主机名对应的 IPv4 地址列表。
func GetIntranetIp
| |
GetIntranetIp retrieves and returns the first intranet ip of current machine.
GetIntranetIp 检索并返回当前计算机的第一个 Intranet IP。
func GetIntranetIpArray
| |
GetIntranetIpArray retrieves and returns the intranet ip list of current machine.
GetIntranetIpArray 检索并返回当前计算机的 Intranet IP 列表。
func GetIpArray
| |
GetIpArray retrieves and returns all the ip of current host.
GetIpArray 检索并返回当前主机的所有 ip。
func GetMac
| |
GetMac retrieves and returns the first mac address of current host.
GetMac 检索并返回当前主机的第一个 mac 地址。
func GetMacArray
| |
GetMacArray retrieves and returns all the mac address of current host.
GetMacArray 检索并返回当前主机的所有 MAC 地址。
func GetNameByAddr
| |
GetNameByAddr returns the Internet host name corresponding to a given IP address.
GetNameByAddr 返回与给定 IP 地址对应的 Internet 主机名。
func GetSegment
| |
GetSegment returns the segment of given ip address. Eg: 192.168.2.102 -> 192.168.2
GetSegment 返回给定 IP 地址的段。例如:192.168.2.102 -> 192.168.2
func Ip2long
| |
Ip2long converts ip address to an uint32 integer.
Ip2long 将 ip 地址转换为 uint32 整数。
func IsIntranet
| |
IsIntranet checks and returns whether given ip an intranet ip.
IsIntranet 检查并返回给定的 ip 是否为 Intranet IP。
Local: 127.0.0.1 A: 10.0.0.0–10.255.255.255 B: 172.16.0.0–172.31.255.255 C: 192.168.0.0–192.168.255.255
本地:127.0.0.1 答:10.0.0.0–10.255.255.255 B:172.16.0.0–172.31.255.255 C:192.168.0.0–192.168.255.255
func Long2ip
| |
Long2ip converts an uint32 integer ip address to its string type address.
Long2ip 将 uint32 整数 IP 地址转换为其字符串类型地址。
func MustGetIntranetIp
| |
MustGetIntranetIp performs as GetIntranetIp, but it panics if any error occurs.
MustGetIntranetIp 作为 GetIntranetIp 执行,但如果发生任何错误,它会崩溃。
func ParseAddress
| |
ParseAddress parses address to its ip and port. Eg: 192.168.1.1:80 -> 192.168.1.1, 80
ParseAddress 解析 address 为其 IP 和端口。例如:192.168.1.1:80 -> 192.168.1.1, 80
func Validate
| |
Validate checks whether given ip a valid IPv4 address.
验证检查是否给定 ip 了有效的 IPv4 地址。
类型
This section is empty.