gnet

package
v0.0.0-...-bad6181 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2024 License: GPL-3.0 Imports: 53 Imported by: 0

Documentation

Index

Constants

View Source
const (
	/* public schemes */
	SchemeUnknown = iota
	SchemeHttp
	SchemeHttps
	SchemeFtp
	SchemeFtps
	SchemeMailto
	SchemeFile
	SchemeIdap
	SchemeNews
	SchemeGopher
	SchemeTelnet
	SchemeWais
	SchemeNntp
	SchemeData
	SchemeIrc
	SchemeIrcs
	SchemeWorldwind
	SchemeMms
	SchemeSocks4
	SchemeSocks4a
	SchemeSocks5
	SchemeSocks5s
	SchemeSocksHttp
	SchemeSocksHttps
	/* custom schemes */
	SchemeSvn
	SchemeHg
	SchemeGit
	SchemeThunder
	SchemeTencent
	SchemeEd2k
	SchemeMagnet
	SchemeTwitter
)

Variables

View Source
var (
	// SysDNSResolver uses the system DNS to resolve host names
	SysDNSResolver = NewDNSClient().CleanCustomServers().UseSysDNSIfNoCustom(true)
)

Functions

func Available

func Available() bool

Available returns whether or not SO_REUSEPORT or equivalent behaviour is available in the OS.

func CIDRListAll

func CIDRListAll(cidr string) ([]string, error)

List all ip address contained in this cidr

func CIDRToMask

func CIDRToMask(cidr string) (net.IPMask, error)

Extracts IP mask from CIDR address.

func CidrContainsIP

func CidrContainsIP(cidr, ip string) (bool, error)

func Control

func Control(network, address string, c syscall.RawConn) error

func DecodeURL

func DecodeURL(encodedUrl string) (string, error)

https://video-icn1-1.xx.fbcdn.net/v/t42.9040-2/58467180_2666273813399564_6679224605468524544_n.mp4?_nc_cat=100\u0026efg=eyJybHIiOjY5NCwicmxhIjo1MTIsInZlbmNvZGVfdGFnIjoic3ZlX3NkIn0=\u0026rl=694\u0026vabr=386\u0026_nc_ht=video-icn1-1.xx\u0026oh=881ead117c700970945a89716b3a0b54\u0026oe=5CB9BAA5

func DeleteNetRoute

func DeleteNetRoute(iface string, addr net.IPNet, address string) error

DeleteNetRoute removes `net` type route rule from local operating system FIXME 是否需要sudo?

func Dial

func Dial(network, address string) (net.Conn, error)

Dial multiple protocols.

func DiscoverGateway

func DiscoverGateway() (net.IP, error)

func GetAllLANIPv4CIDRs

func GetAllLANIPv4CIDRs() ([]string, error)

func GetAllNicNames

func GetAllNicNames() ([]string, error)

func GetAllPrivateIPs

func GetAllPrivateIPs() ([]net.IP, error)

GetAllPrivateIPs returns all my local IPs.

func GetOutboundIP

func GetOutboundIP() (net.IP, error)

get preferred outbound ip of this machine it will fail if device is not connected to LAN router

func GetPublicIPOL

func GetPublicIPOL(proxy string) (net.IP, error)

get my wan IPs by 3rd party service

func GetRandomAvailablePort

func GetRandomAvailablePort(nettype string) (int, error)

func GetRoute

func GetRoute(dst net.IP) (iface *net.Interface, gateway net.IP, err error)

GetRoute returns route info of some specified destination IP, like Interface and gateway. On macOS, this function is the functional equivalent of the `route get $DEST-IP` command.

func GlobalEnableBBR

func GlobalEnableBBR() error

func IsAndOnlyDomain

func IsAndOnlyDomain(str string) bool

"http://bing.com/" is domain url, "http://bing.com/search" is not domain url

func IsAudioUrl

func IsAudioUrl(url string) bool

func IsDomain

func IsDomain(domain string) bool

func IsDomainONLINE

func IsDomainONLINE(domain string) bool

func IsFilePath

func IsFilePath(s string) bool

func IsIPPortString

func IsIPPortString(s string) bool

func IsIPString

func IsIPString(s string) bool

func IsImageUrl

func IsImageUrl(url string) bool

func IsLocalInboundPortClear

func IsLocalInboundPortClear(nettype string, port int) (bool, error)

端口是否通畅 如果发起检测端不是你的程序,需要开关端口监听多次才能确定,因为,如果端口可访问,也可能是被映射到别的电脑上而那个电脑的该端口也被监听了

func IsLocalPortUsing

func IsLocalPortUsing(nettype string, port int) (bool, error)

func IsPrivilegedPort

func IsPrivilegedPort(port int) bool

Privileged port needs root

func IsRegistrable

func IsRegistrable(domain string) bool

Principle: WHOIS information of domains which are not taken include "No match".

func IsRemotePortOpen

func IsRemotePortOpen(nettype string, port int) (bool, error)

只能检测端口是否正开启,如果未开启,可能是多种原因,比如主机关机、防火墙、端口未映射、端口没有服务在监听等

func IsUrl

func IsUrl(s string) bool

func IsValidPort

func IsValidPort(port int) bool

func IsVideoUrl

func IsVideoUrl(url string) bool

func Join

func Join(baseUrl string, relUrl string) (absUrl string, err error)

Combine absolute path and relative path to get a new absolute path If relUrl is absolute url, returns this relUrl

func LastPath

func LastPath(urlstr string) string

func ListenAny

func ListenAny(network, addr string) (net.Listener, error)

ListenAny listens any supported protocols.

func ListenCop

func ListenCop(network, addr string) (net.Listener, error)

ListenCop listens multiple connection-oriented protocols.

func LookupIP

func LookupIP(host string) ([]net.IP, error)

func ParseAddr

func ParseAddr(addr net.Addr) (IP net.IP, port int, err error)

func ParseHostAddrOnline

func ParseHostAddrOnline(addr string) (IP net.IP, port int, err error)

"HOSTNAME" / "DOMAIN" / "IP" / ":PORT" / "HOSTNAME:PORT" / "DOMAIN:PORT" / "IP:PORT" -> net.IP, port return port maybe -1, this is NOT an error NOTICE: ResolveIPAddr() & LookupIP() API can't recognize "1127.0.0.1" or "abc127.0.0.1" style illegal IP string, they still returns a IP address and nil error

func ParseProxyAddr

func ParseProxyAddr(address string) (proxyType, host string, err error)

func RemoveDuplicateUrl

func RemoveDuplicateUrl(urls []string) []string

func ResolveAddr

func ResolveAddr(network, address string) (net.Addr, error)

func ReuseDial

func ReuseDial(network, laddr, raddr string) (net.Conn, error)

ReuseDial dials the given network and address. see net.Dial Returns a net.Conn created from a file descriptor for a socket with SO_REUSEPORT and SO_REUSEADDR option set.

func ReuseDialTimeout

func ReuseDialTimeout(network, laddr, raddr string, timeout time.Duration) (net.Conn, error)

ReuseDialTimeout dials the given network and address, with the given timeout. see net.DialTimeout Returns a net.Conn created from a file descriptor for a socket with SO_REUSEPORT and SO_REUSEADDR option set.

func ReuseListen

func ReuseListen(network, address string) (net.Listener, error)

ReuseListen listens at the given network and address. see net.Listen Returns a net.Listener created from a file discriptor for a socket with SO_REUSEPORT and SO_REUSEADDR option set.

func ReuseListenPacket

func ReuseListenPacket(network, address string) (net.PacketConn, error)

ReuseListenPacket listens at the given network and address. see net.ListenPacket Returns a net.Listener created from a file discriptor for a socket with SO_REUSEPORT and SO_REUSEADDR option set.

func SetIPForwarding

func SetIPForwarding() error

SetIPForwarding - Sets IP forwarding if it's mac or linux

func SetSystemDNS

func SetSystemDNS(interfaces, nameServers []string) error

func SudoAddNetRoute

func SudoAddNetRoute(iface string, destIPNet net.IPNet, address string) error

SudoAddNetRoute adds `net` type route rule to local operating system networksetup -setadditionalroutes Ethernet 192.168.1.0 255.255.255.0 10.0.0.2 persistent address: 不知道干嘛用的

Notice: 1、如果程序进程退出,包括意外退出,通常TUN设备会被系统清除,TUN设备相关的路由也会被系统清除。macOS下亲测如此

Types

type AddrParser

type AddrParser struct {
	// contains filtered or unexported fields
}

func NewParser

func NewParser(address_string string) *AddrParser

func (*AddrParser) Scheme

func (ap *AddrParser) Scheme() string

func (*AddrParser) Split

func (ap *AddrParser) Split() (*AddrSlice, error)

func (*AddrParser) Verify

func (ap *AddrParser) Verify() error

type AddrSlice

type AddrSlice struct {
	Scheme string  // like "http", "ftp"
	Domain Domain  // like "google.com"
	Auth   UrlAuth // like "usr:pwd"
	Host   UrlHost // like "google.com:443"
	Path   Path    // like "?article=1260&lang=en#comment"
}

func ParseUrl

func ParseUrl(urlStr string) (*AddrSlice, error)

NOTICE url.Parse("192.168.1.1:80") reports error because RFC3986 says "192.168.1.1:80" is an invalid url, the correct way is "//192.168.1.1:80". In gaddr library and urlx library, "192.168.1.1:80" is a valid url because it is used a lot Reference: https://github.com/golang/go/issues/19297

func (*AddrSlice) String

func (us *AddrSlice) String() string

type Auth

type Auth struct {
	User string
	Pass string
}

type BBRInfo

type BBRInfo struct {
	BW         int64  // Max-filtered BW (app throughput) estimate in bytes/second
	MinRTT     uint32 // Min-filtered RTT in uSec
	PacingGain uint32 // Pacing gain shifted left 8 bits
	CwndGain   uint32 // Cwnd gain shifted left 8 bits
}

BBRInfo implements the struct associated with INET_DIAG_BBRINFO attribute, corresponding with linux struct tcp_bbr_info in uapi/linux/inet_diag.h. from https://github.com/m-lab/tcp-info/blob/9928ad36d2e5f42c17dad065c98cf1346acc2026/inetdiag/structs.go

type CidrRanger

type CidrRanger struct {
	// contains filtered or unexported fields
}

CidrRanger is a fast IP to CIDR lookup.

func NewCidrRanger

func NewCidrRanger() *CidrRanger

func (*CidrRanger) Contains

func (cr *CidrRanger) Contains(ip net.IP) (bool, error)

func (*CidrRanger) Insert

func (cr *CidrRanger) Insert(in net.IPNet) error

type CodecConn

type CodecConn struct {
	// contains filtered or unexported fields
}

CodecConn is a generic stream-oriented network connection that can be compressed and decompressed. It implements net.Conn interface. It is used to compress/decompress network connection stream, for example, when transferring log files or JSON files over the Internet, adding a compression algorithm like snappy can greatly improve the efficiency of data transfer.

func NewCodecConn

func NewCodecConn(conn net.Conn, codec io.ReadWriteCloser) *CodecConn

NewCodecConn create CodecConn with original connection and codec io.ReadWriteCloser. Note: you should implement data compress/decompress at `codecReadWriteCloser`

func (*CodecConn) Close

func (c *CodecConn) Close() error

Close implements net.Conn.

func (*CodecConn) LocalAddr

func (c *CodecConn) LocalAddr() net.Addr

LocalAddr implements net.Conn.

func (*CodecConn) Read

func (c *CodecConn) Read(p []byte) (n int, err error)

Read implements net.Conn.

func (*CodecConn) RemoteAddr

func (c *CodecConn) RemoteAddr() net.Addr

RemoteAddr implements net.Conn.

func (*CodecConn) SetDeadline

func (c *CodecConn) SetDeadline(t time.Time) error

SetDeadline implements net.Conn.

func (*CodecConn) SetReadDeadline

func (c *CodecConn) SetReadDeadline(t time.Time) error

SetReadDeadline implements net.Conn.

func (*CodecConn) SetWriteDeadline

func (c *CodecConn) SetWriteDeadline(t time.Time) error

SetWriteDeadline implements net.Conn.

func (*CodecConn) Write

func (c *CodecConn) Write(p []byte) (n int, err error)

Write implements net.Conn.

type DNSClient

type DNSClient struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewDNSClient

func NewDNSClient() *DNSClient

func (*DNSClient) AddCustomDNSServer

func (dl *DNSClient) AddCustomDNSServer(host string) error

AddCustomDNSServer adds new custom DNS server. host samples: Plain: 8.8.8.8:53 Plain: 8.8.4.4:53 Plain: 1.0.0.1:53 Plain: 1.1.1.1:53 DNS-over-TLS: tls://dns.adguard.com DNS-over-HTTPS: https://8.8.8.8/dns-query DNS-over-HTTPS: https://dns.adguard.com/dns-query DNSCrypt-stamp: sdns://AQIAAAAAAAAAFDE3Ni4xMDMuMTMwLjEzMDo1NDQzINErR_JS3PLCu_iZEIbq95zkSV2LFsigxDIuUso_OQhzIjIuZG5zY3J5cHQuZGVmYXVsdC5uczEuYWRndWFyZC5jb20 DNS-over-QUIC: quic://dns.adguard.com

More public DNS servers: https://github.com/DNSCrypt/dnscrypt-resolvers/blob/master/v3/public-resolvers.md

func (*DNSClient) CleanCustomServers

func (dl *DNSClient) CleanCustomServers() *DNSClient

CleanCustomServers uses the system DNS to resolve host names.

func (*DNSClient) LookupAddr

func (dl *DNSClient) LookupAddr(addr string) (names []string, err error)

LookupAddr looks up host names or domains by ip address from DNS server, if no DNS server is set up locally, then a query request will be sent to the default gateway.

func (*DNSClient) LookupIP

func (dl *DNSClient) LookupIP(host string) ([]net.IP, error)

func (*DNSClient) RemoveCustomDNSServer

func (dl *DNSClient) RemoveCustomDNSServer(host, ip string)

func (*DNSClient) UseSysDNSIfNoCustom

func (dl *DNSClient) UseSysDNSIfNoCustom(use bool) *DNSClient

type DNSResolver

type DNSResolver interface {
	LookupIP(host string) ([]net.IP, error)
	LookupAddr(addr string) (names []string, err error)
}

DNSResolver is used to implement custom name resolution

type DialFunc

type DialFunc = func(network, remoteAddr string) (net.Conn, error)

type DialWithCtxFunc

type DialWithCtxFunc = func(ctx context.Context, network, remoteAddr string) (net.Conn, error)

type Dialer

type Dialer interface {
	Dial(network, remoteAddr string) (net.Conn, error)
}

type DialerWithCtx

type DialerWithCtx interface {
	DialWithCtx(ctx context.Context, network, remoteAddr string) (net.Conn, error)
}

type Domain

type Domain struct {
	TLD        string // "com" | "com.cn"
	SLD_ROOT   string // "baidu"
	TRD_SUB    string // "www"
	SiteDomain string // "baidu.com"
}

func ParseDomain

func ParseDomain(domain string) (*Domain, error)

NOTICE This an offline domain parse function, please update source repo often

func ParseONLINE

func ParseONLINE(domain string) (*Domain, error)

NOTICE 优点: 从权威网站下载TLD列表,判断结果准确 缺点: 初始化或者更新时必须在线工作,下载期间接口响应慢

type GeoFinder

type GeoFinder struct {
	// contains filtered or unexported fields
}

func NewGeoFinderONLINE

func NewGeoFinderONLINE() (*GeoFinder, error)

func (*GeoFinder) Close

func (gf *GeoFinder) Close()

func (*GeoFinder) GetByIP

func (gf *GeoFinder) GetByIP(ip net.IP) (*IpGeo, error)

func (*GeoFinder) GetByIPString

func (gf *GeoFinder) GetByIPString(s string) (*IpGeo, error)

type Host

type Host struct {
	Domain string
	IP     net.IP
}

func (*Host) String

func (h *Host) String() string

type IP

type IP net.IP

IP address.

func ParseIP

func ParseIP(s string) (IP, error)

func WrapIP

func WrapIP(ip net.IP) IP

func (IP) IsAny

func (ip IP) IsAny() bool

func (IP) IsLoopBack

func (ip IP) IsLoopBack() bool

func (IP) IsPrivate

func (ip IP) IsPrivate() bool

func (IP) IsPublic

func (ip IP) IsPublic() bool

func (IP) IsV4

func (ip IP) IsV4() bool

func (IP) IsV6

func (ip IP) IsV6() bool

func (IP) Raw

func (ip IP) Raw() net.IP

func (IP) String

func (ip IP) String() string

func (IP) To4

func (ip IP) To4() IP

To4 converts the IPv4 address ip to a 4-byte representation. IPv4 maybe takes 16-byte buffer, maybe not, that's why we need To4() function. If ip is not an IPv4 address, To4 returns nil.

type IPMask

type IPMask net.IPMask

IPMask only exists in IPv4, there is no netmask in IPv6.

func MustParseIPMask

func MustParseIPMask(s string) IPMask

func ParseIPMask

func ParseIPMask(s string) (IPMask, error)

ParseIPMask casts string like `255.255.255.0` to IPv4 net mask, IPv6 doesn't need net mask. Subnet Mask represents the Network by defining the Leading Bits as 1’s while the Hosts with Trailing Bits as 0’s. 子网掩码必须以1为前导,以0为尾巴,不可以交叉存在 Invalid mask sample: 255.255.253.0(11111111.11111111.11111101.00000000).

func WrapIPMask

func WrapIPMask(ipMask net.IPMask) IPMask

func (IPMask) DecString

func (im IPMask) DecString() string

func (IPMask) Std

func (im IPMask) Std() net.IPMask

func (IPMask) ToSimpleNotation

func (im IPMask) ToSimpleNotation(mask net.IPMask) (uint16, error)

ToSimpleNotation Converts IP mask to 16 bit unsigned integer.

type IPNet

type IPNet net.IPNet

IPNet defines IP network, or IP range. Notice: Valid IPNet samples: 192.168.7.0/24 Invalid IPNet samples: 192.168.7.123/24

func ParseIPNet

func ParseIPNet(s string) (IPNet, error)

ParseIPNet casts string like `192.168.1.3/24` into IPNet.

func WrapIPNet

func WrapIPNet(ipNet net.IPNet) IPNet

func WrapIPNetPtr

func WrapIPNetPtr(ipNet *net.IPNet) *IPNet

func (IPNet) CidrStyleString

func (in IPNet) CidrStyleString() string

CidrStyleString returns CIDR format IPNet. IPNet: `192.168.1.2/24` Return: `192.168.1.2/24`

func (IPNet) Contains

func (in IPNet) Contains(ip net.IP) bool

func (IPNet) IsHostType

func (in IPNet) IsHostType() bool

IsHostType returns if a IPNet is a host ip address. "192.168.3.3/24": true "192.168.3.0/24": false Notice: IPNet ending with `/32` is both a Host type and a Net type.

func (IPNet) IsNetType

func (in IPNet) IsNetType() bool

IsNetType returns if a IPNet is a network. "192.168.3.0/24": true "192.168.3.3/24": false Notice: IPNet ending with `/32` is both a Host type and a Net type.

func (IPNet) ListAll

func (in IPNet) ListAll() []net.IP

ListAll returns all IPs of current IP network. FIXME: IPv6 not supported for now.

func (IPNet) MacStyleString

func (in IPNet) MacStyleString() string

MacStyleString returns mac style network format IPNet. IPNet: `192.168.1.2/24` Return: `192.168.1` FIXME 需要查资料验证结果是否正确

func (IPNet) OnlyKeepNet

func (in IPNet) OnlyKeepNet() IPNet

OnlyKeepNet returns pure network format IPNet, drop single host info. IPNet: `192.168.1.2/24` Return: `192.168.1.0/24` FIXME 需要查资料验证结果是否正确

func (IPNet) Std

func (in IPNet) Std() net.IPNet

func (IPNet) String

func (in IPNet) String() string

StdString returns standard format IPNet. IPNet: `192.168.1.2/24` Return: `192.168.1.2/24`

func (IPNet) Verify

func (in IPNet) Verify() error

Verify checks if IPNet is a valid IP network or not. Valid IPNet samples: 192.168.7.0/24 Invalid IPNet samples: 192.168.7.12/24

type IPPort

type IPPort struct {
	IP   net.IP
	Port int
}

func NewIPPort

func NewIPPort(IP net.IP, port int) IPPort

func ParseIPPort

func ParseIPPort(s string) (*IPPort, error)

func (*IPPort) String

func (t *IPPort) String() string

type Interface

type Interface net.Interface

func Interfaces

func Interfaces() ([]Interface, error)

func WrapIfi

func WrapIfi(ifi net.Interface) Interface

func WrapIfiPtr

func WrapIfiPtr(ifi *net.Interface) *Interface

func (*Interface) GetV4

func (ifi *Interface) GetV4() (IP, *IPNet, error)

GetV4 returns v4 IP address and IP network of current network interface.

func (*Interface) IsBroadcast

func (ifi *Interface) IsBroadcast() bool

func (*Interface) IsLoopBack

func (ifi *Interface) IsLoopBack() bool

func (*Interface) IsMulticast

func (ifi *Interface) IsMulticast() bool

func (*Interface) IsPointToPoint

func (ifi *Interface) IsPointToPoint() bool

func (*Interface) IsUp

func (ifi *Interface) IsUp() bool

func (*Interface) Raw

func (ifi *Interface) Raw() *net.Interface

type IpGeo

type IpGeo struct {
	Country  string
	Region   string
	Province string
	City     string
	CityId   int64
	ISP      string
}

type Listener

type Listener struct {
	// contains filtered or unexported fields
}

type LookupIPRequiredFunc

type LookupIPRequiredFunc = func(host string) bool

type LookupIPWithCtxFunc

type LookupIPWithCtxFunc = func(ctx context.Context, host string) ([]net.IP, error)

type MsgConn

type MsgConn struct {
	net.Conn
	// contains filtered or unexported fields
}

func NewMsgConn

func NewMsgConn(streamConn net.Conn) *MsgConn

func (*MsgConn) Raw

func (mc *MsgConn) Raw() net.Conn

func (*MsgConn) Read

func (mc *MsgConn) Read(b []byte) (int, error)

func (*MsgConn) ReadMsg

func (mc *MsgConn) ReadMsg() ([]byte, error)

func (*MsgConn) Write

func (mc *MsgConn) Write(b []byte) (int, error)

type MultiListener

type MultiListener struct {
	// contains filtered or unexported fields
}

func NewMultiListener

func NewMultiListener() *MultiListener

NewMultiListener creates new MultiListener.

func (*MultiListener) Accept

func (ml *MultiListener) Accept() (network string, addr string, conn net.Conn, err error)

Accept waits for and returns the next connection to the listener.

func (*MultiListener) AddListen

func (ml *MultiListener) AddListen(network, addr string) error

AddListen add new listen address.

func (*MultiListener) Addr

func (ml *MultiListener) Addr() []string

Addr returns all the listener's network address.

func (*MultiListener) Close

func (ml *MultiListener) Close() error

Close closes all the listeners. Any blocked 'Accept' operations will be unblocked and return errors.

func (*MultiListener) CloseOne

func (ml *MultiListener) CloseOne(network, addr string) error

CloseOne closes one listener.

type NicAddr

type NicAddr struct {
	IP      IP
	Netmask net.IPMask
	CIDR    string
}

type NicInfo

type NicInfo struct {
	Name       string
	Desc       string
	MAC        string
	Addrs      []NicAddr
	IsPhysical bool // Is physical network card or virtual network card
	Flags      string
	MTU        int
}

func GetNicInfo

func GetNicInfo(name string) (NicInfo, error)

type Path

type Path struct {
	Str    string
	Dirs   []string
	Params map[string][]string
}

type PopConn

type PopConn struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

PopConn is packet-oriented protocols connection. It implements net.Conn, makes PacketConn used like a net.Conn.

func (*PopConn) Close

func (c *PopConn) Close() error

func (*PopConn) LocalAddr

func (c *PopConn) LocalAddr() net.Addr

func (*PopConn) Read

func (c *PopConn) Read(b []byte) (int, error)

func (*PopConn) RemoteAddr

func (c *PopConn) RemoteAddr() net.Addr

func (*PopConn) SetDeadline

func (c *PopConn) SetDeadline(t time.Time) error

TODO

func (*PopConn) SetReadDeadline

func (c *PopConn) SetReadDeadline(t time.Time) error

func (*PopConn) SetWriteDeadline

func (c *PopConn) SetWriteDeadline(t time.Time) error

TODO

func (*PopConn) Write

func (c *PopConn) Write(b []byte) (n int, err error)

type PopListener

type PopListener struct {
	// contains filtered or unexported fields
}

PopListener is packet-oriented protocols listener. It implements net.Listener, makes PacketConn used like a net.Listener.

func ListenPop

func ListenPop(network, addr string) (*PopListener, error)

func (*PopListener) Accept

func (l *PopListener) Accept() (net.Conn, error)

func (*PopListener) Addr

func (l *PopListener) Addr() net.Addr

func (*PopListener) Close

func (l *PopListener) Close() error

type RouteRule

type RouteRule struct {
	Type    string // net/host/default
	IPVer   int    // 4 or 6
	Dest    string // 目标网段或者主机
	Gateway string // 网关地址,”*” 表示目标是本主机所属的网络,不需要路由
	Flags   string
	Iface   string // 该路由表项对应的输出接口
	Expire  *int
}

func GetRoutes

func GetRoutes() ([]RouteRule, error)

type Scheme

type Scheme int

type Url

type Url struct {
	Proto   string
	Auth    Auth
	Host    Host
	Port    int
	Paths   []string
	Queries map[string]string
}

func NewUrl

func NewUrl() *Url

func (*Url) SetHost

func (u *Url) SetHost(host string) *Url

func (*Url) SetPass

func (u *Url) SetPass(pass string) *Url

func (*Url) SetPath

func (u *Url) SetPath(paths []string) *Url

func (*Url) SetPort

func (u *Url) SetPort(port int) *Url

func (*Url) SetProto

func (u *Url) SetProto(proto string) *Url

func (*Url) SetQueries

func (u *Url) SetQueries(queries map[string]string) *Url

func (*Url) SetUser

func (u *Url) SetUser(user string) *Url

func (*Url) String

func (u *Url) String() string

type UrlAuth

type UrlAuth struct {
	User        string
	Password    string
	PasswordSet bool
}

func (*UrlAuth) String

func (ua *UrlAuth) String() string

type UrlHost

type UrlHost struct {
	Domain string // like "163.com"
	IP     string // like "8.8.8.8"
	Port   int    // like "443"
}

func (*UrlHost) Addr

func (uh *UrlHost) Addr() string

Addr returns IP address or domain, without port.

func (*UrlHost) String

func (uh *UrlHost) String() string

type Whois

type Whois struct {
	// Query and Host are copied from the Request.
	// Query string
	Host string

	// FetchedAt is the date and time the response was fetched from the server.
	FetchedAt time.Time

	// Body contains the raw bytes of the network response (minus HTTP headers).
	//Body []byte
	Body string
}

Cloned from github.com/domainr/whois Whois response represents a whois response from a server.

func GetWhoisWithDomain

func GetWhoisWithDomain(domain string) (*Whois, error)

func GetWhoisWithIP

func GetWhoisWithIP(ip string) (*Whois, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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