Documentation ¶
Overview ¶
Package node provides functionalities for handling remote nodes and dispatching connections through them.
Index ¶
- type Dispatcher
- type FallbackDialer
- type GetNodesFunc
- type Node
- func (n *Node) AddTunnel(tunnel *Tunnel)
- func (n *Node) Addr() net.Addr
- func (n *Node) BPort() string
- func (n *Node) Close() error
- func (n *Node) CopyTunnels(into *Node)
- func (n *Node) ID() string
- func (n *Node) IsActive() bool
- func (n *Node) IsLocal() bool
- func (n *Node) PPort() string
- func (n *Node) Ping(ctx context.Context) error
- func (n *Node) ProxyAddr() net.Addr
- func (n *Node) RemoveTunnel(target string, acknoledged bool) error
- func (n *Node) SetIsActive(active bool)
- func (n *Node) Tunnel(target string) (*Tunnel, error)
- func (n *Node) Tunnels() map[string]*Tunnel
- func (n *Node) Workload() int
- type Noder
- type Tunnel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dispatcher ¶ added in v0.3.0
type Dispatcher struct { Noder Fallback FallbackDialer }
Dispatcher implements the DialContext method.
func NewDispatcher ¶ added in v0.3.0
func NewDispatcher(n Noder) *Dispatcher
NewDialer returns a Dialer instance. f is used each time that the list of node is required.
func (*Dispatcher) DialContext ¶ added in v0.3.0
DialContext uses the underlying load balancer to retrieve a possible socks5 proxy address to chain the connection to. If none available, dials the connection using the default net.Dialer.
func (*Dispatcher) GetNodeBalanced ¶ added in v0.3.0
func (d *Dispatcher) GetNodeBalanced(exp ...string) (*Node, error)
GetNodeBalanced collects the workload of its registered nodes, and compares them to the workload of the root node.
Returns an error if no candidate is found, either because none was provided or because no entry's workload was under the treshold.
exp is a list of ids, which are considered as nodes that should not be taken into consideration.
type FallbackDialer ¶
FallbackDialer combines DialContext and Dial methods.
type GetNodesFunc ¶ added in v0.3.0
GetNodesFunc describes a simple node getter function. The first node returned is considered as the local/root one.
type Node ¶
type Node struct { BAddr net.Addr PAddr net.Addr ToBeTraced bool sync.Mutex // contains filtered or unexported fields }
Node represents a remote booster node.
func (*Node) AddTunnel ¶ added in v0.3.0
AddTunnel sets the node's state to active and adds a new tunnel to it. If the node as already a tunnel with this target connected to it, it increments the copies of the tunnel.
func (*Node) BPort ¶ added in v0.3.0
BPort is a convenience method that returns the booster port as string.
func (*Node) CopyTunnels ¶ added in v0.3.0
CopyTunnels takes the tunnels of the receiver and copies them into "into".
func (*Node) PPort ¶ added in v0.3.0
PPort is a convenience method that returns the proxy port as string.
func (*Node) Ping ¶
Ping dials with the node with little timeout. Returns an error if the endpoint is not reachable, nil otherwise. Required by tracer.Pinger.
func (*Node) RemoveTunnel ¶ added in v0.3.0
func (*Node) SetIsActive ¶ added in v0.3.0
SetIsActive sets the state of the node. Safe to be called by multiple goroutines.