Documentation
¶
Overview ¶
Package proxy implements a proxy object that can take connections from a listener and forward them to a backend through a configurable dialer.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dialer ¶
Dialer represents a function that can dial a backend/destination for forwarding connections.
type Logger ¶
type Logger interface {
Printf(format string, v ...interface{})
}
Logger is used by this package to log messages
type Proxy ¶
type Proxy struct { // Listener to accept connetions on. Listener net.Listener // ConnectTimeout after which connections are terminated. ConnectTimeout time.Duration // Dial function to reach backend to forward connections to. Dial Dialer // Logger is used to log information messages about connections, errors. Logger Logger // contains filtered or unexported fields }
Proxy will take incoming connections from a listener and forward them to a backend through the given dialer.
func (*Proxy) Accept ¶
func (p *Proxy) Accept()
Accept incoming connections and spawn Go routines to handle them and forward the data to the backend. Will stop accepting connections if Shutdown() is called. Run this in a Goroutine, call Wait() to block on proxy shutdown/connection drain.