forwarder

package
v0.0.0-...-81f0056 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2018 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ConnChannelCap is the capacity of the channel to each connection wrapper
	ConnChannelCap = 20
	// UDPTimeout is how long packets will be sent for after a received packet
	UDPTimeout = 5 * time.Second
)

Variables

View Source
var ClientLogLevel = l.Ignore

ClientLogLevel controls weither client IO errors should be logged

Functions

func Manager

func Manager(log *l.Logger, packets <-chan []byte, add <-chan Conn)

Manager starts new forwarders and cancels them if they stop consuming packets. Returns when the packet channel is closed. forwarders do not merge buffered packets, but TCP-based connections might both merge and split packets.

func TCPServer

func TCPServer(log *l.Logger, serveAddr string, add chan<- Conn)

TCPServer listens for TCP connections and passes the connection to add. Never returns, but any IO error from ResolveTCPAddr(), ListenTCP() or AcceptTCP() is fatal. As TCP is stream-oriented, packets might be split or merged even without delays to send bigger and fewer packets.

func ToHTTP

func ToHTTP(sendTo chan<- Conn, w http.ResponseWriter, _ *http.Request)

ToHTTP sets up the writer for forwarding and passes it to add. Doesn't return until the client disconnects or there is an I/O error. Packets sent through this will be concatenated and split as the ResponseWriter sees fit.

func UDPServer

func UDPServer(log *l.Logger, listenAddr string, add chan<- Conn)

UDPServer listens for UDP packets and starts / stops / times out forwarders Never returns, but any IO error from ResolveUDPAddr(), ListenUDP() or ReadFromUDP() is fatal. Packets will never be merged or split, but if the receivers buffer is too small it might not see everything.

Types

type Conn

type Conn interface {
	io.WriteCloser
}

Conn abstracts away the actual trait from other files

Jump to

Keyboard shortcuts

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