java.lang.Object
net.i2p.client.naming.NamingService
net.i2p.client.naming.DummyNamingService
net.i2p.client.naming.EepGetNamingService
A network-based naming service using HTTP, with in-memory caching. Fetches from one or more remote (in-i2p) CGI services using HTTP GET.
The remote HTTP service takes a CGI parameter and must return (only) the 516-byte Base64 destination, or hostname=dest. A trailing \n or \r\n is acceptable.
Should be used from MetaNamingService, after HostsTxtNamingService. Cannot be used as the only NamingService! Be sure any naming service hosts are in hosts.txt. Supports caching, b32, and b64.
Sample config to put in configadvanced.jsp (restart required):
i2p.naming.impl=net.i2p.client.naming.MetaNamingService i2p.nameservicelist=net.i2p.client.naming.HostsTxtNamingService,net.i2p.client.naming.EepGetNamingService i2p.naming.eepget.list=http://namingservice.i2p/cgi-bin/lkup.cgi?host=,http://i2host.i2p/cgi-bin/i2hostquery?
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringThe naming sites queried when the property is unset.private static final intLargest response accepted for a destination, allowing for the headers.private static final StringProperty listing the naming sites to query.private static final PatternCharacters allowed in a name being looked up.Fields inherited from class DummyNamingService
BASE32_HASH_LENGTH, CACHE_MAX_SIZE, DEST_SIZE, PROP_B32Modifier and TypeFieldDescriptionprotected static final intLength of a base32 hash string.protected static final intMaximum cache size.static final intStandard base64 destination length (no certificate).static final StringProperty to enable b32 lookup.Fields inherited from class NamingService
_context, _listeners, _log, _updaters, PROP_IMPLModifier and TypeFieldDescriptionprotected final I2PAppContextThe app context.protected final Set<NamingServiceListener> The listeners.protected final LogThe logger.protected final Set<NamingServiceUpdater> The updaters.static final StringWhat classname should be used as the naming service impl?Constructor Summary
ConstructorsConstructorDescriptionEepGetNamingService(I2PAppContext context) The naming service should only be constructed and accessed through the application context.Method Summary
Modifier and TypeMethodDescriptionprivate StringFetches one destination from a naming site.getURLs()Reads the naming sites from the config.lookup(String hostname, Properties lookupOptions, Properties storedOptions) Throws, this service knows no destinations.Methods inherited from class DummyNamingService
clearCache, getCache, putCache, removeCacheModifier and TypeMethodDescriptionprotected static voidClear all cached destinations.protected static DestinationLook up a cached destination.protected static voidputCache(String s, Destination d) Provide basic static caching for all services.protected static voidRemove a cached destination.Methods inherited from class NamingService
addDestination, addDestination, addNamingService, addNamingService, createInstance, export, export, getBase64Entries, getConfiguration, getEntries, getEntries, getName, getNames, getNames, getNamingServices, getParent, isB32Host, isBlindedHost, isI2PHost, lookup, lookup, lookupAll, lookupAll, lookupBase32, lookupBase64, put, put, putAll, putIfAbsent, putIfAbsent, registerListener, registerUpdater, remove, remove, remove, remove, removeNamingService, requestUpdate, reverseLookup, reverseLookup, reverseLookup, reverseLookupAll, reverseLookupAll, reverseLookupAll, setConfiguration, shutdown, size, size, start, toString, unregisterListener, unregisterUpdater, updateModifier and TypeMethodDescriptionbooleanaddDestination(String hostname, Destination d) Add a Destination to an existing hostname's entry in the addressbook.booleanaddDestination(String hostname, Destination d, Properties options) Add a Destination to an existing hostname's entry in the addressbook.booleanOnly for chaining-capable NamingServices.booleanaddNamingService(NamingService ns, boolean head) Only for chaining-capable NamingServices.static final NamingServicecreateInstance(I2PAppContext context) WARNING - for use byI2PAppContextonly - others must useI2PAppContext.namingService().voidExport in a hosts.txt format.voidexport(Writer out, Properties options) Export in a hosts.txt format.getBase64Entries(Properties options) This may be more or less efficient thanNamingService.getEntries(), depending on the implementation.Warning - unimplemented in any subclass.Warning - This obviously brings the whole database into memory, so use is discouraged.getEntries(Properties options) Warning - This will bring the whole database into memory if options is null, empty, or unsupported, use with caution.getName()The name of this naming service.getNames()All known hostnames.getNames(Properties options) All known hostnames matching the specified options.For daisy chaining (MetaNamingService).This implementation returns null.static booleanIs this a b32 hostname? Does NOT validate the base32 part except for length.static booleanisBlindedHost(String hostname) Is this a blinded ("b33") hostname? Does NOT validate the base32 part except for length.static booleanIs this an i2p hostname?Look up a hostname.Same asNamingService.lookupBase32(String, int)but with the SHA256 Hash precalculated This implementation returns null.For NamingServices that support multiple Destinations for a single hostname, return all of them.lookupAll(String hostname, Properties lookupOptions, List<Properties> storedOptions) For NamingServices that support multiple Destinations and Properties for a single hostname, return all of them.lookupBase32(String hostname, int timeout) Lookup a Base 32 address.protected DestinationlookupBase64(String hostname) If the hostname is a valid Base64 encoded destination, return the decoded Destination.booleanput(String hostname, Destination d) Add a hostname and Destination to the addressbook.booleanput(String hostname, Destination d, Properties options) Add a hostname and Destination to the addressbook.booleanputAll(Map<String, Destination> entries, Properties options) Put all the entries, each with the given options.booleanputIfAbsent(String hostname, Destination d) Add a hostname and Destination to the addressbook.booleanputIfAbsent(String hostname, Destination d, Properties options) Add a hostname and Destination to the addressbook.voidRegister a listener for naming service changes.voidRegister an updater for the naming service.booleanDelete the entry.booleanremove(String hostname, Properties options) Delete the entry.booleanremove(String hostname, Destination d) Remove a hostname's entry only if it contains the Destination d.booleanremove(String hostname, Destination d, Properties options) Remove a hostname's entry only if it contains the Destination d.booleanOnly for chaining-capable NamingServices.voidrequestUpdate(Properties options) Ask any registered updaters to update now.reverseLookup(Destination dest) Reverse lookup a destination.reverseLookup(Destination d, Properties options) Same as reverseLookup(dest) but with options This implementation returns null.Reverse lookup a hash.reverseLookupAll(Destination dest) Reverse lookup a destination This implementation returns reverseLookupAll(dest, null).reverseLookupAll(Destination d, Properties options) Same as reverseLookupAll(dest) but with options This implementation returns the result from reverseLookup, or null.Reverse lookup a hash.booleanWarning - unimplemented in any subclass.voidshutdown()Parent will call when removed.intsize()The number of entries in this naming service.intsize(Properties options) This implementation returns -1.voidstart()Parent will call when added.toString()Returns a string representation of this naming service.voidUnregister a listener for naming service changes.voidUnregister an updater for the naming service.booleanupdate(String hostname, Destination d, Properties options) Fails if entry did not previously exist.
Field Details
PROP_EEPGET_LIST
Property listing the naming sites to query.- See Also:
DEFAULT_EEPGET_LIST
The naming sites queried when the property is unset.- See Also:
VALID_DEST_CHARS
Characters allowed in a name being looked up.MAX_RESPONSE
private static final int MAX_RESPONSELargest response accepted for a destination, allowing for the headers.- See Also:
Constructor Details
EepGetNamingService
The naming service should only be constructed and accessed through the application context. This constructor should only be used by the appropriate application context itself.- Parameters:
context- the application context
Method Details
getURLs
lookup
Description copied from class:DummyNamingServiceThrows, this service knows no destinations.- Overrides:
lookupin classDummyNamingService- Parameters:
hostname- mixed case as it could be a keylookupOptions- input parameter, NamingService-specific, can be nullstoredOptions- output parameter, NamingService-specific, any stored properties will be added if non-null- Returns:
- dest or null
fetchAddr