diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnel.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnel.java
index 560475e42..3b279a679 100644
--- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnel.java
+++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnel.java
@@ -662,7 +662,7 @@ public class I2PTunnel implements Logging, EventDispatcher {
* "openSOCKSTunnelResult" = "ok" or "error" after the client tunnel has
* started.
*
- * @param args {portNumber}
+ * @param args {portNumber [, sharedClient]}
* @param l logger to receive events and output
*/
public void runSOCKSTunnel(String args[], Logging l) {
@@ -677,6 +677,11 @@ public class I2PTunnel implements Logging, EventDispatcher {
return;
}
+ boolean isShared = false;
+ if (args.length > 1)
+ isShared = "true".equalsIgnoreCase(args[1].trim());
+
+ ownDest = !isShared;
I2PTunnelTask task;
task = new I2PSOCKSTunnel(port, l, ownDest, (EventDispatcher) this, this);
addtask(task);
diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelController.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelController.java
index 955d3abd1..f8592fcd3 100644
--- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelController.java
+++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelController.java
@@ -135,8 +135,10 @@ public class TunnelController implements Logging {
}
if ("httpclient".equals(type)) {
startHttpClient();
- }else if("ircclient".equals(type)) {
+ } else if("ircclient".equals(type)) {
startIrcClient();
+ } else if("sockstunnel".equals(type)) {
+ startSocksClient();
} else if ("client".equals(type)) {
startClient();
} else if ("server".equals(type)) {
@@ -176,6 +178,17 @@ public class TunnelController implements Logging {
_running = true;
}
+ private void startSocksClient() {
+ setI2CPOptions();
+ setSessionOptions();
+ setListenOn();
+ String listenPort = getListenPort();
+ String sharedClient = getSharedClient();
+ _tunnel.runSOCKSTunnel(new String[] { listenPort, sharedClient }, this);
+ acquire();
+ _running = true;
+ }
+
/**
* Note the fact that we are using some sessions, so that they dont get
* closed by some other tunnels
diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKSServerFactory.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKSServerFactory.java
index 357149652..b9b04c57a 100644
--- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKSServerFactory.java
+++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKSServerFactory.java
@@ -39,8 +39,7 @@ public class SOCKSServerFactory {
serv = new SOCKS5Server(s);
break;
default:
- _log.debug("SOCKS protocol version not supported (" + Integer.toHexString(socksVer) + ")");
- return null;
+ throw new SOCKSException("SOCKS protocol version not supported (" + Integer.toHexString(socksVer) + ")");
}
} catch (IOException e) {
_log.debug("error reading SOCKS protocol version");
@@ -49,4 +48,4 @@ public class SOCKSServerFactory {
return serv;
}
-}
\ No newline at end of file
+}
diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java
index 06a46b701..07730718a 100644
--- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java
+++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java
@@ -31,9 +31,7 @@ public class EditBean extends IndexBean {
if (controllers.size() > tunnel) {
TunnelController cur = (TunnelController)controllers.get(tunnel);
if (cur == null) return false;
- return ( ("client".equals(cur.getType())) ||
- ("httpclient".equals(cur.getType()))||
- ("ircclient".equals(cur.getType())));
+ return isClient(cur.getType());
} else {
return false;
}
diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java
index 8c361195a..1500150e3 100644
--- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java
+++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java
@@ -209,10 +209,7 @@ public class IndexBean {
}
// Only modify other shared tunnels
// if the current tunnel is shared, and of supported type
- if ("true".equalsIgnoreCase(cur.getSharedClient()) &&
- ("ircclient".equals(cur.getType()) ||
- "httpclient".equals(cur.getType()) ||
- "client".equals(cur.getType()))) {
+ if ("true".equalsIgnoreCase(cur.getSharedClient()) && isClient(cur.getType())) {
// all clients use the same I2CP session, and as such, use the same I2CP options
List controllers = _group.getControllers();
@@ -224,11 +221,7 @@ public class IndexBean {
// Only modify this non-current tunnel
// if it belongs to a shared destination, and is of supported type
- if ("true".equalsIgnoreCase(c.getSharedClient()) &&
- ("httpclient".equals(c.getType()) ||
- "ircclient".equals(c.getType()) ||
- "client".equals(c.getType()))) {
-
+ if ("true".equalsIgnoreCase(c.getSharedClient()) && isClient(c.getType())) {
Properties cOpt = c.getConfig("");
if (_tunnelQuantity != null) {
cOpt.setProperty("option.inbound.quantity", _tunnelQuantity);
@@ -326,9 +319,14 @@ public class IndexBean {
public boolean isClient(int tunnelNum) {
TunnelController cur = getController(tunnelNum);
if (cur == null) return false;
- return ( ("client".equals(cur.getType())) ||
- ("httpclient".equals(cur.getType())) ||
- ("ircclient".equals(cur.getType())));
+ return isClient(cur.getType());
+ }
+
+ public static boolean isClient(String type) {
+ return ( ("client".equals(type)) ||
+ ("httpclient".equals(type)) ||
+ ("sockstunnel".equals(type)) ||
+ ("ircclient".equals(type)));
}
public String getTunnelName(int tunnel) {
@@ -361,6 +359,7 @@ public class IndexBean {
else if ("ircclient".equals(internalType)) return "IRC client";
else if ("server".equals(internalType)) return "Standard server";
else if ("httpserver".equals(internalType)) return "HTTP server";
+ else if ("sockstunnel".equals(internalType)) return "SOCKS proxy";
else return internalType;
}
@@ -579,77 +578,40 @@ public class IndexBean {
Properties config = new Properties();
updateConfigGeneric(config);
- if ("httpclient".equals(_type)) {
+ if (isClient(_type)) {
+ // generic client stuff
if (_port != null)
config.setProperty("listenPort", _port);
if (_reachableByOther != null)
config.setProperty("interface", _reachableByOther);
else
config.setProperty("interface", _reachableBy);
- if (_proxyList != null)
- config.setProperty("proxyList", _proxyList);
-
- config.setProperty("option.inbound.nickname", CLIENT_NICKNAME);
- config.setProperty("option.outbound.nickname", CLIENT_NICKNAME);
+ config.setProperty("option.inbound.nickname", CLIENT_NICKNAME);
+ config.setProperty("option.outbound.nickname", CLIENT_NICKNAME);
if (_name != null && !_sharedClient) {
config.setProperty("option.inbound.nickname", _name);
config.setProperty("option.outbound.nickname", _name);
}
-
config.setProperty("sharedClient", _sharedClient + "");
- }else if ("ircclient".equals(_type)) {
- if (_port != null)
- config.setProperty("listenPort", _port);
- if (_reachableByOther != null)
- config.setProperty("interface", _reachableByOther);
- else
- config.setProperty("interface", _reachableBy);
- if (_targetDestination != null)
- config.setProperty("targetDestination", _targetDestination);
+ } else {
+ // generic server stuff
+ if (_targetHost != null)
+ config.setProperty("targetHost", _targetHost);
+ if (_targetPort != null)
+ config.setProperty("targetPort", _targetPort);
+ if (_privKeyFile != null)
+ config.setProperty("privKeyFile", _privKeyFile);
+ }
- config.setProperty("option.inbound.nickname", CLIENT_NICKNAME);
- config.setProperty("option.outbound.nickname", CLIENT_NICKNAME);
- if (_name != null && !_sharedClient) {
- config.setProperty("option.inbound.nickname", _name);
- config.setProperty("option.outbound.nickname", _name);
- }
-
- config.setProperty("sharedClient", _sharedClient + "");
- } else if ("client".equals(_type)) {
- if (_port != null)
- config.setProperty("listenPort", _port);
- if (_reachableByOther != null)
- config.setProperty("interface", _reachableByOther);
- else
- config.setProperty("interface", _reachableBy);
+ if ("httpclient".equals(_type)) {
+ if (_proxyList != null)
+ config.setProperty("proxyList", _proxyList);
+ } else if ("ircclient".equals(_type) || "client".equals(_type)) {
if (_targetDestination != null)
config.setProperty("targetDestination", _targetDestination);
-
- config.setProperty("option.inbound.nickname", CLIENT_NICKNAME);
- config.setProperty("option.outbound.nickname", CLIENT_NICKNAME);
- if (_name != null && !_sharedClient) {
- config.setProperty("option.inbound.nickname", _name);
- config.setProperty("option.outbound.nickname", _name);
- }
- config.setProperty("sharedClient", _sharedClient + "");
- } else if ("server".equals(_type)) {
- if (_targetHost != null)
- config.setProperty("targetHost", _targetHost);
- if (_targetPort != null)
- config.setProperty("targetPort", _targetPort);
- if (_privKeyFile != null)
- config.setProperty("privKeyFile", _privKeyFile);
} else if ("httpserver".equals(_type)) {
- if (_targetHost != null)
- config.setProperty("targetHost", _targetHost);
- if (_targetPort != null)
- config.setProperty("targetPort", _targetPort);
- if (_privKeyFile != null)
- config.setProperty("privKeyFile", _privKeyFile);
if (_spoofedHost != null)
config.setProperty("spoofedHost", _spoofedHost);
- } else {
- return null;
}
return config;
diff --git a/apps/i2ptunnel/jsp/edit.jsp b/apps/i2ptunnel/jsp/edit.jsp
index 931629fb1..67fdf016c 100644
--- a/apps/i2ptunnel/jsp/edit.jsp
+++ b/apps/i2ptunnel/jsp/edit.jsp
@@ -14,7 +14,7 @@ String tun = request.getParameter("tunnel");
} else {
String type = request.getParameter("type");
int curTunnel = -1;
- if ("client".equals(type) || "httpclient".equals(type) || "ircclient".equals(type)) {
+ if (EditBean.isClient(type)) {
%>