java.lang.Object
net.i2p.router.tunnel.pool.TunnelPool
net.i2p.router.tunnel.pool.AliasedTunnelPool

public class AliasedTunnelPoolextends TunnelPool
A tunnel pool with its own settings and Destination, but uses another pool for its tunnels.
  • Field Details

    • _aliasOf

      private final TunnelPool _aliasOf
      The pool this one is a handle on.
  • Constructor Details

    • AliasedTunnelPool

      AliasedTunnelPool(RouterContext ctx, TunnelPoolManager mgr, TunnelPoolSettings settings, TunnelPool aliasOf)
      Create an aliased tunnel pool.
      Parameters:
      ctx - the router context
      mgr - the tunnel pool manager
      settings - the pool settings
      aliasOf - the pool to use for tunnel selection
  • Method Details

    • startup

      void startup()
      Description copied from class: TunnelPool
      Warning, this may be called more than once (without an intervening shutdown()) if the tunnel is stopped and then restarted by the client manager with the same Destination (i.e. for servers or clients w/ persistent key, or restarting close-on-idle clients).
      Overrides:
      startup in class TunnelPool
    • shutdown

      void shutdown()
      Description copied from class: TunnelPool
      Shut down the pool and clean up resources.
      Overrides:
      shutdown in class TunnelPool
    • selectTunnel

      TunnelInfo selectTunnel()
      Description copied from class: TunnelPool
      Pull a random tunnel out of the pool. If there are none available but the pool is configured to allow 0hop tunnels, this builds a fake one and returns it.
      Overrides:
      selectTunnel in class TunnelPool
      Returns:
      null on failure, but it should always build and return a fallback
    • selectTunnel

      TunnelInfo selectTunnel(Hash closestTo)
      Description copied from class: TunnelPool
      Return the tunnel from the pool that is XOR-closest to the target. By using this instead of the random TunnelPool.selectTunnel(), we force some locality in OBEP-IBGW connections to minimize those connections network-wide.

      Does not check for backlogged next peer. Does not return an expired tunnel.

      Overrides:
      selectTunnel in class TunnelPool
      Parameters:
      closestTo - the hash to find the closest tunnel to
      Returns:
      the tunnel closest to the target, or null on failure
    • getTunnel

      public TunnelInfo getTunnel(TunnelId gatewayId)
      Description copied from class: TunnelPool
      Tunnel by its gateway tunnel ID.
      Overrides:
      getTunnel in class TunnelPool
      Parameters:
      gatewayId - for inbound, the GW rcv tunnel ID; for outbound, the GW send tunnel ID.
      Returns:
      the tunnel with the matching gateway ID, or null if not found
    • listTunnels

      public List<TunnelInfo> listTunnels()
      Description copied from class: TunnelPool
      List of tunnels currently in the pool.
      Overrides:
      listTunnels in class TunnelPool
      Returns:
      a copy of the list of TunnelInfo objects
    • needFallback

      boolean needFallback()
      Description copied from class: TunnelPool
      Do we really need more fallbacks? Used to prevent a zillion of them. Does not check config, only call if config allows zero hop.
      Overrides:
      needFallback in class TunnelPool
      Returns:
      true if more fallback tunnels are needed
    • listPending

      public List<PooledTunnelCreatorConfig> listPending()
      Description copied from class: TunnelPool
      List of tunnelInfo instances of tunnels currently being built.
      Overrides:
      listPending in class TunnelPool
      Returns:
      the list of tunnels currently being built
    • isAlive

      public boolean isAlive()
      Description copied from class: TunnelPool
      Is this pool running AND either exploratory, or tracked by the client manager? A pool will be alive but not tracked after the client manager removes it but before all the tunnels have expired.
      Overrides:
      isAlive in class TunnelPool
      Returns:
      true if the pool is alive and should be tracked
    • size

      public int size()
      Description copied from class: TunnelPool
      Count every tunnel in the pool, including failed and expired ones awaiting cleanup.
      Overrides:
      size in class TunnelPool
      Returns:
      the number of tunnels in the pool
    • addTunnel

      protected void addTunnel(TunnelInfo info)
      Description copied from class: TunnelPool
      Add a tunnel to the pool.
      Overrides:
      addTunnel in class TunnelPool
      Parameters:
      info - the tunnel to add
    • removeTunnel

      void removeTunnel(TunnelInfo info)
      Description copied from class: TunnelPool
      Remove a tunnel from the pool.
      Overrides:
      removeTunnel in class TunnelPool
      Parameters:
      info - the tunnel to remove
    • tunnelFailed

      void tunnelFailed(TunnelInfo cfg)
      Description copied from class: TunnelPool
      Remove tunnel and blame all peers (not necessarily equally). This may be called multiple times from TestJob. Enhanced with intelligent failure analysis and recovery.
      Overrides:
      tunnelFailed in class TunnelPool
      Parameters:
      cfg - the tunnel that failed
    • tunnelFailed

      void tunnelFailed(TunnelInfo cfg, Hash blamePeer)
      Description copied from class: TunnelPool
      Remove the tunnel and blame only one peer. This may be called multiple times. Data-phase first-hop send failures also feed the selection cooldown and the tier-demotion strike tracker so a persistently failing first hop is not re-selected on the next tunnel generation.
      Overrides:
      tunnelFailed in class TunnelPool
      Parameters:
      cfg - the tunnel that failed
      blamePeer - the peer to blame
    • refreshLeaseSet

      void refreshLeaseSet()
      Description copied from class: TunnelPool
      No-op for outbound and exploratory pools.
      Overrides:
      refreshLeaseSet in class TunnelPool
    • refreshLeaseSet

      public void refreshLeaseSet(boolean force)
      Description copied from class: TunnelPool
      Refresh the LeaseSet, throttled to prevent flooding but not on initial creation. Public so the netdb facade can nudge local-dest refresh on accessLeaseSet.
      Overrides:
      refreshLeaseSet in class TunnelPool
      Parameters:
      force - if true, bypass throttle (for critical refresh when below minimum or near expiry)
    • buildFallback

      boolean buildFallback()
      Description copied from class: TunnelPool
      This will build a fallback (zero-hop) tunnel ONLY if this pool is exploratory, or the settings allow it. Matches upstream: client pools with zero-hop disabled must never fall back to 0-hop, since such a tunnel would be selected for data and would fail every connection through it.
      Overrides:
      buildFallback in class TunnelPool
      Returns:
      true if a fallback tunnel is built, false otherwise
    • locked_buildNewLeaseSet

      protected LeaseSet locked_buildNewLeaseSet()
      Description copied from class: TunnelPool
      Build a leaseSet with the required tunnels that aren't about to expire. Caller must hold _tunnelsLock. The returned LeaseSet will be incomplete; it will not have the destination set and will not be signed. Only the leases will be included.
      Overrides:
      locked_buildNewLeaseSet in class TunnelPool
      Returns:
      null on failure
    • getLifetimeProcessed

      public long getLifetimeProcessed()
      Description copied from class: TunnelPool
      Total lifetime processed bytes for this pool.
      Overrides:
      getLifetimeProcessed in class TunnelPool
      Returns:
      the total number of bytes processed through this pool
    • configureNewTunnel

      PooledTunnelCreatorConfig configureNewTunnel()
      Description copied from class: TunnelPool
      This only sets the peers and creation/expiration times in the configuration. For the crypto, see BuildRequestor and BuildMessageGenerator.
      Overrides:
      configureNewTunnel in class TunnelPool
      Returns:
      null on failure
    • ensureSufficientTunnels

      void ensureSufficientTunnels()
      Aliased pools have no tunnels of their own; the primary pool builds and maintains tunnels for all aliases. Running the full build-decision logic on the empty local pool would log false "EMERGENCY: Zero usable tunnels" warnings and waste cycles on every maintenance pass.
      Overrides:
      ensureSufficientTunnels in class TunnelPool
    • buildComplete

      void buildComplete(PooledTunnelCreatorConfig cfg, BuildExecutor.Result result)
      Description copied from class: TunnelPool
      Remove from the _inprogress list and call addTunnel() if result is SUCCESS. Updates consecutive build timeout count.
      Overrides:
      buildComplete in class TunnelPool
      Parameters:
      cfg - the completed tunnel configuration
      result - the build result
    • toString

      public String toString()
      Description copied from class: TunnelPool
      Description of the pool and its settings.
      Overrides:
      toString in class TunnelPool