Documentation ¶
Overview ¶
Package extnet extend network
Index ¶
- Constants
- Variables
- func AdornFlow(wc, rc, tc *atomic.Uint64) func(conn net.Conn) net.Conn
- func AdornGzip(compress bool) func(conn net.Conn) net.Conn
- func AdornGzipLevel(compress bool, level int) func(conn net.Conn) net.Conn
- func AdornIol(opts ...ciol.Options) func(conn net.Conn) net.Conn
- func AdornSnappy(compress bool) func(conn net.Conn) net.Conn
- func AdornZlib(compress bool) func(net.Conn) net.Conn
- func AdornZlibLevel(compress bool, level int) func(net.Conn) net.Conn
- func AdornZlibLevelDict(compress bool, level int, dict []byte) func(net.Conn) net.Conn
- func BaseAdornStcp(method, password string) func(conn net.Conn) net.Conn
- func BaseAdornTLSClient(conf *tls.Config) func(conn net.Conn) net.Conn
- func BaseAdornTLSServer(conf *tls.Config) func(conn net.Conn) net.Conn
- func DialContext(ctx context.Context, d Dialer, network, address string) (net.Conn, 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, afterChains ...AdornConn) (net.Listener, error)
- func ListenWith(network, addr string, base AdornConn, afterChains ...AdornConn) (net.Listener, error)
- func NewListener(inner net.Listener, base AdornConn, afterChains ...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
- 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 AdornGzipLevel ¶ added in v0.0.4
AdornGzipLevel gzip chain with level level see gzip package
func AdornSnappy ¶ added in v0.0.4
AdornSnappy snappy chain
func AdornZlibLevel ¶ added in v0.0.4
AdornZlibLevel zlib chain with the level level see zlib package
func AdornZlibLevelDict ¶ added in v0.0.4
AdornZlibLevelDict zlib chain with the level and dict level see zlib package
func BaseAdornStcp ¶ added in v0.0.6
BaseAdornStcp base adorn encrypt with method and password
func BaseAdornTLSClient ¶ added in v0.0.5
BaseAdornTLSClient base adorn tls client
func BaseAdornTLSServer ¶ added in v0.0.5
BaseAdornTLSServer base adorn tls server
func DialContext ¶ added in v0.0.4
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 IsErrDeadline ¶ added in v0.0.7
IsErrDeadline is error i/o deadline reached
func IsErrRefused ¶ added in v0.0.7
IsErrRefused is error connection refused
func IsErrSocketNotConnected ¶ added in v0.0.7
IsErrSocketNotConnected is error socket is not connected
func IsErrTemporary ¶ added in v0.0.7
IsErrTemporary is net error timeout
func IsErrTimeout ¶ added in v0.0.7
IsErrTimeout is net error timeout
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 ¶ added in v0.1.6
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 ¶ added in v0.0.4
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 ListenWith ¶ added in v0.0.4
func ListenWith(network, addr string, base AdornConn, afterChains ...AdornConn) (net.Listener, error)
ListenWith announces on the local network address , base afterChains
func NewListener ¶ added in v0.0.4
NewListener new listener
func PreviousIP ¶ added in v0.1.2
PreviousIP returns the previous sequential ip.
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 AdornConnsChain ¶ added in v0.0.4
type AdornConnsChain []AdornConn
AdornConnsChain defines a adornConn array. NOTE: 在conn read或write调用过程是在链上从后往前执行的,(类似栈,先进后执行,后进先执行),
所以统计类的应放在链头,也就是AfterChains的第一个,最靠近出口
type Client ¶ added in v0.0.5
type Client struct { Timeout time.Duration // timeout for dial BaseAdorn AdornConn // base adorn conn AfterAdornChains AdornConnsChain // chains after base Forward Dialer // if set it will use forward. }
Client tcp dialer
type ContextDialer ¶ added in v0.0.4
type ContextDialer interface {
DialContext(ctx context.Context, network, address string) (net.Conn, error)
}
ContextDialer A ContextDialer dials using a context.
type IPNet ¶ added in v0.1.2
type IPNet struct { *net.IPNet Number Numeric Mask NumericMask }
IPNet represents a block of network numbers, also known as CIDR.
func (*IPNet) ContainsIPNet ¶ added in v0.1.2
ContainsIPNet returns true if Network covers o, false otherwise
func (*IPNet) ContainsNumeric ¶ added in v0.1.2
ContainsNumeric returns true if Numeric is in range of IPNet, false otherwise.
type Numeric ¶ added in v0.1.2
type Numeric []uint32
Numeric represents an ToIP address using uint32 as internal storage. IPv4 uses 1 uint32 IPv6 uses 4 uint32.
func IP ¶ added in v0.1.2
IP returns a equivalent Numeric to given IP address, return nil if ip is neither IPv4 nor IPv6.
func (Numeric) Bit ¶ added in v0.1.2
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 ¶ added in v0.1.2
func (n Numeric) Mask(m NumericMask) Numeric
Mask returns a new masked Numeric from given Numeric.
type NumericMask ¶ added in v0.1.2
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接口 |