ipv4

package
v0.0.0-...-d86ec20 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertIpToUint32

func ConvertIpToUint32(ip string) uint32

ConvertIpToUint32 converts ip address to an uint32 integer.

func ConvertUint32ToIp

func ConvertUint32ToIp(long uint32) string

ConvertUint32ToIp converts an uint32 integer ip address to its string type address.

func GetHostByName

func GetHostByName(hostname string) (string, error)

GetHostByName returns the IPv4 address corresponding to a given Internet host name.

func GetHostsByName

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

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

func GetIntranetIp

func GetIntranetIp() (ip string, err error)

GetIntranetIp retrieves and returns the first intranet ip of current machine.

func GetIntranetIpArray

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

GetIntranetIpArray retrieves and returns the intranet ip list of current machine.

func GetIpArray

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

GetIpArray retrieves and returns all the ip of current host.

func GetMac

func GetMac() (mac string, err error)

GetMac retrieves and returns the first mac address of current host.

func GetMacArray

func GetMacArray() (macs []string, err error)

GetMacArray retrieves and returns all the mac address of current host.

func GetNameByAddr

func GetNameByAddr(ipAddress string) (string, error)

GetNameByAddr returns the Internet host name corresponding to a given IP address.

func GetSegment

func GetSegment(ip string) string

GetSegment returns the segment of given ip address. Eg: 192.168.2.102 -> 192.168.2

func IsIntranet

func IsIntranet(ip string) bool

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 MustGetIntranetIp

func MustGetIntranetIp() string

MustGetIntranetIp performs as GetIntranetIp, but it panics if any error occurs.

func ParseAddress

func ParseAddress(address string) (string, int)

ParseAddress parses `address` to its ip and port. Eg: 192.168.1.1:80 -> 192.168.1.1, 80

func ValidateIpv4

func ValidateIpv4(ip string) bool

ValidateIpv4 checks whether given `ip` a valid IPv4 address.

Types

This section is empty.

Jump to

Keyboard shortcuts

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