netutil

package
v0.0.0-...-9c21ab8 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdjustByteSlice

func AdjustByteSlice(src []byte, size int) []byte

调整slice的长度到size,如果不足则右侧补0,超出则截断

func Download

func Download(uri string) ([]byte, error)

func DownloadAsFile

func DownloadAsFile(uri string, filepath string) error

func GetAllIP

func GetAllIP() []net.IP

func GetExternalIP

func GetExternalIP() string

获取公网IP

func GetOutboundIP

func GetOutboundIP() net.IP

func InetAton

func InetAton(ip net.IP) int64

func InetNtoa

func InetNtoa(ipnr int64) net.IP

func IpBetween

func IpBetween(from net.IP, to net.IP, test net.IP) bool

func IsInternetOK

func IsInternetOK() (ok bool)

func IsPublicIP

func IsPublicIP(IP net.IP) bool

func MergeBytes

func MergeBytes(bs [][]byte) []byte

func NetAddr2IPPort

func NetAddr2IPPort(addr net.Addr) (ip string, port int)

Types

type IP

type IP struct {
	Country   string `json:"country"`
	CountryId string `json:"country_id"`
	Area      string `json:"area"`
	AreaId    string `json:"area_id"`
	Region    string `json:"region"`
	RegionId  string `json:"region_id"`
	City      string `json:"city"`
	CityId    string `json:"city_id"`
	Isp       string `json:"isp"`
}

type IPInfo

type IPInfo struct {
	Code int `json:"code"`
	Data IP  `json:"data"`
}

func GetIPInfo

func GetIPInfo(ip string) *IPInfo

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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