java.lang.Object
net.i2p.client.naming.NamingService
net.i2p.client.naming.DummyNamingService
- Direct Known Subclasses:
BlockfileNamingService, EepGetNamingService, MetaNamingService
A Dummy naming service that can only handle base64 and b32 destinations.
Field Summary
Modifier and TypeFieldDescriptionprivate static final Map<String, Destination> The LRU cache, with no expiration time.protected 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
ConstructorsModifierConstructorDescriptionprotectedDummyNamingService(I2PAppContext context) The naming service should only be constructed and accessed through the application context.Method Summary
Modifier and TypeMethodDescriptionprotected static voidClear all cached destinations.protected static DestinationLook up a cached destination.lookup(String hostname, Properties lookupOptions, Properties storedOptions) Throws, this service knows no destinations.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
BASE32_HASH_LENGTH
protected static final int BASE32_HASH_LENGTHLength of a base32 hash string.- See Also:
PROP_B32
CACHE_MAX_SIZE
protected static final int CACHE_MAX_SIZEMaximum cache size.DEST_SIZE
public static final int DEST_SIZEStandard base64 destination length (no certificate).- See Also:
_cache
The LRU cache, with no expiration time. Classes should take care to callremoveCache(String)for any entries that are invalidated.
Constructor Details
DummyNamingService
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
lookup
Throws, this service knows no destinations.- Specified by:
lookupin classNamingService- 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
putCache
Provide basic static caching for all services.- Parameters:
s- case-sensitive, could be a hostname or a full b64 stringd- the destination to cache
getCache
Look up a cached destination.- Parameters:
s- case-sensitive, could be a hostname or a full b64 string- Returns:
- cached dest or null
removeCache
Remove a cached destination.- Parameters:
s- case-sensitive, could be a hostname or a full b64 string
clearCache
protected static void clearCache()Clear all cached destinations. @since 0.8.1.