I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 5ef32540 authored by zzz's avatar zzz
Browse files

Optimize naming lookups for a destkey

parent d957712e
No related branches found
No related tags found
No related merge requests found
...@@ -63,6 +63,10 @@ public class EepGetNamingService extends NamingService { ...@@ -63,6 +63,10 @@ public class EepGetNamingService extends NamingService {
} }
public Destination lookup(String hostname) { public Destination lookup(String hostname) {
// If it's long, assume it's a key.
if (hostname.length() >= DEST_SIZE)
return lookupBase64(hostname);
hostname = hostname.toLowerCase(); hostname = hostname.toLowerCase();
// check the cache // check the cache
...@@ -95,10 +99,7 @@ public class EepGetNamingService extends NamingService { ...@@ -95,10 +99,7 @@ public class EepGetNamingService extends NamingService {
return lookupBase64(key); return lookupBase64(key);
} }
} }
return null;
// If we can't find name,
// assume it's a key.
return lookupBase64(hostname);
} }
private static final int DEST_SIZE = 516; // Std. Base64 length (no certificate) private static final int DEST_SIZE = 516; // Std. Base64 length (no certificate)
......
...@@ -64,6 +64,10 @@ public class ExecNamingService extends NamingService { ...@@ -64,6 +64,10 @@ public class ExecNamingService extends NamingService {
} }
public Destination lookup(String hostname) { public Destination lookup(String hostname) {
// If it's long, assume it's a key.
if (hostname.length() >= DEST_SIZE)
return lookupBase64(hostname);
hostname = hostname.toLowerCase(); hostname = hostname.toLowerCase();
// check the cache // check the cache
...@@ -80,10 +84,7 @@ public class ExecNamingService extends NamingService { ...@@ -80,10 +84,7 @@ public class ExecNamingService extends NamingService {
_hosts.setProperty(hostname, key); // cache _hosts.setProperty(hostname, key); // cache
return lookupBase64(key); return lookupBase64(key);
} }
return null;
// If we can't find name,
// assume it's a key.
return lookupBase64(hostname);
} }
private static final int DEST_SIZE = 516; // Std. Base64 length (no certificate) private static final int DEST_SIZE = 516; // Std. Base64 length (no certificate)
......
...@@ -54,6 +54,10 @@ public class HostsTxtNamingService extends NamingService { ...@@ -54,6 +54,10 @@ public class HostsTxtNamingService extends NamingService {
} }
public Destination lookup(String hostname) { public Destination lookup(String hostname) {
// If it's long, assume it's a key.
if (hostname.length() >= 516)
return lookupBase64(hostname);
// check the list each time, reloading the file on each // check the list each time, reloading the file on each
// lookup // lookup
...@@ -79,12 +83,10 @@ public class HostsTxtNamingService extends NamingService { ...@@ -79,12 +83,10 @@ public class HostsTxtNamingService extends NamingService {
} }
// not found, continue to the next file // not found, continue to the next file
} }
// If we can't find name in any of the hosts files, return null;
// assume it's a key.
return lookupBase64(hostname);
} }
public String reverseLookup(Destination dest) { public String reverseLookup(Destination dest) {
return null; return null;
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment