java.lang.Object
net.i2p.router.dummy.DummyTunnelManagerFacade
All Implemented Interfaces:
Service, TunnelManagerFacade

public class DummyTunnelManagerFacadeextends Object implements TunnelManagerFacade
Build and maintain tunnels throughout the network.
  • Constructor Details

    • DummyTunnelManagerFacade

      public DummyTunnelManagerFacade()
      Creates a new DummyTunnelManagerFacade.
  • Method Details

    • selectInboundTunnel

      public TunnelInfo selectInboundTunnel(Hash destination)
      Description copied from interface: TunnelManagerFacade
      Pick a random inbound tunnel from the given destination's pool.
      Specified by:
      selectInboundTunnel in interface TunnelManagerFacade
      Parameters:
      destination - if null, returns inbound exploratory tunnel
      Returns:
      null if none
    • selectOutboundTunnel

      public TunnelInfo selectOutboundTunnel()
      Description copied from interface: TunnelManagerFacade
      Pick a random outbound exploratory tunnel.
      Specified by:
      selectOutboundTunnel in interface TunnelManagerFacade
      Returns:
      null if none
    • selectOutboundTunnel

      public TunnelInfo selectOutboundTunnel(Hash destination)
      Description copied from interface: TunnelManagerFacade
      Pick a random outbound tunnel from the given destination's pool.
      Specified by:
      selectOutboundTunnel in interface TunnelManagerFacade
      Parameters:
      destination - if null, returns outbound exploratory tunnel
      Returns:
      null if none
    • selectInboundExploratoryTunnel

      public TunnelInfo selectInboundExploratoryTunnel(Hash closestTo)
      Description copied from interface: TunnelManagerFacade
      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:
      selectInboundExploratoryTunnel in interface TunnelManagerFacade
      Parameters:
      closestTo - non-null
      Returns:
      null if none
    • selectInboundTunnel

      public TunnelInfo selectInboundTunnel(Hash destination, Hash closestTo)
      Description copied from interface: TunnelManagerFacade
      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:
      selectInboundTunnel in interface TunnelManagerFacade
      Parameters:
      destination - if null, returns inbound exploratory tunnel
      closestTo - non-null
      Returns:
      null if none
    • selectOutboundExploratoryTunnel

      public TunnelInfo selectOutboundExploratoryTunnel(Hash closestTo)
      Description copied from interface: TunnelManagerFacade
      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:
      selectOutboundExploratoryTunnel in interface TunnelManagerFacade
      Parameters:
      closestTo - non-null
      Returns:
      null if none
    • selectOutboundTunnel

      public TunnelInfo selectOutboundTunnel(Hash destination, Hash closestTo)
      Description copied from interface: TunnelManagerFacade
      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:
      selectOutboundTunnel in interface TunnelManagerFacade
      Parameters:
      destination - if null, returns outbound exploratory tunnel
      closestTo - non-null
      Returns:
      null if none
    • selectAnyOutboundTunnel

      public TunnelInfo selectAnyOutboundTunnel()
      Description copied from interface: TunnelManagerFacade
      Pick a random outbound tunnel from any pool — client pools first, then exploratory.
      Specified by:
      selectAnyOutboundTunnel in interface TunnelManagerFacade
      Returns:
      null if none
    • selectAnyInboundTunnel

      public TunnelInfo selectAnyInboundTunnel()
      Description copied from interface: TunnelManagerFacade
      Pick a random inbound tunnel from any pool — client pools first, then exploratory.
      Specified by:
      selectAnyInboundTunnel in interface TunnelManagerFacade
      Returns:
      null if none
    • isValidTunnel

      public boolean isValidTunnel(Hash client, TunnelInfo tunnel)
      Description copied from interface: TunnelManagerFacade
      Is a tunnel a valid member of the pool?
      Specified by:
      isValidTunnel in interface TunnelManagerFacade
      Parameters:
      client - hash of the destination whose pool is checked
      tunnel - candidate, rejected if failed or expired
      Returns:
      true only if unfailed, unexpired and listed in that client's inbound or outbound pool, matching the tunnel's direction
    • getParticipatingCount

      public int getParticipatingCount()
      Description copied from interface: TunnelManagerFacade
      How many tunnels are we participating in?
      Specified by:
      getParticipatingCount in interface TunnelManagerFacade
      Returns:
      number of tunnels where we are a gateway or an endpoint
    • getFreeTunnelCount

      public int getFreeTunnelCount()
      Description copied from interface: TunnelManagerFacade
      How many free inbound tunnels do we have available?
      Specified by:
      getFreeTunnelCount in interface TunnelManagerFacade
      Returns:
      number of valid, unfailed inbound exploratory tunnels
    • getOutboundTunnelCount

      public int getOutboundTunnelCount()
      Description copied from interface: TunnelManagerFacade
      How many outbound tunnels do we have available?
      Specified by:
      getOutboundTunnelCount in interface TunnelManagerFacade
      Returns:
      number of valid, unfailed outbound exploratory tunnels
    • getInboundClientTunnelCount

      public int getInboundClientTunnelCount()
      Description copied from interface: TunnelManagerFacade
      How many free inbound client tunnels do we have available?
      Specified by:
      getInboundClientTunnelCount in interface TunnelManagerFacade
      Returns:
      total over all destinations of GOOD (tested and passed) inbound client tunnels
    • getShareRatio

      public double getShareRatio()
      Description copied from interface: TunnelManagerFacade
      The share ratio of tunnel bandwidth allocated to the network.
      Specified by:
      getShareRatio in interface TunnelManagerFacade
      Returns:
      the share ratio
    • getOutboundClientTunnelCount

      public int getOutboundClientTunnelCount()
      Description copied from interface: TunnelManagerFacade
      How many outbound client tunnels do we have available?
      Specified by:
      getOutboundClientTunnelCount in interface TunnelManagerFacade
      Returns:
      total over all destinations of GOOD (tested and passed) outbound client tunnels
    • getOutboundClientTunnelCount

      public int getOutboundClientTunnelCount(Hash destination)
      Description copied from interface: TunnelManagerFacade
      How many outbound client tunnels in this pool?
      Specified by:
      getOutboundClientTunnelCount in interface TunnelManagerFacade
      Parameters:
      destination - hash of the destination owning the outbound pool
      Returns:
      GOOD tunnel count, or the count including untested tunnels while bootstrapping, or 0 if no pool is registered
    • getInboundClientTunnelCount

      public int getInboundClientTunnelCount(Hash destination)
      Description copied from interface: TunnelManagerFacade
      How many inbound client tunnels in this pool?
      Specified by:
      getInboundClientTunnelCount in interface TunnelManagerFacade
      Parameters:
      destination - hash of the destination owning the inbound pool
      Returns:
      GOOD tunnel count, or the count including untested tunnels while bootstrapping, or 0 if no pool is registered
    • getLastParticipatingExpiration

      public long getLastParticipatingExpiration()
      Description copied from interface: TunnelManagerFacade
      When does the last tunnel we are participating in expire?
      Specified by:
      getLastParticipatingExpiration in interface TunnelManagerFacade
      Returns:
      expiration of the latest-expiring participating tunnel in milliseconds since the epoch, or -1 if we participate in none
    • buildTunnels

      public void buildTunnels(Destination client, ClientTunnelSettings settings)
      Description copied from interface: TunnelManagerFacade
      The client connected (or updated their settings), so make sure we have the tunnels for them, and whenever necessary, ask them to authorize leases.
      Specified by:
      buildTunnels in interface TunnelManagerFacade
      Parameters:
      client - connecting destination, whose hash keys the pools created here
      settings - per-destination inbound and outbound pool settings, which replace those of any pools that already exist
    • removeTunnels

      public void removeTunnels(Destination client)
      Description copied from interface: TunnelManagerFacade
      Must be called AFTER deregistration by the client manager.
      Specified by:
      removeTunnels in interface TunnelManagerFacade
      Parameters:
      client - destination whose pools are scheduled for removal, deferred so its tunnels keep operating until they expire
    • addAlias

      public boolean addAlias(Destination dest, ClientTunnelSettings settings, Destination existingClient)
      Description copied from interface: TunnelManagerFacade
      Add another destination to the same tunnels. Must have same encryption key and a different signing key.
      Specified by:
      addAlias in interface TunnelManagerFacade
      Parameters:
      dest - alias destination, which gets its own pools flagged as aliased
      settings - settings for the alias pools, retained under the primary hash
      existingClient - primary destination whose tunnels are being shared
      Returns:
      true if the alias pools were created, false if the destination already had pools or the primary has none
    • removeAlias

      public void removeAlias(Destination dest)
      Description copied from interface: TunnelManagerFacade
      Remove another destination to the same tunnels.
      Specified by:
      removeAlias in interface TunnelManagerFacade
      Parameters:
      dest - alias destination to drop from the primary's alias set
    • getInboundSettings

      public TunnelPoolSettings getInboundSettings()
      Description copied from interface: TunnelManagerFacade
      The inbound settings for the exploratory pool.
      Specified by:
      getInboundSettings in interface TunnelManagerFacade
      Returns:
      the inbound settings
    • getOutboundSettings

      public TunnelPoolSettings getOutboundSettings()
      Description copied from interface: TunnelManagerFacade
      The outbound settings for the exploratory pool.
      Specified by:
      getOutboundSettings in interface TunnelManagerFacade
      Returns:
      the outbound settings
    • getInboundSettings

      public TunnelPoolSettings getInboundSettings(Hash client)
      Description copied from interface: TunnelManagerFacade
      The inbound settings for the given client.
      Specified by:
      getInboundSettings in interface TunnelManagerFacade
      Parameters:
      client - the client hash
      Returns:
      the inbound settings
    • getOutboundSettings

      public TunnelPoolSettings getOutboundSettings(Hash client)
      Description copied from interface: TunnelManagerFacade
      The outbound settings for the given client.
      Specified by:
      getOutboundSettings in interface TunnelManagerFacade
      Parameters:
      client - the client hash
      Returns:
      the outbound settings
    • setInboundSettings

      public void setInboundSettings(TunnelPoolSettings settings)
      Description copied from interface: TunnelManagerFacade
      The inbound settings for the exploratory pool.
      Specified by:
      setInboundSettings in interface TunnelManagerFacade
      Parameters:
      settings - the inbound settings
    • setOutboundSettings

      public void setOutboundSettings(TunnelPoolSettings settings)
      Description copied from interface: TunnelManagerFacade
      The outbound settings for the exploratory pool.
      Specified by:
      setOutboundSettings in interface TunnelManagerFacade
      Parameters:
      settings - the outbound settings
    • setInboundSettings

      public void setInboundSettings(Hash client, TunnelPoolSettings settings)
      Description copied from interface: TunnelManagerFacade
      The inbound settings for the given client.
      Specified by:
      setInboundSettings in interface TunnelManagerFacade
      Parameters:
      client - the client hash
      settings - the inbound settings
    • setOutboundSettings

      public void setOutboundSettings(Hash client, TunnelPoolSettings settings)
      Description copied from interface: TunnelManagerFacade
      The outbound settings for the given client.
      Specified by:
      setOutboundSettings in interface TunnelManagerFacade
      Parameters:
      client - the client hash
      settings - the outbound settings
    • getInboundBuildQueueSize

      public int getInboundBuildQueueSize()
      Description copied from interface: TunnelManagerFacade
      Count how many inbound tunnel requests we have received but not yet processed.
      Specified by:
      getInboundBuildQueueSize in interface TunnelManagerFacade
      Returns:
      number of inbound build requests waiting in the queue
    • selectPeersInTooManyTunnels

      public Set<Hash> selectPeersInTooManyTunnels()
      Description copied from interface: TunnelManagerFacade
      Peers that should not be allowed to be in another tunnel.
      Specified by:
      selectPeersInTooManyTunnels in interface TunnelManagerFacade
      Returns:
      Set of peers that should not be allowed to be in another tunnel
    • renderStatusHTML

      public void renderStatusHTML(Writer out) throws IOException
      Description copied from interface: Service
      Render the status as HTML.
      Specified by:
      renderStatusHTML in interface Service
      Parameters:
      out - the writer to write to
      Throws:
      IOException - if an error occurs writing
    • restart

      public void restart()
      Description copied from interface: Service
      Perform a soft restart.
      Specified by:
      restart in interface Service
    • shutdown

      public void shutdown()
      Description copied from interface: Service
      Instruct the service that the router is shutting down and that it should do whatever is necessary to go down gracefully. It should not depend on other components at this point. This call DOES block.
      Specified by:
      shutdown in interface Service
    • startup

      public void startup()
      Description copied from interface: Service
      Instruct the service that it should start normal operation. This call DOES block until the service is ready.
      Specified by:
      startup in interface Service
    • listPools

      public void listPools(List<TunnelPool> out)
      Description copied from interface: TunnelManagerFacade
      For TunnelRenderer in router console.
      Specified by:
      listPools in interface TunnelManagerFacade
      Parameters:
      out - list that the client inbound, client outbound and both exploratory pools are appended to
    • getInboundClientPools

      public Map<Hash, TunnelPool> getInboundClientPools()
      Description copied from interface: TunnelManagerFacade
      For TunnelRenderer in router console.
      Specified by:
      getInboundClientPools in interface TunnelManagerFacade
      Returns:
      snapshot of the inbound pools, keyed by destination hash
    • getOutboundClientPools

      public Map<Hash, TunnelPool> getOutboundClientPools()
      Description copied from interface: TunnelManagerFacade
      For TunnelRenderer in router console.
      Specified by:
      getOutboundClientPools in interface TunnelManagerFacade
      Returns:
      snapshot of the outbound pools, keyed by destination hash
    • getInboundExploratoryPool

      public TunnelPool getInboundExploratoryPool()
      Description copied from interface: TunnelManagerFacade
      For TunnelRenderer in router console.
      Specified by:
      getInboundExploratoryPool in interface TunnelManagerFacade
      Returns:
      the shared inbound exploratory pool, never null
    • getOutboundExploratoryPool

      public TunnelPool getOutboundExploratoryPool()
      Description copied from interface: TunnelManagerFacade
      For TunnelRenderer in router console.
      Specified by:
      getOutboundExploratoryPool in interface TunnelManagerFacade
      Returns:
      the shared outbound exploratory pool, never null
    • fail

      public void fail(Hash peer)
      Description copied from interface: TunnelManagerFacade
      Fail every tunnel that depends on a peer we can no longer reach: outbound tunnels with it as first hop, inbound tunnels with it as last hop.
      Specified by:
      fail in interface TunnelManagerFacade
      Parameters:
      peer - hash of the unreachable peer
    • getInboundPool

      public TunnelPool getInboundPool(Hash client)
      Description copied from interface: TunnelManagerFacade
      Inbound tunnel pool for the given client, or null if none.
      Specified by:
      getInboundPool in interface TunnelManagerFacade
      Parameters:
      client - hash of the destination that owns the pool
      Returns:
      pool or null
    • getOutboundPool

      public TunnelPool getOutboundPool(Hash client)
      Description copied from interface: TunnelManagerFacade
      Outbound tunnel pool for the given client, or null if none.
      Specified by:
      getOutboundPool in interface TunnelManagerFacade
      Parameters:
      client - hash of the destination that owns the pool
      Returns:
      pool or null
    • getGhostPeerManager

      public GhostPeerManager getGhostPeerManager()
      Description copied from interface: TunnelManagerFacade
      The ghost peer manager for tracking peers with consistent tunnel build timeouts.
      Specified by:
      getGhostPeerManager in interface TunnelManagerFacade
      Returns:
      the GhostPeerManager instance
    • reportSendFailure

      public void reportSendFailure(TunnelInfo tunnel, int status)
      Description copied from interface: TunnelManagerFacade
      Report a data-phase send failure for a specific tunnel. Called from the I2CP message dispatch path when a message fails through a known tunnel (e.g. expired, local overflow, no tunnels available). Increments the tunnel's failure counter and triggers replacement builds when the threshold is reached, so the pool rotates away from the failing tunnel faster than TestJob alone.
      Specified by:
      reportSendFailure in interface TunnelManagerFacade
      Parameters:
      tunnel - the outbound tunnel that carried the failed message
      status - the I2CP MessageStatusMessage failure code
    • ensurePoolsFor

      public int ensurePoolsFor(Hash client)
      Description copied from interface: TunnelManagerFacade
      Run both of a client's pools' ensure logic on demand instead of waiting for the next build-timer interval. Called from the data phase when a send failed for pool-empty reasons (message expired while queued, no tunnels available). A liveness signal that the pools need rebuilding now. Each pool's internal ensure throttle still applies, so a failure storm cannot become a build storm.

      The pool maps are keyed by the local client (source) destination hash, never the remote destination: passing a remote hash finds no pools and silently does nothing.

      Additive ABI: this method and its int return both postdate 0.9.70+ (no release ever shipped a void variant), so implementations and callers only ever saw this signature; callers may still ignore the returned count.

      Specified by:
      ensurePoolsFor in interface TunnelManagerFacade
      Parameters:
      client - the LOCAL client destination hash whose pools should rebuild
      Returns:
      how many pools were nudged; 0 when none are registered for the client
    • forceTunnelFailure

      public void forceTunnelFailure(TunnelInfo tunnel)
      Description copied from interface: TunnelManagerFacade
      Force a tunnel to fail immediately and trigger a replacement build. Used when rotation is saturated and the pool has no viable alternative tunnels (e.g., all tunnels in the pool match the cached tunnel). This bypasses the incremental failure counter and directly removes the tunnel, ensuring the pool builds a replacement without waiting for multiple failure reports.
      Specified by:
      forceTunnelFailure in interface TunnelManagerFacade
      Parameters:
      tunnel - the outbound tunnel to force-fail