Documentation ¶
Overview ¶
Package nethelper wraps various kind of network support with universal api to dial and listen you need to import according packages to enabled certain network supprot
to support
tcp/tcp4/tcp6/unix (with or without tls) udp/udp4/udp6 (without tls) unixpacket/unixgram (with or without tls) import _ "arhat.dev/pkg/nethelper/stdnet"
to support
udp/udp4/udp6 (with tls) import _ "arhat.dev/pkg/nethelper/piondtls"
to support
pipe (with or without tls) import _ "arhat.dev/pkg/nethelper/pipenet"
Index ¶
- Variables
- func Dial(ctx context.Context, dialer interface{}, network, addr string, ...) (net.Conn, error)
- func Forward(ctx context.Context, dialer interface{}, network string, addr string, ...) (downstream io.ReadCloser, closeWrite func(), readErrCh <-chan error, err error)
- func Listen(ctx context.Context, config interface{}, network, addr string, ...) (interface{}, error)
- func Register(network string, supportTLS bool, listen ListenFunc, dial DialFunc)
- type DialFunc
- type ListenFunc
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func Forward ¶ added in v0.4.0
func Forward( ctx context.Context, dialer interface{}, network string, addr string, upstream io.Reader, packetReadBuf []byte, ) ( downstream io.ReadCloser, closeWrite func(), readErrCh <-chan error, err error, )
Forward network traffic the parameters:
ctx is used to cancel dial operation and read error sending dialer is optional for custom network dial options network is the network name, e.g. tcp, udp, tcp4 addr is the endpoint address upstream is the data channel to the endpoint packetReadBuf is the buffer used for udp/ip/unix connection
the return values:
downstream is used to read data sent from the forwarded port and close connection, it actually is a net.Conn and you can cast it to any real type it is, but kept as reader here for better understanding. closeWrite is intended to close write in stream oriented connection readErrCh is used to check read error and whether donwstream reading finished err if not nil the port forward failed
Types ¶
Directories ¶
Path | Synopsis |
---|---|
Package piondtls register udp/udp4/udp6 with dtls support
|
Package piondtls register udp/udp4/udp6 with dtls support |
Package pipenet register pipe with tls support
|
Package pipenet register pipe with tls support |
Package stdnet register tcp/tcp4/tcp6/udp/udp4/udp6/unix network implementation from standard `net` library
|
Package stdnet register tcp/tcp4/tcp6/udp/udp4/udp6/unix network implementation from standard `net` library |
Click to show internal directories.
Click to hide internal directories.