forked from I2P_Developers/i2p.i2p
* I2PTunnel: Allow changing of spoof host and target host/port without
restarting server tunnel
This commit is contained in:
@@ -182,6 +182,10 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
|||||||
if (getTunnel() != tunnel)
|
if (getTunnel() != tunnel)
|
||||||
return;
|
return;
|
||||||
setupPostThrottle();
|
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);
|
super.optionsUpdated(tunnel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,6 +16,7 @@ import java.net.InetSocketAddress;
|
|||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.net.SocketException;
|
import java.net.SocketException;
|
||||||
import java.net.SocketTimeoutException;
|
import java.net.SocketTimeoutException;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
import java.security.GeneralSecurityException;
|
import java.security.GeneralSecurityException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
@@ -50,8 +51,8 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable {
|
|||||||
protected final Object slock = new Object();
|
protected final Object slock = new Object();
|
||||||
protected final Object sslLock = new Object();
|
protected final Object sslLock = new Object();
|
||||||
|
|
||||||
protected final InetAddress remoteHost;
|
protected InetAddress remoteHost;
|
||||||
protected final int remotePort;
|
protected int remotePort;
|
||||||
private final boolean _usePool;
|
private final boolean _usePool;
|
||||||
protected final Logging l;
|
protected final Logging l;
|
||||||
private I2PSSLSocketFactory _sslFactory;
|
private I2PSSLSocketFactory _sslFactory;
|
||||||
@@ -350,6 +351,7 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the I2PSocketManager.
|
* Update the I2PSocketManager.
|
||||||
|
* And since 0.9.15, the target host and port.
|
||||||
*
|
*
|
||||||
* @since 0.9.1
|
* @since 0.9.1
|
||||||
*/
|
*/
|
||||||
@@ -359,6 +361,27 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable {
|
|||||||
return;
|
return;
|
||||||
Properties props = tunnel.getClientOptions();
|
Properties props = tunnel.getClientOptions();
|
||||||
sockMgr.setDefaultOptions(sockMgr.buildOptions(props));
|
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);
|
buildSocketMap(props);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -487,6 +487,17 @@ public class TunnelController implements Logging {
|
|||||||
String proxies = getProxyList();
|
String proxies = getProxyList();
|
||||||
if (proxies != null)
|
if (proxies != null)
|
||||||
opts.setProperty(PROP_PROXIES, proxies);
|
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);
|
_tunnel.setClientOptions(opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user