extnet

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package extnet extend network

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdornFlow added in v0.0.4

func AdornFlow(Wc *atomic.Uint64, Rc *atomic.Uint64, Tc *atomic.Uint64) func(conn net.Conn) net.Conn

AdornFlow cflow chain

func AdornGzip added in v0.0.4

func AdornGzip(compress bool) func(conn net.Conn) net.Conn

AdornGzip gzip chain

func AdornGzipLevel added in v0.0.4

func AdornGzipLevel(compress bool, level int) func(conn net.Conn) net.Conn

AdornGzipLevel gzip chain with level level see gzip package

func AdornIol added in v0.0.4

func AdornIol(opts ...ciol.Options) func(conn net.Conn) net.Conn

AdornIol ciol chain

func AdornSnappy added in v0.0.4

func AdornSnappy(compress bool) func(conn net.Conn) net.Conn

AdornSnappy snappy chain

func AdornZlib added in v0.0.4

func AdornZlib(compress bool) func(net.Conn) net.Conn

AdornZlib zlib chain

func AdornZlibLevel added in v0.0.4

func AdornZlibLevel(compress bool, level int) func(net.Conn) net.Conn

AdornZlibLevel zlib chain with the level level see zlib package

func AdornZlibLevelDict added in v0.0.4

func AdornZlibLevelDict(compress bool, level int, dict []byte) func(net.Conn) net.Conn

AdornZlibLevelDict zlib chain with the level and dict level see zlib package

func BaseAdornStcp added in v0.0.6

func BaseAdornStcp(method, password string) func(conn net.Conn) net.Conn

BaseAdornStcp base adorn encrypt with method and password

func BaseAdornTLSClient added in v0.0.5

func BaseAdornTLSClient(conf *tls.Config) func(conn net.Conn) net.Conn

BaseAdornTLSClient base adorn tls client

func BaseAdornTLSServer added in v0.0.5

func BaseAdornTLSServer(conf *tls.Config) func(conn net.Conn) net.Conn

BaseAdornTLSServer base adorn tls server

func DialContext added in v0.0.4

func DialContext(ctx context.Context, d Dialer, network, address string) (net.Conn, error)

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 cancelled will be immediately closed.

func IPv4 added in v0.0.4

func IPv4(v uint32) net.IP

IPv4 数值转换为net.IP

func IsDomain

func IsDomain(host string) bool

IsDomain 是否是域名,只检查host或ip,不可带port,否则会误判

func IsIntranet

func IsIntranet(host string) bool

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 JoinHostPort added in v0.0.4

func JoinHostPort(host string, port uint16) string

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 Listen added in v0.0.4

func Listen(network string, addr string, afterChains ...AdornConn) (net.Listener, error)

Listen announces on the local network address and afterChains

func ListenWith added in v0.0.4

func ListenWith(network string, 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

func NewListener(inner net.Listener, base AdornConn, afterChains ...AdornConn) net.Listener

NewListener new listener

func ParseNumeric added in v0.0.4

func ParseNumeric(s string) (uint32, error)

ParseNumeric 点分十进制字符串转换数值

func SplitHostPort

func SplitHostPort(addr string) (string, uint16, error)

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.

func ToNumeric added in v0.0.4

func ToNumeric(p net.IP) (uint32, error)

ToNumeric net.IP转换为数值

Types

type AdornConn added in v0.0.4

type AdornConn func(conn net.Conn) net.Conn

AdornConn defines the conn decorate.

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

func (*Client) Dial added in v0.0.5

func (sf *Client) Dial(network, addr string) (net.Conn, error)

Dial connects to the address on the named network.

func (*Client) DialContext added in v0.0.5

func (sf *Client) DialContext(ctx context.Context, network, addr string) (net.Conn, error)

DialContext connects to the address on the named network using the provided context.

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 Dialer added in v0.0.4

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

Dialer A Dialer is a means to establish a connection.

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接口

Jump to

Keyboard shortcuts

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