Documentation ¶
Overview ¶
Package extnet extend network
Index ¶
- Constants
- Variables
- func DialContext(ctx context.Context, d Dialer, network, address string) (net.Conn, error)
- func GetFreePort() (int, error)
- func GetFreePorts(count int) ([]int, error)
- func IsDomain(host string) bool
- func IsErrClosed(err error) bool
- func IsErrDeadline(err error) bool
- func IsErrRefused(err error) bool
- func IsErrSocketNotConnected(err error) bool
- func IsErrTemporary(err error) bool
- func IsErrTimeout(err error) bool
- func IsIntranet(host string) bool
- func IsIntranetIP(ip net.IP) bool
- func JoinHostPort(host string, port uint16) string
- func Listen(network, addr string, chains ...AdornConn) (net.Listener, error)
- func MustGetFreePort() int
- func NewListener(inner net.Listener, chains ...AdornConn) net.Listener
- func NextIP(ip net.IP) net.IP
- func PreviousIP(ip net.IP) net.IP
- func SplitHostPort(addr string) (string, uint16, error)
- func ToIP(v uint32) net.IP
- type AdornConn
- func AdornFlow(wc, rc, tc *atomic.Uint64) AdornConn
- func AdornGzip(compress bool) AdornConn
- func AdornGzipLevel(compress bool, level int) AdornConn
- func AdornIol(opts ...ciol.Options) AdornConn
- func AdornSnappy(compress bool) AdornConn
- func AdornZlib(compress bool) AdornConn
- func AdornZlibLevel(compress bool, level int) AdornConn
- func AdornZlibLevelDict(compress bool, level int, dict []byte) AdornConn
- func BaseAdornStcp(method, password string) AdornConn
- func BaseAdornTLSClient(conf *tls.Config) AdornConn
- func BaseAdornTLSServer(conf *tls.Config) AdornConn
- type AdornConnsChain
- type Client
- type ContextDialer
- type Dialer
- type IPNet
- type Numeric
- func (n Numeric) Bit(position uint) (bool, error)
- func (n Numeric) Equal(n1 Numeric) bool
- func (n Numeric) Mask(m NumericMask) Numeric
- func (n Numeric) Next() Numeric
- func (n Numeric) Previous() Numeric
- func (n Numeric) String() string
- func (n Numeric) To16() Numeric
- func (n Numeric) To4() Numeric
- func (n Numeric) ToIP() net.IP
- type NumericMask
Constants ¶
const ( IPv4Uint32Cnt = 1 IPv6Uint32Cnt = 4 )
IP uint32 count const defined
Variables ¶
var ErrInvalidBitPosition = fmt.Errorf("bit position not valid")
ErrInvalidBitPosition is returned when bits requested is not valid.
Functions ¶
func DialContext ¶
DialContext dial context with dialer WARNING: this can leak a goroutine for as long as the underlying Dialer implementation takes to timeout A Conn returned from a successful Dial after the context has been canceled will be immediately closed.
func GetFreePort ¶
GetFreePort asks the kernel for a free open port that is ready to use.
func GetFreePorts ¶
GetFreePorts asks the kernel for free open ports that are ready to use.
func IsErrSocketNotConnected ¶
IsErrSocketNotConnected is error socket is not connected
func IsIntranet ¶
IsIntranet is intranet network,if host is domain,it will looks up host using the local resolver. net.LookupIP may cause deadlock in windows see https://github.com/golang/go/issues/24178 局域网IP段:
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 IsIntranetIP ¶
IsIntranetIP is intranet network or not. 局域网IP段:
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 JoinHostPort ¶
JoinHostPort combines host and port into a network address of the form "host:port". If host contains a colon, as found in literal IPv6 addresses, then JoinHostPort returns "[host]:port".
See func Dial for a description of the host and port parameters.
func MustGetFreePort ¶
func MustGetFreePort() int
MustGetFreePort calls GetFreePort and panics on error
func NewListener ¶
NewListener new listener
func SplitHostPort ¶
SplitHostPort splits a network address of the form "host:port", "host%zone:port", "[host]:port" or "[host%zone]:port" into host or host%zone and port.
A literal IPv6 address in hostport must be enclosed in square brackets, as in "[::1]:80", "[::1%lo0]:80".
See func Dial for a description of the hostport parameter, and host and port results.
Types ¶
type AdornConn ¶
AdornConn defines the conn decorate.
func AdornGzipLevel ¶
AdornGzipLevel gzip chain with level level see gzip package
func AdornZlibLevel ¶
AdornZlibLevel zlib chain with the level level see zlib package
func AdornZlibLevelDict ¶
AdornZlibLevelDict zlib chain with the level and dict level see zlib package
func BaseAdornStcp ¶
BaseAdornStcp base adorn encrypt with method and password
func BaseAdornTLSClient ¶
BaseAdornTLSClient base adorn tls client
func BaseAdornTLSServer ¶
BaseAdornTLSServer base adorn tls server
type AdornConnsChain ¶
type AdornConnsChain []AdornConn
AdornConnsChain defines a adornConn array. NOTE: 在conn read或write调用过程是在链上从后往前执行的,(类似洋葱,包在最外面的选执行),
所以基础链,统计链的应放在链头,也就是chains的第一个,最靠近出口
type Client ¶
type Client struct { Timeout time.Duration // timeout for dial AdornChains AdornConnsChain // adorn chains Forward Dialer // if set it will use forward. }
Client tcp dialer
type ContextDialer ¶
type ContextDialer interface {
DialContext(ctx context.Context, network, address string) (net.Conn, error)
}
ContextDialer A ContextDialer dials using a context.
type IPNet ¶
type IPNet struct { *net.IPNet Number Numeric Mask NumericMask }
IPNet represents a block of network numbers, also known as CIDR.
func (*IPNet) ContainsIPNet ¶
ContainsIPNet returns true if Network covers o, false otherwise
func (*IPNet) ContainsNumeric ¶
ContainsNumeric returns true if Numeric is in range of IPNet, false otherwise.
type Numeric ¶
type Numeric []uint32
Numeric represents an ToIP address using uint32 as internal storage. IPv4 uses 1 uint32 IPv6 uses 4 uint32.
func IP ¶
IP returns a equivalent Numeric to given IP address, return nil if ip is neither IPv4 nor IPv6.
func (Numeric) Bit ¶
Bit returns uint32 representing the bit value at given position, e.g., "128.0.0.0" has bit value of 1 at position 31, and 0 for positions 30 to 0.
func (Numeric) Mask ¶
func (n Numeric) Mask(m NumericMask) Numeric
Mask returns a new masked Numeric from given Numeric.
type NumericMask ¶
type NumericMask []uint32
NumericMask represents an IP address using uint32 as internal storage. IPv4 uses 1 uint32, while IPv6 uses 4 uint32.
Directories ¶
Path | Synopsis |
---|---|
connection
|
|
cbuffered
Package cbuffered 实现读缓冲的net.conn接口
|
Package cbuffered 实现读缓冲的net.conn接口 |
ccrypt
Package ccrypt 实现net.conn的加密conn接口 aes cfb加密码的连接,通过提供的配置使用pbkdf2生成key, 依靠key和hash生成iv
|
Package ccrypt 实现net.conn的加密conn接口 aes cfb加密码的连接,通过提供的配置使用pbkdf2生成key, 依靠key和hash生成iv |
cencrypt
Package cencrypt 实现加密的net.conn接口
|
Package cencrypt 实现加密的net.conn接口 |
cflow
Package cflow 实现字节统计,读,写,读写统计,以字节为准.
|
Package cflow 实现字节统计,读,写,读写统计,以字节为准. |
cgzip
Package cgzip 采用gzip压缩实现的net.conn接口
|
Package cgzip 采用gzip压缩实现的net.conn接口 |
ciol
Package ciol 实现 net.conn 网络io限速器接口
|
Package ciol 实现 net.conn 网络io限速器接口 |
csnappy
Package csnappy 采用snappy压缩实现的net.conn接口
|
Package csnappy 采用snappy压缩实现的net.conn接口 |
czlib
Package czlib 采用zlib压缩实现的net.conn接口
|
Package czlib 采用zlib压缩实现的net.conn接口 |