Documentation ¶
Overview ¶
Package relay is an implementation of relay mechanism. Proxy contains info about hosts which can relaying packets. Relay contains info about hosts of which packets current host have to relay.
Usage:
package relay relay := NewRelay() relay.AddClient(host) if relay.NeedToRelay(host.Address()) { //relay packet } relay.RemoveClient(host) //----------------------------------- proxy := NewProxy() proxy.AddProxyHost(host.Address()) if proxy.ProxyHostsCount > 0 { address := proxy.GetNextProxyAddress //send packet to next proxy } proxy.RemoveProxyHost(host.Address)
Index ¶
Constants ¶
View Source
const ( // Unknown unknown relay state. Unknown = State(iota + 1) // Started is relay type means relaying started. Started // Stopped is relay type means relaying stopped. Stopped // Error is relay type means error state change. Error // NoAuth - this error returns if host tries to send relay request but not authenticated. NoAuth )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Proxy ¶
type Proxy interface { // AddProxyHost add an address to proxy list. AddProxyHost(address string) // RemoveProxyHost removes proxy address from proxy list. RemoveProxyHost(address string) // GetNextProxyAddress returns a next address to send from proxy list. GetNextProxyAddress() string // ProxyHostsCount return added proxy count. ProxyHostsCount() int }
Proxy contains proxy addresses.
type Relay ¶
type Relay interface { // AddClient add client to relay list. AddClient(host *host.Host) error // RemoveClient removes client from relay list. RemoveClient(host *host.Host) error // ClientsCount - clients count. ClientsCount() int // NeedToRelay returns true if origin host is proxy for target host. NeedToRelay(targetAddress string) bool }
Relay Interface for relaying
Click to show internal directories.
Click to hide internal directories.