C# Class Brunet.Relay.RelayEdgeListener

Relays provide the ability for disconnected peers to form via existing overlay connections. For example, two nodes behind asymmetric NATs can form a tunnel over a common peer forming a virtual direct link between each other. Relays provide a mechanism for forming a complete ring.
Inheritance: EdgeListener, IEdgeSendHandler, IDataHandler, IRpcHandler
Show file Open project: pstjuste/brunet Class Usage Examples

Protected Properties

Property Type Description
_connections ConnectionList
_iasf IForwarderSelectorFactory
_ito IRelayOverlap
_local_tas IList
_node Brunet.Node
_oco OverlapConnectionOverlord
_oco_trim_timeout int
_oco_trim_timer FuzzyEvent
_running int
_started int

Private Properties

Property Type Description

Public Methods

Method Description
CreateEdgeTo ( TransportAddress ta, EdgeCreationCallback ecb ) : void

Does not immediately create an edge to a remote node, instead, it tells a timer to wait 5 seconds prior to attempting an edge.

GetNearest ( Brunet.Address addr, ConnectionList cons ) : List

Returns our nearest neighbors to the specified address, which is in turn used to help communicate with tunnel peer.

HandleData ( MemBlock data, ISender return_path, object state ) : void

Where data packets prepended with a tunnel come. Here we receive data as well as create new RelayEdges.

HandleEdgeSend ( Edge from, ICopyable data ) : void

Used to send data over the tunnel via forwarding senders using a randomly selected peer from our overlap list.

HandleRpc ( ISender caller, string method, IList args, object rs ) : void
RelayEdgeListener ( Node node ) : Brunet
RelayEdgeListener ( Node node, IRelayOverlap ito ) : Brunet
RelayEdgeListener ( Node node, IRelayOverlap ito, IForwarderSelectorFactory iasf ) : Brunet
Start ( ) : void
Stop ( ) : void

Protected Methods

Method Description
AttemptToCreateOverlap ( RelayEdgeCallbackAction teca ) : void

First we try to find a third party we can connect with for overlap, if that is successful, we attempt to connect to him, if that is successful, we create a new tunnel edge.

CloseHandler ( object o, EventArgs ea ) : void

When a RelayEdge closes, we must remove it from our hashtable.

ConnectionHandler ( object o, EventArgs ea ) : void

We need to keep track of a current ConnectionList, so we listen to incoming connections. We also use this opportunity to rebuild our LocalTA.

CreateEdge ( RelayEdgeCallbackAction teca, List overlap ) : void

Common code to Create an outgoing edge.

CreateEdgeTo ( RelayEdgeCallbackAction teca ) : void

The delayed callback for CreateEdgeTo, we create an edge if there is a potential non-tunnel overlap and allow the Linker to do the rest.

DisconnectionHandler ( object o, EventArgs ea ) : void

When a disconnection occurs, we must make sure that none of our tunnels use that faulty edge / connection any more.

FailedEdgeCreate ( RelayEdgeCallbackAction teca ) : void

Common code to signify the failure of edge creation.

OcoTrim ( System.DateTime now ) : void

A callback to trim Overlapped Connections. We do this here, since we control Oco and he is essentially headless.

UpdateNeighborIntersection ( Brunet.Relay.RelayEdge from, IDictionary msg ) : void

Whenever the node receives a new StatusMessage from a tunnel, we use this to build a consisting of the intersection of our peers creating a table of potential tunneling options. We close the edge if it is empty.

Method Details

AttemptToCreateOverlap() protected method

First we try to find a third party we can connect with for overlap, if that is successful, we attempt to connect to him, if that is successful, we create a new tunnel edge.
protected AttemptToCreateOverlap ( RelayEdgeCallbackAction teca ) : void
teca RelayEdgeCallbackAction
return void

CloseHandler() protected method

When a RelayEdge closes, we must remove it from our hashtable.
protected CloseHandler ( object o, EventArgs ea ) : void
o object
ea System.EventArgs
return void

ConnectionHandler() protected method

We need to keep track of a current ConnectionList, so we listen to incoming connections. We also use this opportunity to rebuild our LocalTA.
protected ConnectionHandler ( object o, EventArgs ea ) : void
o object
ea System.EventArgs
return void

CreateEdge() protected method

Common code to Create an outgoing edge.
protected CreateEdge ( RelayEdgeCallbackAction teca, List overlap ) : void
teca RelayEdgeCallbackAction
overlap List
return void

CreateEdgeTo() protected method

The delayed callback for CreateEdgeTo, we create an edge if there is a potential non-tunnel overlap and allow the Linker to do the rest.
protected CreateEdgeTo ( RelayEdgeCallbackAction teca ) : void
teca RelayEdgeCallbackAction
return void

CreateEdgeTo() public method

Does not immediately create an edge to a remote node, instead, it tells a timer to wait 5 seconds prior to attempting an edge.
public CreateEdgeTo ( TransportAddress ta, EdgeCreationCallback ecb ) : void
ta TransportAddress
ecb EdgeCreationCallback
return void

DisconnectionHandler() protected method

When a disconnection occurs, we must make sure that none of our tunnels use that faulty edge / connection any more.
protected DisconnectionHandler ( object o, EventArgs ea ) : void
o object
ea System.EventArgs
return void

FailedEdgeCreate() protected method

Common code to signify the failure of edge creation.
protected FailedEdgeCreate ( RelayEdgeCallbackAction teca ) : void
teca RelayEdgeCallbackAction
return void

GetNearest() public static method

Returns our nearest neighbors to the specified address, which is in turn used to help communicate with tunnel peer.
public static GetNearest ( Brunet.Address addr, ConnectionList cons ) : List
addr Brunet.Address
cons ConnectionList
return List

HandleData() public method

Where data packets prepended with a tunnel come. Here we receive data as well as create new RelayEdges.
public HandleData ( MemBlock data, ISender return_path, object state ) : void
data MemBlock
return_path ISender
state object
return void

HandleEdgeSend() public method

Used to send data over the tunnel via forwarding senders using a randomly selected peer from our overlap list.
public HandleEdgeSend ( Edge from, ICopyable data ) : void
from Edge
data ICopyable
return void

HandleRpc() public method

public HandleRpc ( ISender caller, string method, IList args, object rs ) : void
caller ISender
method string
args IList
rs object
return void

OcoTrim() protected method

A callback to trim Overlapped Connections. We do this here, since we control Oco and he is essentially headless.
protected OcoTrim ( System.DateTime now ) : void
now System.DateTime
return void

RelayEdgeListener() public method

public RelayEdgeListener ( Node node ) : Brunet
node Brunet.Node
return Brunet

RelayEdgeListener() public method

public RelayEdgeListener ( Node node, IRelayOverlap ito ) : Brunet
node Brunet.Node
ito IRelayOverlap
return Brunet

RelayEdgeListener() public method

public RelayEdgeListener ( Node node, IRelayOverlap ito, IForwarderSelectorFactory iasf ) : Brunet
node Brunet.Node
ito IRelayOverlap
iasf IForwarderSelectorFactory
return Brunet

Start() public method

public Start ( ) : void
return void

Stop() public method

public Stop ( ) : void
return void

UpdateNeighborIntersection() protected method

Whenever the node receives a new StatusMessage from a tunnel, we use this to build a consisting of the intersection of our peers creating a table of potential tunneling options. We close the edge if it is empty.
protected UpdateNeighborIntersection ( Brunet.Relay.RelayEdge from, IDictionary msg ) : void
from Brunet.Relay.RelayEdge
msg IDictionary
return void

Property Details

_connections protected property

protected ConnectionList _connections
return ConnectionList

_iasf protected property

protected IForwarderSelectorFactory _iasf
return IForwarderSelectorFactory

_ito protected property

protected IRelayOverlap _ito
return IRelayOverlap

_local_tas protected property

protected IList _local_tas
return IList

_node protected property

protected Node,Brunet _node
return Brunet.Node

_oco protected property

protected OverlapConnectionOverlord,Brunet.Relay _oco
return OverlapConnectionOverlord

_oco_trim_timeout protected property

protected int _oco_trim_timeout
return int

_oco_trim_timer protected property

protected FuzzyEvent _oco_trim_timer
return FuzzyEvent

_running protected property

protected int _running
return int

_started protected property

protected int _started
return int