net2

package
v0.3.17 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NameServer = "ns1.google.com:53"

NameServer the name server to use for this lib

Functions

func Dial

func Dial(addr string, timeout time.Duration) error

Dial dial 指定的端口,失败返回错误

func Get

func Get() (port int, err error)

Get a free port.

func GetClientIP

func GetClientIP(r *http.Request) (ip string)

GetClientIP 获取用户ip

func GetDefaultInterfaceName

func GetDefaultInterfaceName() string

func GetIPs

func GetIPs() (ips []string)

GetIPs ...

func GetInterfaceIP

func GetInterfaceIP() (string, error)

GetInterfaceIP get the ip of your interface, useful when you want to get your ip inside a private network, such as wifi network.

func GetIp138

func GetIp138(ip string) string

爬虫 ip138 获取 ip 地理信息 ~~~~~~ 暂时废弃,采用 IPIP

func GetLocalIP

func GetLocalIP() (string, error)

GetLocalIP ...

func GetLocalIP1

func GetLocalIP1() (ip string)

GetLocalIP 获取内网ip

func GetLocalIp

func GetLocalIp() string

func GetLocalMainIP

func GetLocalMainIP() (string, int, error)

GetLocalIP ...

func GetMacAddrs

func GetMacAddrs() (macAddrs []string)

GetMacAddrs ...

func GetOutboundIP

func GetOutboundIP() string

Get preferred outbound ip of this machine

func GetPublicIP

func GetPublicIP() (string, error)

GetPublicIP get the ip that is public to global.

func GetValidAddressCount

func GetValidAddressCount(cidr string) int

func GetWwwIP

func GetWwwIP() (exip string)

GetWwwIP 获取公网IP地址

func IPv4

func IPv4() (net.IP, error)

func InternalIp

func InternalIp() string

func Intersect

func Intersect(n1, n2 *net.IPNet) bool

func IpAddress

func IpAddress() string

func LocalIP

func LocalIP() (string, error)

LocalIP gets the first NIC's IP address.

func LocalListener

func LocalListener() net.Listener

LocalListener 随机一个本地端口,返回listener

func LocalMac

func LocalMac() (string, error)

LocalMac gets the first NIC's MAC address.

func Lower16BitIP

func Lower16BitIP() (uint16, error)

func Ping

func Ping(host string, port int) error

Ping 调用http://ip:port/health 接口, 失败返回错误

func ToCommonString

func ToCommonString(ip string, prefix uint32) string

func Upper16BitIP

func Upper16BitIP() (uint16, error)

Types

type URL

type URL struct {
	Scheme     string
	Opaque     string        // encoded opaque data
	User       *url.Userinfo // username and password information
	Host       string        // host or host:port
	Path       string        // path (relative paths may omit leading slash)
	RawPath    string        // encoded path hint (see EscapedPath method)
	ForceQuery bool          // append a query ('?') even if RawQuery is empty
	RawQuery   string        // encoded query values, without '?'
	Fragment   string        // fragment for references, without '#'
	HostName   string
	Port       string
	// contains filtered or unexported fields
}

URL wrap url.URL.

func ParseURL

func ParseURL(raw string) (*URL, error)

ParseURL parses raw into URL.

func (*URL) Password

func (u *URL) Password() (string, bool)

Password gets password from URL.

func (*URL) Query

func (u *URL) Query() url.Values

Query parses RawQuery and returns the corresponding values. It silently discards malformed value pairs. To check errors use ParseQuery.

func (*URL) QueryBool

func (u *URL) QueryBool(field string, expect bool) (ret bool)

QueryBool returns provided field's value in bool if value is empty, expect returns

func (*URL) QueryDuration

func (u *URL) QueryDuration(field string, expect time.Duration) (ret time.Duration)

QueryDuration returns provided field's value in duration type. if value is empty, expect returns

func (*URL) QueryInt

func (u *URL) QueryInt(field string, expect int) (ret int)

QueryInt returns provided field's value in int type. if value is empty, expect returns

func (*URL) QueryInt64

func (u *URL) QueryInt64(field string, expect int64) (ret int64)

QueryInt64 returns provided field's value in int64 type. if value is empty, expect returns

func (*URL) QueryString

func (u *URL) QueryString(field string, expect string) (ret string)

QueryString returns provided field's value in string type. if value is empty, expect returns

func (*URL) Username

func (u *URL) Username() string

Username gets username from URL.

Jump to

Keyboard shortcuts

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