Documentation
¶
Index ¶
- Variables
- func HandleHTTP(relay *Relay) http.HandlerFunc
- type Logger
- type Metrics
- type ProxyType
- type Relay
- func (r *Relay) Close() error
- func (r *Relay) DisableProxy(remoteIndex ...int)
- func (r *Relay) ListenServe() error
- func (r *Relay) Running() bool
- func (r *Relay) Serve(l net.Listener) error
- func (r *Relay) SetClient(client *http.Client)
- func (r *Relay) SetFailOverTCP()
- func (r *Relay) SetHTTP(server http.Server) error
- func (r *Relay) SetProxy(dialer ...*proxy.Dialer)
- func (r *Relay) SetTLS(certificateFile, keyFile string)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnknownProxyType is returned when a relay has a proxy type which is invalid ErrUnknownProxyType = errors.New("unknown proxytype used in creation of relay") // ErrAddrNotMatch is returned when a server object has a addr which is not nil // and does not equal the relay's address ErrAddrNotMatch = errors.New("addr does not match the relays host address") )
var (
ErrFailConnect = errors.New("failed to dial remote")
)
Functions ¶
func HandleHTTP ¶
func HandleHTTP(relay *Relay) http.HandlerFunc
HandleHTTP is to be used as the HTTP relay's handler set in the http.Server object
Types ¶
type Logger ¶
Logger is used for logging debug information such as connections being created, dropped etc
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics stores information such as bandwidth usage conn stats etc
func (*Metrics) Connections ¶
Connections returns the amount of active and total connections
func (*Metrics) DialerAvg ¶
DialerAvg returns the 10 point average dial time this average includes failed dials
type ProxyType ¶
type ProxyType uint8
ProxyType represents what type of proxy the relay is.
Raw TCP is used for just forwarding the raw connection to the remote address.
const ( // ProxyTCP is for raw TCP forwarding ProxyTCP ProxyType = iota // ProxyHTTP creates a HTTP server and forwards the traffic to // either a HTTP or HTTPs server ProxyHTTP // ProxyHTTPS is the same as HTTP but listens on TLS ProxyHTTPS // ProxyFailOverTCP acts like the TCP proxy however if it cannot connect // it will use a failover address instead. ProxyFailOverTCP // VERSION uses semantic versioning VERSION = "v1.0.0" )
type Relay ¶
type Relay struct { // Name is a generic name which can be assigned to this relay Name string // Host is the address to listen on Host string // ForwardAddr is the destination to send the connection. // When using a relay type which accept multipule destinations // use a comma seperated list. ForwardAddr string // ProxyType is used to forward or manipulate the connection ProxyType ProxyType // Metrics is used to store information such as upload/download // and other statistics *Metrics // contains filtered or unexported fields }
Relay represents a reverse proxy and all of its settings
func (*Relay) DisableProxy ¶ added in v1.0.0
DisableProxy will disable the proxy settings when connecting to the remote at the index provided.
OPTION ONLY AVALIABLE FOR FAIL OVER TCP PROXY TYPE!
func (*Relay) ListenServe ¶
ListenServe will start a listener and handle the incoming requests
func (*Relay) SetFailOverTCP ¶ added in v1.0.0
func (r *Relay) SetFailOverTCP()
SetFailOverTCP will make the relay type TCP and support multipule destinations. If one destination fails to dial the next will be attempted.
func (*Relay) SetHTTP ¶
SetHTTP is used to set the relay as a type HTTP relay addr will auto be set in the server object if left blank