node

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2018 License: AGPL-3.0 Imports: 10 Imported by: 2

Documentation

Overview

Package node provides functionalities for handling remote nodes and dispatching connections through them.

Index

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

func (d *Dispatcher) DialContext(ctx context.Context, network, addr string) (net.Conn, error)

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

type FallbackDialer interface {
	socks5.Dialer
	proxy.Dialer
}

FallbackDialer combines DialContext and Dial methods.

type GetNodesFunc added in v0.3.0

type GetNodesFunc func() (*Node, []*Node)

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 New added in v0.3.0

func New(host, pport, bport string, isLocal bool) (*Node, error)

New creates a new node instance.

func (*Node) AddTunnel added in v0.3.0

func (n *Node) AddTunnel(tunnel *Tunnel)

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) Addr

func (n *Node) Addr() net.Addr

func (*Node) BPort added in v0.3.0

func (n *Node) BPort() string

BPort is a convenience method that returns the booster port as string.

func (*Node) Close

func (n *Node) Close() error

func (*Node) CopyTunnels added in v0.3.0

func (n *Node) CopyTunnels(into *Node)

CopyTunnels takes the tunnels of the receiver and copies them into "into".

func (*Node) ID

func (n *Node) ID() string

ID returns the node's sha1 identifier.

func (*Node) IsActive

func (n *Node) IsActive() bool

IsActive returns true if the node is updating it's status.

func (*Node) IsLocal added in v0.3.0

func (n *Node) IsLocal() bool

IsLocal returns true if the node is a local node.

func (*Node) PPort added in v0.3.0

func (n *Node) PPort() string

PPort is a convenience method that returns the proxy port as string.

func (*Node) Ping

func (n *Node) Ping(ctx context.Context) error

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) ProxyAddr added in v0.3.0

func (n *Node) ProxyAddr() net.Addr

ProxyAddr returns the proxy address of the node.

func (*Node) RemoveTunnel added in v0.3.0

func (n *Node) RemoveTunnel(target string, acknoledged bool) error

func (*Node) SetIsActive added in v0.3.0

func (n *Node) SetIsActive(active bool)

SetIsActive sets the state of the node. Safe to be called by multiple goroutines.

func (*Node) Tunnel added in v0.3.0

func (n *Node) Tunnel(target string) (*Tunnel, error)

func (*Node) Tunnels added in v0.3.0

func (n *Node) Tunnels() map[string]*Tunnel

func (*Node) Workload added in v0.3.0

func (n *Node) Workload() int

Workload is the number of tunnels that the node is managing. Contains also unacknoledged ones.

type Noder added in v0.3.0

type Noder interface {
	Nodes() (*Node, []*Node)
}

type Tunnel added in v0.3.0

type Tunnel struct {
	Target string

	sync.Mutex
	// contains filtered or unexported fields
}

func NewTunnel added in v0.3.0

func NewTunnel(target string) *Tunnel

func (*Tunnel) Copies added in v0.3.0

func (t *Tunnel) Copies() int

func (*Tunnel) Copy added in v0.4.0

func (t *Tunnel) Copy() *Tunnel

func (*Tunnel) ID added in v0.3.0

func (t *Tunnel) ID() string

Jump to

Keyboard shortcuts

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