java.lang.Object
net.i2p.client.naming.LookupDest
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 Summary
FieldsModifier and TypeFieldDescriptionprivate static final longMilliseconds a blocking lookup waits when no timeout is given (15 seconds).Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedLookupDest(I2PAppContext context) Create a new LookupDest instance.Method Summary
Modifier and TypeMethodDescriptionprivate static PropertiesgetOpts(I2PAppContext ctx) I2CP options from the context.(package private) static DestinationlookupBase32Hash(I2PAppContext ctx, String key) Look up a destination by Base32 hash.private static DestinationlookupHash(I2PAppContext ctx, byte[] h) Look up a destination by hash.(package private) static DestinationlookupHostname(I2PAppContext ctx, String hostname) Any hostname, but this is for long-format b32.static voidSupports hostnames and extended b32.
Field Details
DEFAULT_TIMEOUT
private static final long DEFAULT_TIMEOUTMilliseconds a blocking lookup waits when no timeout is given (15 seconds).- See Also:
Constructor Details
LookupDest
Create a new LookupDest instance.- Parameters:
context- the application context, unused by this constructor
Method Details
lookupBase32Hash
Look up a destination by Base32 hash.- Parameters:
ctx- the application contextkey- 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
Look up a destination by hash.- Parameters:
ctx- the application contexth- 32 byte hash- Returns:
- the destination, or null if not found
- Throws:
I2PSessionException- if there is an I2CP error
lookupHostname
Any hostname, but this is for long-format b32.- Parameters:
ctx- the context to read the I2CP client options fromhostname- 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
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
Supports hostnames and extended b32.- Parameters:
args- command line arguments