gf: github.com/gogf/gf/g/net/gipv4 Index | Files

package gipv4

import "github.com/gogf/gf/g/net/gipv4"

Package gipv4 provides useful API for IPv4 address handling.

Index

Package Files

gipv4.go

func GetHostByName Uses

func GetHostByName(hostname string) (string, error)

Get the IPv4 address corresponding to a given Internet host name.

func GetHostsByName Uses

func GetHostsByName(hostname string) ([]string, error)

Get a list of IPv4 addresses corresponding to a given Internet host name.

func GetNameByAddr Uses

func GetNameByAddr(ipAddress string) (string, error)

Get the Internet host name corresponding to a given IP address.

func GetSegment Uses

func GetSegment(ip string) string

获得ip的网段,例如:192.168.2.102 -> 192.168.2

func IntranetIP Uses

func IntranetIP() (ips []string, err error)

获取本地局域网ip列表

func Ip2long Uses

func Ip2long(ipAddress string) uint32

IP字符串转为整形.

func IsIntranet Uses

func IsIntranet(ipStr string) bool

判断所给ip是否为局域网ip 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

func Long2ip Uses

func Long2ip(properAddress uint32) string

ip整形转为字符串

func ParseAddress Uses

func ParseAddress(addr string) (string, int)

解析地址,形如:192.168.1.1:80 -> 192.168.1.1, 80

func Validate Uses

func Validate(ip string) bool

判断所给地址是否是一个IPv4地址

Package gipv4 imports 7 packages (graph) and is imported by 2 packages. Updated 2019-06-25. Refresh now. Tools for package owners.