Documentation ¶
Overview ¶
Package gipv4 provides useful API for IPv4 address handling.
Index ¶
- func GetHostByName(hostname string) (string, error)
- func GetHostsByName(hostname string) ([]string, error)
- func GetIntranetIp() (ip string, err error)
- func GetIntranetIpArray() (ips []string, err error)
- func GetIpArray() (ips []string, err error)
- func GetMac() (mac string, err error)
- func GetMacArray() (macs []string, err error)
- func GetNameByAddr(ipAddress string) (string, error)
- func GetSegment(ip string) string
- func Ip2long(ip string) uint32
- func IsIntranet(ip string) bool
- func Long2ip(long uint32) string
- func MustGetIntranetIp() string
- func ParseAddress(address string) (string, int)
- func Validate(ip string) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetHostByName ¶
GetHostByName returns the IPv4 address corresponding to a given Internet host name.
func GetHostsByName ¶
GetHostsByName returns a list of IPv4 addresses corresponding to a given Internet host name.
func GetIntranetIp ¶
GetIntranetIp retrieves and returns the first intranet ip of current machine.
func GetIntranetIpArray ¶
GetIntranetIpArray retrieves and returns the intranet ip list of current machine.
func GetIpArray ¶
GetIpArray retrieves and returns all the ip of current host.
func GetMac ¶
GetMac retrieves and returns the first mac address of current host.
func GetMacArray ¶
GetMacArray retrieves and returns all the mac address of current host.
func GetNameByAddr ¶
GetNameByAddr returns the Internet host name corresponding to a given IP address.
func GetSegment ¶
GetSegment returns the segment of given ip address. Eg: 192.168.2.102 -> 192.168.2
func IsIntranet ¶
IsIntranet checks and returns whether given ip an 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
func Long2ip ¶
Long2ip converts an uint32 integer ip address to its string type address.
func MustGetIntranetIp ¶
func MustGetIntranetIp() string
MustGetIntranetIp performs as GetIntranetIp, but it panics if any error occurs.
func ParseAddress ¶
ParseAddress parses `address` to its ip and port. Eg: 192.168.1.1:80 -> 192.168.1.1, 80
Types ¶
This section is empty.