gipv4

package
v2.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2024 License: MIT Imports: 7 Imported by: 33

Documentation

Overview

Package gipv4 provides useful API for IPv4 address handling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 Ip2long

func Ip2long(ip string) uint32

Ip2long converts ip address to an uint32 integer.

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 Long2ip

func Long2ip(long uint32) string

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

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 Validate

func Validate(ip string) bool

Validate 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