dipv4

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHostByName

func GetHostByName(hostname string) (string, error)

GetHostByName 通过hostname解析出对应的ip地址

func GetHostsByName

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

GetHostsByName 通过hostname解析出对应的所有ip地址

func GetIntranetIp

func GetIntranetIp() (ip string, err error)

GetIntranetIp 获取当前计算机上的内网ip

func GetIntranetIpArray

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

GetIntranetIpArray 返回当前计算机上所有内网ip的列表

func GetIpArray

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

GetIpArray 获取当前网卡的ip列表

func GetMac

func GetMac() (mac string, err error)

GetMac 获取所有网卡的mac地址中的第一个

func GetMacArray

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

GetMacArray 获取当前机器上所有网卡的mac地址

func GetNameByAddr

func GetNameByAddr(ipAddress string) (string, error)

GetNameByAddr 通过ip地址,获取dns地址

func GetSegment

func GetSegment(ip string) string

GetSegment 返回传入ip地址的网段 Eg: 192.168.2.102 -> 192.168.2

func Ip2long

func Ip2long(ip string) uint32

Ip2long 把ip地址转换成一个uint32的整数

func IsIntranet

func IsIntranet(ip string) bool

IsIntranet 判断ip地址是否是内网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 把一个uint32的整数转换成一个ip地址

func ParseAddress

func ParseAddress(address string) (string, int)

ParseAddress 把连起来的ip端口转换成分开的ip和端口 Eg: 192.168.1.1:80 -> 192.168.1.1, 80

func Validate

func Validate(ip string) bool

Validate 验证传入的参数是否是合法的ip地址

Types

This section is empty.

Jump to

Keyboard shortcuts

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