nethelper

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2020 License: Apache-2.0 Imports: 5 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PortForward

func PortForward(
	ctx context.Context,
	dialer *net.Dialer,
	address string,
	protocol string,
	port int32,
	upstream io.Reader,
	packetReadBuf []byte,
) (
	downstream io.ReadCloser,
	closeWrite func(),
	readErrCh <-chan error,
	err error,
)

PortForward network traffic the parameters:

ctx is used to cancel dial operation
dialer is optional for custom network dial options
address is the endpoint address
protocol is the protocol name, e.g. tcp, udp, tcp4
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
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

This section is empty.

Jump to

Keyboard shortcuts

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