diff --git a/core/java/src/net/i2p/client/naming/BlockfileNamingService.java b/core/java/src/net/i2p/client/naming/BlockfileNamingService.java index ec12eb792d8543bd258cf66e644a33a088057d56..efa8b3e064710a2c5bf0aaf61a558332a32a7b9b 100644 --- a/core/java/src/net/i2p/client/naming/BlockfileNamingService.java +++ b/core/java/src/net/i2p/client/naming/BlockfileNamingService.java @@ -621,11 +621,33 @@ public class BlockfileNamingService extends DummyNamingService { ////////// Start NamingService API /* + * + * Will strip a "www." prefix and retry if lookup fails + * + * @param hostname upper/lower case ok * @param options If non-null and contains the key "list", lookup in * that list only, otherwise all lists */ @Override public Destination lookup(String hostname, Properties lookupOptions, Properties storedOptions) { + Destination rv = lookup2(hostname, lookupOptions, storedOptions); + if (rv == null) { + // if hostname starts with "www.", strip and try again + // but not for www.i2p + hostname = hostname.toLowerCase(Locale.US); + if (hostname.startsWith("www.") && hostname.length() > 7) { + hostname = hostname.substring(4); + rv = lookup2(hostname, lookupOptions, storedOptions); + } + } + return rv; + } + + /* + * @param options If non-null and contains the key "list", lookup in + * that list only, otherwise all lists + */ + private Destination lookup2(String hostname, Properties lookupOptions, Properties storedOptions) { String listname = null; if (lookupOptions != null) listname = lookupOptions.getProperty("list"); diff --git a/core/java/src/net/i2p/client/naming/SingleFileNamingService.java b/core/java/src/net/i2p/client/naming/SingleFileNamingService.java index c331fae01ed25a3a74f4b253918dba6866eff157..219c61bbc2cc29bc24b0882029bedb8031ebc219 100644 --- a/core/java/src/net/i2p/client/naming/SingleFileNamingService.java +++ b/core/java/src/net/i2p/client/naming/SingleFileNamingService.java @@ -77,6 +77,8 @@ public class SingleFileNamingService extends NamingService { } /** + * Will strip a "www." prefix and retry if lookup fails + * * @param hostname case-sensitive; caller should convert to lower case * @param lookupOptions ignored * @param storedOptions ignored @@ -85,6 +87,8 @@ public class SingleFileNamingService extends NamingService { public Destination lookup(String hostname, Properties lookupOptions, Properties storedOptions) { try { String key = getKey(hostname); + if (key == null && hostname.startsWith("www.") && hostname.length() > 7) + key = getKey(hostname.substring(4)); if (key != null) return lookupBase64(key); } catch (Exception ioe) {