diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java index 128b1565d3d032bbe6957156a7ed53045bc780ea..ac1d2d39a7d5689fff43a510435b2c087a1feffc 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java @@ -182,6 +182,10 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer { if (getTunnel() != tunnel) return; setupPostThrottle(); + Properties props = tunnel.getClientOptions(); + // see TunnelController.setSessionOptions() + String spoofHost = props.getProperty(TunnelController.PROP_SPOOFED_HOST); + _spoofHost = (spoofHost != null && spoofHost.trim().length() > 0) ? spoofHost.trim() : null; super.optionsUpdated(tunnel); } diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java index c79e274e083686ca0cd32d1c28de9ef9b5b20043..dfec31bc375faca85efa1f14faddb4fd9cd703f7 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java @@ -16,6 +16,7 @@ import java.net.InetSocketAddress; import java.net.Socket; import java.net.SocketException; import java.net.SocketTimeoutException; +import java.net.UnknownHostException; import java.security.GeneralSecurityException; import java.util.Map; import java.util.Properties; @@ -50,8 +51,8 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable { protected final Object slock = new Object(); protected final Object sslLock = new Object(); - protected final InetAddress remoteHost; - protected final int remotePort; + protected InetAddress remoteHost; + protected int remotePort; private final boolean _usePool; protected final Logging l; private I2PSSLSocketFactory _sslFactory; @@ -350,6 +351,7 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable { /** * Update the I2PSocketManager. + * And since 0.9.15, the target host and port. * * @since 0.9.1 */ @@ -359,6 +361,27 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable { return; Properties props = tunnel.getClientOptions(); sockMgr.setDefaultOptions(sockMgr.buildOptions(props)); + // see TunnelController.setSessionOptions() + String h = props.getProperty(TunnelController.PROP_TARGET_HOST); + if (h != null) { + try { + remoteHost = InetAddress.getByName(h); + } catch (UnknownHostException uhe) { + l.log("Unknown host: " + h); + } + } + String p = props.getProperty(TunnelController.PROP_TARGET_PORT); + if (p != null) { + try { + int port = Integer.parseInt(p); + if (port > 0 && port <= 65535) + remotePort = port; + else + l.log("Bad port: " + port); + } catch (NumberFormatException nfe) { + l.log("Bad port: " + p); + } + } buildSocketMap(props); } diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelController.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelController.java index 96fab6213b945d43f3543016472f4fff6fbc4eec..32b8b85af31f3edea4315f5a16eda1fe3c852322 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelController.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelController.java @@ -487,6 +487,17 @@ public class TunnelController implements Logging { String proxies = getProxyList(); if (proxies != null) opts.setProperty(PROP_PROXIES, proxies); + // Ditto spoof host. Since 0.9.15. + String spoofhost = getSpoofedHost(); + if (spoofhost != null) + opts.setProperty(PROP_SPOOFED_HOST, spoofhost); + // Ditto target host/port. Since 0.9.15. + String targethost = getTargetHost(); + if (targethost != null) + opts.setProperty(PROP_TARGET_HOST, targethost); + String targetport = getTargetPort(); + if (targetport != null) + opts.setProperty(PROP_TARGET_PORT, targetport); _tunnel.setClientOptions(opts); }