java.lang.Object
net.i2p.client.naming.LookupDest

public class LookupDestextends Object
Connect via I2CP and ask the router to look up the lease of a hash, convert it to a Destination and return it. Obviously this can take a while.

All calls are blocking and return null on failure. Timeout is 15 seconds. To do: Add methods that allow specifying the timeout.

As of 0.8.3, standard I2PSessions support lookups, including multiple lookups in parallel, and overriding the default timeout. Using an existing I2PSession is much more efficient and flexible than using this class.

Public since 0.9.45 only for main(String[]). Not a public API.

  • Field Details

    • DEFAULT_TIMEOUT

      private static final long DEFAULT_TIMEOUT
      Milliseconds a blocking lookup waits when no timeout is given (15 seconds).
      See Also:
  • Constructor Details

    • LookupDest

      protected LookupDest(I2PAppContext context)
      Create a new LookupDest instance.
      Parameters:
      context - the application context, unused by this constructor
  • Method Details

    • lookupBase32Hash

      static Destination lookupBase32Hash(I2PAppContext ctx, String key) throws I2PSessionException
      Look up a destination by Base32 hash.
      Parameters:
      ctx - the application context
      key - 52 chars (do not include the .b32.i2p suffix)
      Returns:
      the destination, or null if not found
      Throws:
      I2PSessionException - if there is an I2CP error
    • lookupHash

      private static Destination lookupHash(I2PAppContext ctx, byte[] h) throws I2PSessionException
      Look up a destination by hash.
      Parameters:
      ctx - the application context
      h - 32 byte hash
      Returns:
      the destination, or null if not found
      Throws:
      I2PSessionException - if there is an I2CP error
    • lookupHostname

      static Destination lookupHostname(I2PAppContext ctx, String hostname) throws I2PSessionException
      Any hostname, but this is for long-format b32.
      Parameters:
      ctx - the context to read the I2CP client options from
      hostname - a "b33" hostname, 64+ chars ending with ".b32.i2p"
      Returns:
      the destination, or null on failure
      Throws:
      I2PSessionException - if the I2CP session cannot be created or connected
    • getOpts

      private static Properties getOpts(I2PAppContext ctx)
      I2CP options from the context.
      Parameters:
      ctx - the application context supplying the I2CP client settings
      Returns:
      a fresh Properties holding the I2CP host, port, SSL, user, and password settings from the context, empty when the context is a router context and has no I2CP client settings to copy
    • main

      public static void main(String[] args)
      Supports hostnames and extended b32.
      Parameters:
      args - command line arguments