Package net.i2p.router.tunnel.pool
Class TunnelPoolManager
java.lang.Object
net.i2p.router.tunnel.pool.TunnelPoolManager
- All Implemented Interfaces:
Service,TunnelManagerFacade
Manage all the exploratory and client tunnel pools.
Run the tunnel builder and handler threads.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddAlias(Destination dest, ClientTunnelSettings settings, Destination existingClient) Add another destination to the same tunnels.(package private) voidqueue a recurring test job if appropriatevoidbuildTunnels(Destination client, ClientTunnelSettings settings) Used only at session startup.voidFail all outbound tunnels with this peer as first hop, and all inbound tunnels with this peer as the last hop, baecause we can't contact it any more.(package private) BuildExecutorinthow many free inbound tunnels do we have available?intcount how many inbound tunnel requests we have received but not yet processedfor TunnelRenderer in router consoleinthow many free inbound client tunnels do we have available?For TunnelRenderer in router consolegetInboundPool(Hash client) exploratorygetInboundSettings(Hash client) longWhen does the last tunnel we are participating in expire?for TunnelRenderer in router consoleinthow many outbound client tunnels do we have available?intgetOutboundClientTunnelCount(Hash destination) Use to verify a tunnel pool is aliveFor TunnelRenderer in router consolegetOutboundPool(Hash client) exploratorygetOutboundSettings(Hash client) inthow many outbound tunnels do we have available?inthow many tunnels are we participating in?doubleDeprecated.unused(package private) booleanbooleanisValidTunnel(Hash client, TunnelInfo tunnel) Is a tunnel a valid member of the pool?voidlistPools(List<TunnelPool> out) list of TunnelPool instances currently in playvoidremoveAlias(Destination dest) Remove a destination for the same tunnels as another.voidremoveTunnels(Destination dest) Must be called AFTER deregistration by the client manager.voidremoveTunnels(Hash destination) This will be called twice, once by the inbound and once by the outbound pool.voidrenderStatusHTML(Writer out) Deprecated.moved to routerconsolevoidrestart()Perform a soft restart.selectInboundExploratoryTunnel(Hash closestTo) Pick the inbound exploratory tunnel with the gateway closest to the given hash.Pick a random inbound exploratory tunnel.selectInboundTunnel(Hash destination) Pick a random inbound tunnel from the given destination's pool.selectInboundTunnel(Hash destination, Hash closestTo) Pick the inbound tunnel with the gateway closest to the given hash from the given destination's pool.selectOutboundExploratoryTunnel(Hash closestTo) Pick the outbound exploratory tunnel with the endpoint closest to the given hash.Pick a random outbound exploratory tunnel.selectOutboundTunnel(Hash destination) Pick a random outbound tunnel from the given destination's pool.selectOutboundTunnel(Hash destination, Hash closestTo) Pick the outbound tunnel with the endpoint closest to the given hash from the given destination's pool.For reliability reasons, don't allow a peer in more than x% of client and exploratory tunnels.voidsetInboundSettings(Hash client, TunnelPoolSettings settings) voidsetInboundSettings(TunnelPoolSettings settings) exploratoryvoidsetOutboundSettings(Hash client, TunnelPoolSettings settings) voidsetOutboundSettings(TunnelPoolSettings settings) exploratoryvoidshutdown()Cannot be restartedvoidstartup()Instruct the service that it should start normal operation.(package private) void
-
Constructor Details
-
TunnelPoolManager
-
-
Method Details
-
selectInboundTunnel
Pick a random inbound exploratory tunnel. Warning - selectInboundExploratoryTunnel(Hash) is preferred.- Specified by:
selectInboundTunnelin interfaceTunnelManagerFacade- Returns:
- null if none
-
selectInboundTunnel
Pick a random inbound tunnel from the given destination's pool. Warning - selectInboundTunnel(Hash, Hash) is preferred.- Specified by:
selectInboundTunnelin interfaceTunnelManagerFacade- Parameters:
destination- if null, returns inbound exploratory tunnel- Returns:
- null if none
-
selectOutboundTunnel
Pick a random outbound exploratory tunnel. Warning - selectOutboundExploratoryTunnel(Hash) is preferred.- Specified by:
selectOutboundTunnelin interfaceTunnelManagerFacade- Returns:
- null if none
-
selectOutboundTunnel
Pick a random outbound tunnel from the given destination's pool. Warning - selectOutboundTunnel(Hash, Hash) is preferred.- Specified by:
selectOutboundTunnelin interfaceTunnelManagerFacade- Parameters:
destination- if null, returns outbound exploratory tunnel- Returns:
- null if none
-
selectInboundExploratoryTunnel
Pick the inbound exploratory tunnel with the gateway closest to the given hash. By using this instead of the random selectTunnel(), we force some locality in OBEP-IBGW connections to minimize those connections network-wide.- Specified by:
selectInboundExploratoryTunnelin interfaceTunnelManagerFacade- Parameters:
closestTo- non-null- Returns:
- null if none
- Since:
- 0.8.10
-
selectInboundTunnel
Pick the inbound tunnel with the gateway closest to the given hash from the given destination's pool. By using this instead of the random selectTunnel(), we force some locality in OBEP-IBGW connections to minimize those connections network-wide.- Specified by:
selectInboundTunnelin interfaceTunnelManagerFacade- Parameters:
destination- if null, returns inbound exploratory tunnelclosestTo- non-null- Returns:
- null if none
- Since:
- 0.8.10
-
selectOutboundExploratoryTunnel
Pick the outbound exploratory tunnel with the endpoint closest to the given hash. By using this instead of the random selectTunnel(), we force some locality in OBEP-IBGW connections to minimize those connections network-wide.- Specified by:
selectOutboundExploratoryTunnelin interfaceTunnelManagerFacade- Parameters:
closestTo- non-null- Returns:
- null if none
- Since:
- 0.8.10
-
selectOutboundTunnel
Pick the outbound tunnel with the endpoint closest to the given hash from the given destination's pool. By using this instead of the random selectTunnel(), we force some locality in OBEP-IBGW connections to minimize those connections network-wide.- Specified by:
selectOutboundTunnelin interfaceTunnelManagerFacade- Parameters:
destination- if null, returns outbound exploratory tunnelclosestTo- non-null- Returns:
- null if none
- Since:
- 0.8.10
-
getTunnelInfo
Deprecated.unusedExpensive (iterates through all tunnels of all pools) and unnecessary.- Specified by:
getTunnelInfoin interfaceTunnelManagerFacade- Parameters:
id- the tunnelId as seen at the gateway
-
getFreeTunnelCount
public int getFreeTunnelCount()Description copied from interface:TunnelManagerFacadehow many free inbound tunnels do we have available?- Specified by:
getFreeTunnelCountin interfaceTunnelManagerFacade- Returns:
- number of inbound exploratory tunnels
-
getOutboundTunnelCount
public int getOutboundTunnelCount()Description copied from interface:TunnelManagerFacadehow many outbound tunnels do we have available?- Specified by:
getOutboundTunnelCountin interfaceTunnelManagerFacade- Returns:
- number of outbound exploratory tunnels
-
getInboundClientTunnelCount
public int getInboundClientTunnelCount()Description copied from interface:TunnelManagerFacadehow many free inbound client tunnels do we have available?- Specified by:
getInboundClientTunnelCountin interfaceTunnelManagerFacade
-
getOutboundClientTunnelCount
public int getOutboundClientTunnelCount()Description copied from interface:TunnelManagerFacadehow many outbound client tunnels do we have available?- Specified by:
getOutboundClientTunnelCountin interfaceTunnelManagerFacade
-
getOutboundClientTunnelCount
Use to verify a tunnel pool is alive- Specified by:
getOutboundClientTunnelCountin interfaceTunnelManagerFacade- Since:
- 0.7.11
-
getParticipatingCount
public int getParticipatingCount()Description copied from interface:TunnelManagerFacadehow many tunnels are we participating in?- Specified by:
getParticipatingCountin interfaceTunnelManagerFacade
-
getLastParticipatingExpiration
public long getLastParticipatingExpiration()Description copied from interface:TunnelManagerFacadeWhen does the last tunnel we are participating in expire?- Specified by:
getLastParticipatingExpirationin interfaceTunnelManagerFacade
-
isValidTunnel
Description copied from interface:TunnelManagerFacadeIs a tunnel a valid member of the pool?- Specified by:
isValidTunnelin interfaceTunnelManagerFacade
-
getInboundSettings
exploratory- Specified by:
getInboundSettingsin interfaceTunnelManagerFacade
-
getOutboundSettings
exploratory- Specified by:
getOutboundSettingsin interfaceTunnelManagerFacade
-
setInboundSettings
exploratory- Specified by:
setInboundSettingsin interfaceTunnelManagerFacade
-
setOutboundSettings
exploratory- Specified by:
setOutboundSettingsin interfaceTunnelManagerFacade
-
getInboundSettings
- Specified by:
getInboundSettingsin interfaceTunnelManagerFacade
-
getOutboundSettings
- Specified by:
getOutboundSettingsin interfaceTunnelManagerFacade
-
setInboundSettings
- Specified by:
setInboundSettingsin interfaceTunnelManagerFacade
-
setOutboundSettings
- Specified by:
setOutboundSettingsin interfaceTunnelManagerFacade
-
restart
public void restart()Description copied from interface:ServicePerform a soft restart. -
buildTunnels
Used only at session startup. Do not use to change settings. Do not use for aliased destinations; use addAlias().- Specified by:
buildTunnelsin interfaceTunnelManagerFacade
-
addAlias
public boolean addAlias(Destination dest, ClientTunnelSettings settings, Destination existingClient) Add another destination to the same tunnels. Must have same encryption key and a different signing key.- Specified by:
addAliasin interfaceTunnelManagerFacade- Returns:
- success
- Throws:
IllegalArgumentException- if not- Since:
- 0.9.21
-
removeAlias
Remove a destination for the same tunnels as another.- Specified by:
removeAliasin interfaceTunnelManagerFacade- Since:
- 0.9.21
-
removeTunnels
Must be called AFTER deregistration by the client manager.- Specified by:
removeTunnelsin interfaceTunnelManagerFacade- Since:
- 0.9.48
-
removeTunnels
This will be called twice, once by the inbound and once by the outbound pool. Synched with buildTunnels() above. Must be called AFTER deregistration by the client manager. -
buildComplete
queue a recurring test job if appropriate -
startup
public void startup()Description copied from interface:ServiceInstruct the service that it should start normal operation. This call DOES block until the service is ready. -
shutdown
public void shutdown()Cannot be restarted -
listPools
list of TunnelPool instances currently in play- Specified by:
listPoolsin interfaceTunnelManagerFacade
-
tunnelFailed
void tunnelFailed() -
getExecutor
BuildExecutor getExecutor() -
isShutdown
boolean isShutdown() -
getInboundBuildQueueSize
public int getInboundBuildQueueSize()Description copied from interface:TunnelManagerFacadecount how many inbound tunnel requests we have received but not yet processed- Specified by:
getInboundBuildQueueSizein interfaceTunnelManagerFacade
-
renderStatusHTML
Deprecated.moved to routerconsole- Specified by:
renderStatusHTMLin interfaceService- Throws:
IOException
-
selectPeersInTooManyTunnels
For reliability reasons, don't allow a peer in more than x% of client and exploratory tunnels. This also will prevent a single huge-capacity (or malicious) peer from taking all the tunnels in the network (although it would be nice to limit the % of total network tunnels to 10% or so, but that appears to be too low to set as a default here... much lower than 33% will push client tunnels out of the fast tier into high cap or beyond...) Possible improvement - restrict based on count per IP, or IP block, to slightly increase costs of collusion- Specified by:
selectPeersInTooManyTunnelsin interfaceTunnelManagerFacade- Returns:
- Set of peers that should not be allowed in another tunnel
-
getInboundClientPools
for TunnelRenderer in router console- Specified by:
getInboundClientPoolsin interfaceTunnelManagerFacade
-
getOutboundClientPools
for TunnelRenderer in router console- Specified by:
getOutboundClientPoolsin interfaceTunnelManagerFacade
-
getInboundExploratoryPool
For TunnelRenderer in router console- Specified by:
getInboundExploratoryPoolin interfaceTunnelManagerFacade- Returns:
- non-null
-
getOutboundExploratoryPool
For TunnelRenderer in router console- Specified by:
getOutboundExploratoryPoolin interfaceTunnelManagerFacade- Returns:
- non-null
-
getInboundPool
- Specified by:
getInboundPoolin interfaceTunnelManagerFacade- Returns:
- pool or null
- Since:
- 0.9.34
-
getOutboundPool
- Specified by:
getOutboundPoolin interfaceTunnelManagerFacade- Returns:
- pool or null
- Since:
- 0.9.34
-
fail
Fail all outbound tunnels with this peer as first hop, and all inbound tunnels with this peer as the last hop, baecause we can't contact it any more. This is most likely to be triggered by an outbound tunnel.- Specified by:
failin interfaceTunnelManagerFacade- Since:
- 0.8.13
-