net

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2020 License: Apache-2.0 Imports: 2 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsPrivateAddress added in v1.0.4

func IsPrivateAddress(ip net.IP) bool

IsPrivateAddress returns whether an IP address belongs to the LAN.

func Relay

func Relay(leftConn, rightConn DuplexConn) (int64, int64, error)

Relay copies between left and right bidirectionally. Returns number of bytes copied from right to left, from left to right, and any error occurred. Relay allows for half-closed connections: if one side is done writing, it can still read all remaining data from its peer.

Types

type ConnectionError

type ConnectionError struct {
	// TODO: create status enums and move to metrics.go
	Status  string
	Message string
	Cause   error
}

func NewConnectionError

func NewConnectionError(status, message string, cause error) *ConnectionError

type DuplexConn

type DuplexConn interface {
	net.Conn
	// Closes the Read end of the connection, allowing for the release of resources.
	// No more reads should happen.
	CloseRead() error
	// Closes the Write end of the connection. An EOF or FIN signal may be
	// sent to the connection target.
	CloseWrite() error
}

DuplexConn is a net.Conn that allows for closing only the reader or writer end of it, supporting half-open state.

func WrapConn

func WrapConn(c DuplexConn, r io.Reader, w io.Writer) DuplexConn

WrapDuplexConn wraps an existing DuplexConn with new Reader and Writer, but preserving the original CloseRead() and CloseWrite().

Jump to

Keyboard shortcuts

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