C# Class Brunet.Tunnel.TunnelEdgeListener

Tunnels 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. Tunnels provide a mechanism for forming a complete ring.
Inheritance: EdgeListener, IEdgeSendHandler, IDataHandler, IRpcHandler
Exibir arquivo Open project: johnynek/brunet Class Usage Examples

Protected Properties

Property Type Description
_connections ConnectionList
_iasf IForwarderSelectorFactory
_ito ITunnelOverlap
_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 TunnelEdges.

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
Start ( ) : void
Stop ( ) : void
TunnelEdgeListener ( Node node ) : Brunet
TunnelEdgeListener ( Node node, ITunnelOverlap ito ) : Brunet
TunnelEdgeListener ( Node node, ITunnelOverlap ito, IForwarderSelectorFactory iasf ) : Brunet

Protected Methods

Method Description
AttemptToCreateOverlap ( TunnelEdgeCallbackAction 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 TunnelEdge 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 ( TunnelEdgeCallbackAction teca, List overlap ) : void

Common code to Create an outgoing edge.

CreateEdgeTo ( TunnelEdgeCallbackAction 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 ( TunnelEdgeCallbackAction 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 ( TunnelEdge 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 ( TunnelEdgeCallbackAction teca ) : void
teca TunnelEdgeCallbackAction
return void

CloseHandler() protected method

When a TunnelEdge 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 ( TunnelEdgeCallbackAction teca, List overlap ) : void
teca TunnelEdgeCallbackAction
overlap List
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

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 ( TunnelEdgeCallbackAction teca ) : void
teca TunnelEdgeCallbackAction
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 ( TunnelEdgeCallbackAction teca ) : void
teca TunnelEdgeCallbackAction
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 TunnelEdges.
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

Start() public method

public Start ( ) : void
return void

Stop() public method

public Stop ( ) : void
return void

TunnelEdgeListener() public method

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

TunnelEdgeListener() public method

public TunnelEdgeListener ( Node node, ITunnelOverlap ito ) : Brunet
node Brunet.Node
ito ITunnelOverlap
return Brunet

TunnelEdgeListener() public method

public TunnelEdgeListener ( Node node, ITunnelOverlap ito, IForwarderSelectorFactory iasf ) : Brunet
node Brunet.Node
ito ITunnelOverlap
iasf IForwarderSelectorFactory
return Brunet

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 ( TunnelEdge from, IDictionary msg ) : void
from TunnelEdge
msg IDictionary
return void

Property Details

_connections protected_oe property

protected ConnectionList _connections
return ConnectionList

_iasf protected_oe property

protected IForwarderSelectorFactory _iasf
return IForwarderSelectorFactory

_ito protected_oe property

protected ITunnelOverlap _ito
return ITunnelOverlap

_local_tas protected_oe property

protected IList _local_tas
return IList

_node protected_oe property

protected Node,Brunet _node
return Brunet.Node

_oco protected_oe property

protected OverlapConnectionOverlord,Brunet.Tunnel _oco
return OverlapConnectionOverlord

_oco_trim_timeout protected_oe property

protected int _oco_trim_timeout
return int

_oco_trim_timer protected_oe property

protected FuzzyEvent _oco_trim_timer
return FuzzyEvent

_running protected_oe property

protected int _running
return int

_started protected_oe property

protected int _started
return int