diff --git a/core/java/src/net/i2p/client/naming/EepGetNamingService.java b/core/java/src/net/i2p/client/naming/EepGetNamingService.java index d83317967..737e33423 100644 --- a/core/java/src/net/i2p/client/naming/EepGetNamingService.java +++ b/core/java/src/net/i2p/client/naming/EepGetNamingService.java @@ -66,6 +66,10 @@ public class EepGetNamingService extends NamingService { hostname = hostname.toLowerCase(); + // If you want b32, chain with HostsTxtNamingService + if (hostname.length() == 60 && hostname.endsWith(".b32.i2p")) + return null; + // check the cache Destination d = getCache(hostname); if (d != null) diff --git a/core/java/src/net/i2p/client/naming/ExecNamingService.java b/core/java/src/net/i2p/client/naming/ExecNamingService.java index 446e907c4..118f06eac 100644 --- a/core/java/src/net/i2p/client/naming/ExecNamingService.java +++ b/core/java/src/net/i2p/client/naming/ExecNamingService.java @@ -66,6 +66,10 @@ public class ExecNamingService extends NamingService { hostname = hostname.toLowerCase(); + // If you want b32, chain with HostsTxtNamingService + if (hostname.length() == 60 && hostname.endsWith(".b32.i2p")) + return null; + // check the cache Destination d = getCache(hostname); if (d != null) diff --git a/core/java/src/net/i2p/client/naming/LookupDest.java b/core/java/src/net/i2p/client/naming/LookupDest.java index 1a8a1632b..2bbb2eeb6 100644 --- a/core/java/src/net/i2p/client/naming/LookupDest.java +++ b/core/java/src/net/i2p/client/naming/LookupDest.java @@ -27,6 +27,7 @@ class LookupDest { protected LookupDest(I2PAppContext context) {} + /** @param key 52 chars (do not include the .b32.i2p suffix) */ static Destination lookupBase32Hash(I2PAppContext ctx, String key) { byte[] h = Base32.decode(key); if (h == null) @@ -44,6 +45,7 @@ class LookupDest { } ****/ + /** @param h 32 byte hash */ static Destination lookupHash(I2PAppContext ctx, byte[] h) { Hash key = new Hash(h); Destination rv = null; diff --git a/core/java/src/net/i2p/client/naming/NamingService.java b/core/java/src/net/i2p/client/naming/NamingService.java index a7098d799..fc9a53414 100644 --- a/core/java/src/net/i2p/client/naming/NamingService.java +++ b/core/java/src/net/i2p/client/naming/NamingService.java @@ -32,7 +32,7 @@ public abstract class NamingService { public static final String PROP_IMPL = "i2p.naming.impl"; private static final String DEFAULT_IMPL = "net.i2p.client.naming.HostsTxtNamingService"; - protected static final int CACHE_MAX_SIZE = 8; + protected static final int CACHE_MAX_SIZE = 16; /** @@ -107,7 +107,7 @@ public abstract class NamingService { * The service may override the age and/or size limit */ /** Don't know why a dest would ever change but keep this short anyway */ - protected static final long CACHE_MAX_AGE = 60*1000; + protected static final long CACHE_MAX_AGE = 7*60*1000; private class CacheEntry { public Destination dest; @@ -174,4 +174,11 @@ public abstract class NamingService { return ce.dest; } } + + /** @since 0.8.1 */ + public void clearCache() { + synchronized (_cache) { + _cache.clear(); + } + } }