gipv4

package
v1.12.1 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2020 License: MIT Imports: 7 Imported by: 7

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 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 IntranetIP

func IntranetIP() (ip string, err error)

IntranetIP returns the first intranet ip of current machine.

func IntranetIPArray added in v1.10.0

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

IntranetIPArray returns the intranet ip list of current machine.

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 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