java.lang.Object
net.i2p.router.tunnel.pool.ConnectChecker
Direct Known Subclasses:
TunnelPeerSelector

public class ConnectCheckerextends Object
Tools to check transport compatibility.
  • Field Details

    • ctx

      protected final RouterContext ctx
      The router context.
    • log

      protected final Log log
      The logger.
    • NTCP_V4

      private static final int NTCP_V4
      Bit for an NTCP connection to an IPv4 address.
      See Also:
    • NTCP_V6

      private static final int NTCP_V6
      Bit for an NTCP connection to an IPv6 address.
      See Also:
    • SSU_V4

      private static final int SSU_V4
      Bit for an SSU connection to an IPv4 address.
      See Also:
    • SSU_V6

      private static final int SSU_V6
      Bit for an SSU connection to an IPv6 address.
      See Also:
    • SSU2_V4

      private static final int SSU2_V4
      Bit for an SSU2 connection to an IPv4 address.
      See Also:
    • SSU2_V6

      private static final int SSU2_V6
      Bit for an SSU2 connection to an IPv6 address.
      See Also:
    • ANY_V4

      public static final int ANY_V4
      Any IPv4 transport.
      See Also:
    • IHOST

      private static final String[] IHOST
      Prevent object churn.
  • Constructor Details

    • ConnectChecker

      public ConnectChecker(RouterContext context)
      Create a new ConnectChecker.
      Parameters:
      context - the router context
  • Method Details

    • isNTCPDisabled

      protected boolean isNTCPDisabled()
      Is NTCP disabled?
      Returns:
      true if NTCP is disabled
    • isSSUDisabled

      protected boolean isSSUDisabled()
      Is SSU disabled?
      Returns:
      true if SSU is disabled
    • isSSU2Enabled

      private boolean isSSU2Enabled()
      Is SSU2 enabled?
      Returns:
      whether s s u2 enabled
    • canConnect

      public boolean canConnect(Hash from, Hash to)
      Can "from" connect to "to" based on published addresses?

      This is intended for tunnel candidates, where we already have the RI. Will not force RI lookups. Either from or to may be us.

      This is best effort, as we can't know for sure. Published addresses or introducers may have changed. Even if a can't connect to b, they may already be connected as b connected to a.

      Parameters:
      from - the source router hash
      to - the destination router hash
      Returns:
      true if we don't have either RI
    • canConnect

      public boolean canConnect(int ourMask, RouterInfo to)
      Can we connect to "to" based on published addresses?

      This is intended for tunnel candidates, where we already have the RI. Will not force RI lookups.

      This is best effort, as we can't know for sure. Does not check isEstablished(); do that first.

      Parameters:
      ourMask - our connection mask
      to - the destination router info
      Returns:
      true if we can connect
    • canConnect

      public boolean canConnect(RouterInfo from, int ourMask)
      Can "from" connect to us based on published addresses?

      This is intended for tunnel candidates, where we already have the RI. Will not force RI lookups.

      This is best effort, as we can't know for sure. Does not check isEstablished(); do that first.

      Parameters:
      from - the source router info
      ourMask - our connection mask
      Returns:
      true if from can connect to us
    • getInboundMask

      public int getInboundMask(RouterInfo us)
      Our inbound mask. For most cases, we use what we published, i.e. getConnectMask().
      Parameters:
      us - our router info
      Returns:
      bitmask for accepting connections
    • getOutboundMask

      public int getOutboundMask(RouterInfo us)
      Our outbound mask. For most cases, we use our comm system status.
      Parameters:
      us - our router info
      Returns:
      bitmask for initiating connections
    • getConnectMask

      private static int getConnectMask(Collection<RouterAddress> addrs)
      The bitmask of supported transports for the given addresses.
      Parameters:
      addrs - non-empty, set your own default if empty
      Returns:
      bitmask of v4/v6 NTCP/SSU