* I2PTunnel: Deprecate destFromName()
This commit is contained in:
@ -1573,6 +1573,7 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
*
|
||||
* Since file:<filename> isn't really used, this method is deprecated,
|
||||
* just call context.namingService.lookup() directly.
|
||||
* @deprecated Don't use i2ptunnel for lookup! Use I2PAppContext.getGlobalContext().namingService().lookup(name) from i2p.jar
|
||||
*/
|
||||
public static Destination destFromName(String name) throws DataFormatException {
|
||||
|
||||
|
@ -42,15 +42,11 @@ public class I2PTunnelClient extends I2PTunnelClientBase {
|
||||
dests = new ArrayList(1);
|
||||
while (tok.hasMoreTokens()) {
|
||||
String destination = tok.nextToken();
|
||||
try {
|
||||
Destination destN = I2PTunnel.destFromName(destination);
|
||||
if (destN == null)
|
||||
l.log("Could not resolve " + destination);
|
||||
else
|
||||
dests.add(destN);
|
||||
} catch (DataFormatException dfe) {
|
||||
l.log("Bad format parsing \"" + destination + "\"");
|
||||
}
|
||||
Destination destN = _context.namingService().lookup(destination);
|
||||
if (destN == null)
|
||||
l.log("Could not resolve " + destination);
|
||||
else
|
||||
dests.add(destN);
|
||||
}
|
||||
|
||||
if (dests.isEmpty()) {
|
||||
|
@ -278,7 +278,7 @@ public class I2PTunnelConnectClient extends I2PTunnelHTTPClientBase implements R
|
||||
return;
|
||||
}
|
||||
|
||||
Destination clientDest = I2PTunnel.destFromName(destination);
|
||||
Destination clientDest = _context.namingService().lookup(destination);
|
||||
if (clientDest == null) {
|
||||
String str;
|
||||
byte[] header;
|
||||
|
@ -28,7 +28,6 @@ import net.i2p.client.streaming.I2PSocketManager;
|
||||
import net.i2p.client.streaming.I2PSocketOptions;
|
||||
import net.i2p.data.Base32;
|
||||
import net.i2p.data.Base64;
|
||||
import net.i2p.data.DataFormatException;
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.data.Destination;
|
||||
import net.i2p.util.EventDispatcher;
|
||||
@ -431,11 +430,9 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
|
||||
// Host resolvable from database, verify addresshelper key
|
||||
// Silently bypass correct keys, otherwise alert
|
||||
String destB64 = null;
|
||||
try {
|
||||
Destination _dest = I2PTunnel.destFromName(host);
|
||||
if (_dest != null)
|
||||
destB64 = _dest.toBase64();
|
||||
} catch (DataFormatException dfe) {}
|
||||
Destination _dest = _context.namingService().lookup(host);
|
||||
if (_dest != null)
|
||||
destB64 = _dest.toBase64();
|
||||
if (destB64 != null && !destB64.equals(ahelperKey))
|
||||
{
|
||||
// Conflict: handle when URL reconstruction done
|
||||
@ -721,7 +718,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
|
||||
if ("i2p".equals(host))
|
||||
clientDest = null;
|
||||
else
|
||||
clientDest = I2PTunnel.destFromName(destination);
|
||||
clientDest = _context.namingService().lookup(destination);
|
||||
|
||||
if (clientDest == null) {
|
||||
//l.log("Could not resolve " + destination + ".");
|
||||
@ -814,17 +811,13 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
|
||||
* @return b32hash.b32.i2p, or "i2p" on lookup failure.
|
||||
* Prior to 0.7.12, returned b64 key
|
||||
*/
|
||||
private final static String getHostName(String host) {
|
||||
private final String getHostName(String host) {
|
||||
if (host == null) return null;
|
||||
if (host.length() == 60 && host.toLowerCase().endsWith(".b32.i2p"))
|
||||
return host;
|
||||
try {
|
||||
Destination dest = I2PTunnel.destFromName(host);
|
||||
if (dest == null) return "i2p";
|
||||
return Base32.encode(dest.calculateHash().getData()) + ".b32.i2p";
|
||||
} catch (DataFormatException dfe) {
|
||||
return "i2p";
|
||||
}
|
||||
Destination dest = _context.namingService().lookup(host);
|
||||
if (dest == null) return "i2p";
|
||||
return Base32.encode(dest.calculateHash().getData()) + ".b32.i2p";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -947,12 +940,8 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
|
||||
// Skip jump servers we don't know
|
||||
String jumphost = jurl.substring(7); // "http://"
|
||||
jumphost = jumphost.substring(0, jumphost.indexOf('/'));
|
||||
try {
|
||||
Destination dest = I2PTunnel.destFromName(jumphost);
|
||||
if (dest == null) continue;
|
||||
} catch (DataFormatException dfe) {
|
||||
continue;
|
||||
}
|
||||
Destination dest = I2PAppContext.getGlobalContext().namingService().lookup(jumphost);
|
||||
if (dest == null) continue;
|
||||
|
||||
out.write("<br><a href=\"".getBytes());
|
||||
out.write(jurl.getBytes());
|
||||
@ -1014,7 +1003,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
|
||||
|
||||
if (!found) {
|
||||
try {
|
||||
Destination d = I2PTunnel.destFromName(host);
|
||||
Destination d = _context.namingService().lookup(host);
|
||||
if (d == null) return false;
|
||||
} catch (DataFormatException dfe) {
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import net.i2p.client.streaming.I2PSocket;
|
||||
import net.i2p.data.DataFormatException;
|
||||
import net.i2p.data.Destination;
|
||||
import net.i2p.util.EventDispatcher;
|
||||
import net.i2p.util.I2PAppThread;
|
||||
@ -52,15 +51,11 @@ public class I2PTunnelIRCClient extends I2PTunnelClientBase implements Runnable
|
||||
dests = new ArrayList(2);
|
||||
while (tok.hasMoreTokens()) {
|
||||
String destination = tok.nextToken();
|
||||
try {
|
||||
Destination destN = I2PTunnel.destFromName(destination);
|
||||
if (destN == null)
|
||||
l.log("Could not resolve " + destination);
|
||||
else
|
||||
dests.add(destN);
|
||||
} catch (DataFormatException dfe) {
|
||||
l.log("Bad format parsing \"" + destination + "\"");
|
||||
}
|
||||
Destination destN = _context.namingService().lookup(destination);
|
||||
if (destN == null)
|
||||
l.log("Could not resolve " + destination);
|
||||
else
|
||||
dests.add(destN);
|
||||
}
|
||||
|
||||
if (dests.isEmpty()) {
|
||||
|
@ -10,6 +10,7 @@ import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.I2PException;
|
||||
import net.i2p.client.streaming.I2PSocketManager;
|
||||
import net.i2p.data.Destination;
|
||||
@ -200,7 +201,7 @@ public class I2Ping extends I2PTunnelTask implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Destination dest = I2PTunnel.destFromName(destination);
|
||||
Destination dest = I2PAppContext.getGlobalContext().namingService().lookup(destination);
|
||||
if (dest == null) {
|
||||
synchronized (lock) { // Logger is not thread safe
|
||||
l.log("Unresolvable: " + destination + "");
|
||||
|
@ -204,7 +204,7 @@ public class SOCKS4aServer extends SOCKSServer {
|
||||
// Let's not due a new Dest for every request, huh?
|
||||
//I2PSocketManager sm = I2PSocketManagerFactory.createManager();
|
||||
//destSock = sm.connect(I2PTunnel.destFromName(connHostName), null);
|
||||
destSock = t.createI2PSocket(I2PTunnel.destFromName(connHostName));
|
||||
destSock = t.createI2PSocket(I2PAppContext.getGlobalContext().namingService().lookup(connHostName));
|
||||
} else if ("localhost".equals(connHostName) || "127.0.0.1".equals(connHostName)) {
|
||||
String err = "No localhost accesses allowed through the Socks Proxy";
|
||||
_log.error(err);
|
||||
@ -237,7 +237,7 @@ public class SOCKS4aServer extends SOCKSServer {
|
||||
_log.debug("connecting to port " + connPort + " proxy " + proxy + " for " + connHostName + "...");
|
||||
// this isn't going to work, these need to be socks outproxies so we need
|
||||
// to do a socks session to them?
|
||||
destSock = t.createI2PSocket(I2PTunnel.destFromName(proxy));
|
||||
destSock = t.createI2PSocket(I2PAppContext.getGlobalContext().namingService().lookup(proxy));
|
||||
}
|
||||
confirmConnection();
|
||||
_log.debug("connection confirmed - exchanging data...");
|
||||
|
@ -360,14 +360,14 @@ public class SOCKS5Server extends SOCKSServer {
|
||||
// Let's not due a new Dest for every request, huh?
|
||||
//I2PSocketManager sm = I2PSocketManagerFactory.createManager();
|
||||
//destSock = sm.connect(I2PTunnel.destFromName(connHostName), null);
|
||||
Destination dest = I2PTunnel.destFromName(connHostName);
|
||||
Destination dest = I2PAppContext.getGlobalContext().namingService().lookup(connHostName);
|
||||
if (dest == null) {
|
||||
try {
|
||||
sendRequestReply(Reply.HOST_UNREACHABLE, AddressType.DOMAINNAME, null, "0.0.0.0", 0, out);
|
||||
} catch (IOException ioe) {}
|
||||
throw new SOCKSException("Host not found");
|
||||
}
|
||||
destSock = t.createI2PSocket(I2PTunnel.destFromName(connHostName));
|
||||
destSock = t.createI2PSocket(I2PAppContext.getGlobalContext().namingService().lookup(connHostName));
|
||||
} else if ("localhost".equals(connHostName) || "127.0.0.1".equals(connHostName)) {
|
||||
String err = "No localhost accesses allowed through the Socks Proxy";
|
||||
_log.error(err);
|
||||
@ -455,10 +455,10 @@ public class SOCKS5Server extends SOCKSServer {
|
||||
Properties overrides = new Properties();
|
||||
overrides.setProperty("option.i2p.streaming.connectDelay", "1000");
|
||||
I2PSocketOptions proxyOpts = tun.buildOptions(overrides);
|
||||
Destination dest = I2PTunnel.destFromName(proxy);
|
||||
Destination dest = I2PAppContext.getGlobalContext().namingService().lookup(proxy);
|
||||
if (dest == null)
|
||||
throw new SOCKSException("Outproxy not found");
|
||||
I2PSocket destSock = tun.createI2PSocket(I2PTunnel.destFromName(proxy), proxyOpts);
|
||||
I2PSocket destSock = tun.createI2PSocket(I2PAppContext.getGlobalContext().namingService().lookup(proxy), proxyOpts);
|
||||
try {
|
||||
DataOutputStream out = new DataOutputStream(destSock.getOutputStream());
|
||||
boolean authAvail = Boolean.valueOf(props.getProperty(I2PTunnelHTTPClientBase.PROP_OUTPROXY_AUTH)).booleanValue();
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.i2p.i2ptunnel.socks;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.data.Base32;
|
||||
import net.i2p.data.DataFormatException;
|
||||
import net.i2p.data.Destination;
|
||||
import net.i2p.i2ptunnel.I2PTunnel;
|
||||
|
||||
@ -74,11 +74,8 @@ public class SOCKSHeader {
|
||||
String name = getHost();
|
||||
if (name == null)
|
||||
return null;
|
||||
try {
|
||||
// the naming service does caching (thankfully)
|
||||
return I2PTunnel.destFromName(name);
|
||||
} catch (DataFormatException dfe) {}
|
||||
return null;
|
||||
// the naming service does caching (thankfully)
|
||||
return I2PAppContext.getGlobalContext().namingService().lookup(name);
|
||||
}
|
||||
|
||||
public byte[] getBytes() {
|
||||
|
@ -117,9 +117,7 @@ import net.i2p.util.Log;
|
||||
|
||||
// Setup the sink. Always send repliable datagrams.
|
||||
if (destination != null && destination.length() > 0) {
|
||||
try {
|
||||
_otherDest = I2PTunnel.destFromName(destination);
|
||||
} catch (DataFormatException dfe) {}
|
||||
_otherDest = _context.namingService().lookup(destination);
|
||||
if (_otherDest == null) {
|
||||
l.log("Could not resolve " + destination);
|
||||
throw new RuntimeException("failed to create session - could not resolve " + destination);
|
||||
|
Reference in New Issue
Block a user