public class TunnelDispatcher extends Object implements Service
For each type of tunnel, it creates a chain of handlers, as follows: Following tunnels are created by us: Outbound Gateway > 0 hops: PumpedTunnelGateway BatchedRouterPreprocessor -> OutboundSender -> OutboundReceiver -> OutNetMessagePool Outbound zero-hop Gateway+Endpoint: TunnelGatewayZeroHop OutboundMessageDistributor -> OutNetMessagePool Inbound Endpoint > 0 hops: TunnelParticipant RouterFragmentHandler -> InboundEndpointProcessor -> InboundMessageDistributor -> InNetMessagePool Inbound zero-hop Gateway+Endpoint: TunnelGatewayZeroHop InboundMessageDistributor -> InNetMessagePool Following tunnels are NOT created by us: Participant (not gateway or endpoint) TunnelParticipant HopProcessor -> OutNetMessagePool Outbound Endpoint > 0 hops: OutboundTunnelEndpoint RouterFragmentHandler -> HopProcessor -> OutboundMessageDistributor -> OutNetMessagePool Inbound Gateway > 0 hops: ThrottledPumpedTunnelGateway BatchedRouterPreprocessor -> InboundSender -> InboundGatewayReceiver -> OutNetMessagePool
Modifier and Type | Class and Description |
---|---|
(package private) static class |
TunnelDispatcher.Location
for shouldDropParticipatingMessage()
|
Constructor and Description |
---|
TunnelDispatcher(RouterContext ctx)
Creates a new instance of TunnelDispatcher
|
Modifier and Type | Method and Description |
---|---|
void |
dispatch(TunnelDataMessage msg,
Hash recvFrom)
We are participating in a tunnel (perhaps we're even the endpoint), so
take the message and do what it says.
|
void |
dispatch(TunnelGatewayMessage msg)
We are the inbound tunnel gateway, so encrypt it as necessary and forward
it on.
|
void |
dispatchOutbound(I2NPMessage msg,
TunnelId outboundTunnel,
Hash targetPeer)
We are the outbound tunnel gateway (we created it), so wrap up this message
with instructions to be forwarded to the targetPeer when it reaches the
endpoint.
|
void |
dispatchOutbound(I2NPMessage msg,
TunnelId outboundTunnel,
TunnelId targetTunnel,
Hash targetPeer)
We are the outbound tunnel gateway (we created it), so wrap up this message
with instructions to be forwarded to the targetTunnel on the targetPeer when
it reaches the endpoint.
|
long |
getLastParticipatingExpiration()
what is the date/time on which the last non-locally-created tunnel expires?
|
long |
getNewIBEPID()
Get a new random receive tunnel ID that isn't a dup.
|
long |
getNewIBZeroHopID()
Get a new random receive tunnel ID that isn't a dup.
|
long |
getNewOBGWID()
Get a new random send tunnel ID that isn't a dup.
|
int |
getParticipatingCount() |
static int |
getShareBandwidth(RouterContext ctx) |
boolean |
joinInbound(TunnelCreatorConfig cfg)
We are the inbound endpoint - we created this tunnel
|
boolean |
joinInboundGateway(HopConfig cfg)
We are the inbound gateway in this tunnel, and did not create it
|
boolean |
joinOutbound(TunnelCreatorConfig cfg)
We are the outbound gateway - we created this tunnel
|
boolean |
joinOutboundEndpoint(HopConfig cfg)
We are the outbound endpoint in this tunnel, and did not create it
|
boolean |
joinParticipant(HopConfig cfg)
We are a participant in this tunnel, but not as the endpoint or gateway
|
List<HopConfig> |
listParticipatingTunnels()
Only for console TunnelRenderer.
|
void |
remove(HopConfig cfg)
No longer participate in the tunnel that someone asked us to be a member of
|
void |
remove(TunnelCreatorConfig cfg)
We no longer want to participate in this tunnel that we created
|
void |
renderStatusHTML(Writer out)
Deprecated.
moved to router console
|
void |
restart()
Perform a soft restart.
|
boolean |
shouldDropParticipatingMessage(TunnelDispatcher.Location loc,
int type,
int length)
Implement random early discard (RED) to enforce the share bandwidth limit.
|
void |
shutdown()
Instruct the service that the router is shutting down and that it should do
whatever is necessary to go down gracefully.
|
void |
startup()
startup
|
void |
updateParticipatingStats(int ms)
Generate a current estimate of usage per-participating-tunnel lifetime.
|
public TunnelDispatcher(RouterContext ctx)
public boolean joinOutbound(TunnelCreatorConfig cfg)
public boolean joinInbound(TunnelCreatorConfig cfg)
public boolean joinParticipant(HopConfig cfg)
public boolean joinOutboundEndpoint(HopConfig cfg)
public boolean joinInboundGateway(HopConfig cfg)
public int getParticipatingCount()
public long getNewOBGWID()
public long getNewIBEPID()
public long getNewIBZeroHopID()
public long getLastParticipatingExpiration()
public void remove(TunnelCreatorConfig cfg)
public void remove(HopConfig cfg)
public void dispatch(TunnelDataMessage msg, Hash recvFrom)
public void dispatch(TunnelGatewayMessage msg)
public void dispatchOutbound(I2NPMessage msg, TunnelId outboundTunnel, Hash targetPeer)
msg
- raw message to deliver to the target peeroutboundTunnel
- tunnel to send the message out, or null for directtargetPeer
- peer to receive the messagepublic void dispatchOutbound(I2NPMessage msg, TunnelId outboundTunnel, TunnelId targetTunnel, Hash targetPeer)
msg
- raw message to deliver to the targetTunnel on the targetPeeroutboundTunnel
- tunnel to send the message outtargetTunnel
- tunnel on the targetPeer to deliver the message to, or null for directtargetPeer
- gateway to the tunnel to receive the messagepublic List<HopConfig> listParticipatingTunnels()
public void updateParticipatingStats(int ms)
public boolean shouldDropParticipatingMessage(TunnelDispatcher.Location loc, int type, int length)
loc
- message hop locationtype
- I2NP message typelength
- the length of the messagepublic static int getShareBandwidth(RouterContext ctx)
public void shutdown()
Service
public void restart()
Service
@Deprecated public void renderStatusHTML(Writer out) throws IOException
renderStatusHTML
in interface Service
IOException