Add socks to gui, prevent NPE on socks 4 request, general cleanup
This commit is contained in:
@ -662,7 +662,7 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
|||||||
* "openSOCKSTunnelResult" = "ok" or "error" after the client tunnel has
|
* "openSOCKSTunnelResult" = "ok" or "error" after the client tunnel has
|
||||||
* started.
|
* started.
|
||||||
*
|
*
|
||||||
* @param args {portNumber}
|
* @param args {portNumber [, sharedClient]}
|
||||||
* @param l logger to receive events and output
|
* @param l logger to receive events and output
|
||||||
*/
|
*/
|
||||||
public void runSOCKSTunnel(String args[], Logging l) {
|
public void runSOCKSTunnel(String args[], Logging l) {
|
||||||
@ -677,6 +677,11 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isShared = false;
|
||||||
|
if (args.length > 1)
|
||||||
|
isShared = "true".equalsIgnoreCase(args[1].trim());
|
||||||
|
|
||||||
|
ownDest = !isShared;
|
||||||
I2PTunnelTask task;
|
I2PTunnelTask task;
|
||||||
task = new I2PSOCKSTunnel(port, l, ownDest, (EventDispatcher) this, this);
|
task = new I2PSOCKSTunnel(port, l, ownDest, (EventDispatcher) this, this);
|
||||||
addtask(task);
|
addtask(task);
|
||||||
|
@ -135,8 +135,10 @@ public class TunnelController implements Logging {
|
|||||||
}
|
}
|
||||||
if ("httpclient".equals(type)) {
|
if ("httpclient".equals(type)) {
|
||||||
startHttpClient();
|
startHttpClient();
|
||||||
}else if("ircclient".equals(type)) {
|
} else if("ircclient".equals(type)) {
|
||||||
startIrcClient();
|
startIrcClient();
|
||||||
|
} else if("sockstunnel".equals(type)) {
|
||||||
|
startSocksClient();
|
||||||
} else if ("client".equals(type)) {
|
} else if ("client".equals(type)) {
|
||||||
startClient();
|
startClient();
|
||||||
} else if ("server".equals(type)) {
|
} else if ("server".equals(type)) {
|
||||||
@ -176,6 +178,17 @@ public class TunnelController implements Logging {
|
|||||||
_running = true;
|
_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
|
* Note the fact that we are using some sessions, so that they dont get
|
||||||
* closed by some other tunnels
|
* closed by some other tunnels
|
||||||
|
@ -39,8 +39,7 @@ public class SOCKSServerFactory {
|
|||||||
serv = new SOCKS5Server(s);
|
serv = new SOCKS5Server(s);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
_log.debug("SOCKS protocol version not supported (" + Integer.toHexString(socksVer) + ")");
|
throw new SOCKSException("SOCKS protocol version not supported (" + Integer.toHexString(socksVer) + ")");
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
_log.debug("error reading SOCKS protocol version");
|
_log.debug("error reading SOCKS protocol version");
|
||||||
|
@ -31,9 +31,7 @@ public class EditBean extends IndexBean {
|
|||||||
if (controllers.size() > tunnel) {
|
if (controllers.size() > tunnel) {
|
||||||
TunnelController cur = (TunnelController)controllers.get(tunnel);
|
TunnelController cur = (TunnelController)controllers.get(tunnel);
|
||||||
if (cur == null) return false;
|
if (cur == null) return false;
|
||||||
return ( ("client".equals(cur.getType())) ||
|
return isClient(cur.getType());
|
||||||
("httpclient".equals(cur.getType()))||
|
|
||||||
("ircclient".equals(cur.getType())));
|
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -209,10 +209,7 @@ public class IndexBean {
|
|||||||
}
|
}
|
||||||
// Only modify other shared tunnels
|
// Only modify other shared tunnels
|
||||||
// if the current tunnel is shared, and of supported type
|
// if the current tunnel is shared, and of supported type
|
||||||
if ("true".equalsIgnoreCase(cur.getSharedClient()) &&
|
if ("true".equalsIgnoreCase(cur.getSharedClient()) && isClient(cur.getType())) {
|
||||||
("ircclient".equals(cur.getType()) ||
|
|
||||||
"httpclient".equals(cur.getType()) ||
|
|
||||||
"client".equals(cur.getType()))) {
|
|
||||||
// all clients use the same I2CP session, and as such, use the same I2CP options
|
// all clients use the same I2CP session, and as such, use the same I2CP options
|
||||||
List controllers = _group.getControllers();
|
List controllers = _group.getControllers();
|
||||||
|
|
||||||
@ -224,11 +221,7 @@ public class IndexBean {
|
|||||||
|
|
||||||
// Only modify this non-current tunnel
|
// Only modify this non-current tunnel
|
||||||
// if it belongs to a shared destination, and is of supported type
|
// if it belongs to a shared destination, and is of supported type
|
||||||
if ("true".equalsIgnoreCase(c.getSharedClient()) &&
|
if ("true".equalsIgnoreCase(c.getSharedClient()) && isClient(c.getType())) {
|
||||||
("httpclient".equals(c.getType()) ||
|
|
||||||
"ircclient".equals(c.getType()) ||
|
|
||||||
"client".equals(c.getType()))) {
|
|
||||||
|
|
||||||
Properties cOpt = c.getConfig("");
|
Properties cOpt = c.getConfig("");
|
||||||
if (_tunnelQuantity != null) {
|
if (_tunnelQuantity != null) {
|
||||||
cOpt.setProperty("option.inbound.quantity", _tunnelQuantity);
|
cOpt.setProperty("option.inbound.quantity", _tunnelQuantity);
|
||||||
@ -326,9 +319,14 @@ public class IndexBean {
|
|||||||
public boolean isClient(int tunnelNum) {
|
public boolean isClient(int tunnelNum) {
|
||||||
TunnelController cur = getController(tunnelNum);
|
TunnelController cur = getController(tunnelNum);
|
||||||
if (cur == null) return false;
|
if (cur == null) return false;
|
||||||
return ( ("client".equals(cur.getType())) ||
|
return isClient(cur.getType());
|
||||||
("httpclient".equals(cur.getType())) ||
|
}
|
||||||
("ircclient".equals(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) {
|
public String getTunnelName(int tunnel) {
|
||||||
@ -361,6 +359,7 @@ public class IndexBean {
|
|||||||
else if ("ircclient".equals(internalType)) return "IRC client";
|
else if ("ircclient".equals(internalType)) return "IRC client";
|
||||||
else if ("server".equals(internalType)) return "Standard server";
|
else if ("server".equals(internalType)) return "Standard server";
|
||||||
else if ("httpserver".equals(internalType)) return "HTTP server";
|
else if ("httpserver".equals(internalType)) return "HTTP server";
|
||||||
|
else if ("sockstunnel".equals(internalType)) return "SOCKS proxy";
|
||||||
else return internalType;
|
else return internalType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -579,77 +578,40 @@ public class IndexBean {
|
|||||||
Properties config = new Properties();
|
Properties config = new Properties();
|
||||||
updateConfigGeneric(config);
|
updateConfigGeneric(config);
|
||||||
|
|
||||||
if ("httpclient".equals(_type)) {
|
if (isClient(_type)) {
|
||||||
|
// generic client stuff
|
||||||
if (_port != null)
|
if (_port != null)
|
||||||
config.setProperty("listenPort", _port);
|
config.setProperty("listenPort", _port);
|
||||||
if (_reachableByOther != null)
|
if (_reachableByOther != null)
|
||||||
config.setProperty("interface", _reachableByOther);
|
config.setProperty("interface", _reachableByOther);
|
||||||
else
|
else
|
||||||
config.setProperty("interface", _reachableBy);
|
config.setProperty("interface", _reachableBy);
|
||||||
if (_proxyList != null)
|
config.setProperty("option.inbound.nickname", CLIENT_NICKNAME);
|
||||||
config.setProperty("proxyList", _proxyList);
|
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) {
|
if (_name != null && !_sharedClient) {
|
||||||
config.setProperty("option.inbound.nickname", _name);
|
config.setProperty("option.inbound.nickname", _name);
|
||||||
config.setProperty("option.outbound.nickname", _name);
|
config.setProperty("option.outbound.nickname", _name);
|
||||||
}
|
}
|
||||||
|
|
||||||
config.setProperty("sharedClient", _sharedClient + "");
|
config.setProperty("sharedClient", _sharedClient + "");
|
||||||
}else if ("ircclient".equals(_type)) {
|
} else {
|
||||||
if (_port != null)
|
// generic server stuff
|
||||||
config.setProperty("listenPort", _port);
|
if (_targetHost != null)
|
||||||
if (_reachableByOther != null)
|
config.setProperty("targetHost", _targetHost);
|
||||||
config.setProperty("interface", _reachableByOther);
|
if (_targetPort != null)
|
||||||
else
|
config.setProperty("targetPort", _targetPort);
|
||||||
config.setProperty("interface", _reachableBy);
|
if (_privKeyFile != null)
|
||||||
if (_targetDestination != null)
|
config.setProperty("privKeyFile", _privKeyFile);
|
||||||
config.setProperty("targetDestination", _targetDestination);
|
}
|
||||||
|
|
||||||
config.setProperty("option.inbound.nickname", CLIENT_NICKNAME);
|
if ("httpclient".equals(_type)) {
|
||||||
config.setProperty("option.outbound.nickname", CLIENT_NICKNAME);
|
if (_proxyList != null)
|
||||||
if (_name != null && !_sharedClient) {
|
config.setProperty("proxyList", _proxyList);
|
||||||
config.setProperty("option.inbound.nickname", _name);
|
} else if ("ircclient".equals(_type) || "client".equals(_type)) {
|
||||||
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 (_targetDestination != null)
|
if (_targetDestination != null)
|
||||||
config.setProperty("targetDestination", _targetDestination);
|
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)) {
|
} 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)
|
if (_spoofedHost != null)
|
||||||
config.setProperty("spoofedHost", _spoofedHost);
|
config.setProperty("spoofedHost", _spoofedHost);
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
|
@ -14,7 +14,7 @@ String tun = request.getParameter("tunnel");
|
|||||||
} else {
|
} else {
|
||||||
String type = request.getParameter("type");
|
String type = request.getParameter("type");
|
||||||
int curTunnel = -1;
|
int curTunnel = -1;
|
||||||
if ("client".equals(type) || "httpclient".equals(type) || "ircclient".equals(type)) {
|
if (EditBean.isClient(type)) {
|
||||||
%><jsp:include page="editClient.jsp" /><%
|
%><jsp:include page="editClient.jsp" /><%
|
||||||
} else if ("server".equals(type) || "httpserver".equals(type)) {
|
} else if ("server".equals(type) || "httpserver".equals(type)) {
|
||||||
%><jsp:include page="editServer.jsp" /><%
|
%><jsp:include page="editServer.jsp" /><%
|
||||||
|
@ -116,14 +116,14 @@
|
|||||||
<hr />
|
<hr />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% if ("httpclient".equals(editBean.getInternalType(curTunnel))) {
|
<% if ("httpclient".equals(tunnelType)) {
|
||||||
%><div id="destinationField" class="rowItem">
|
%><div id="destinationField" class="rowItem">
|
||||||
<label for="proxyList" accesskey="x">
|
<label for="proxyList" accesskey="x">
|
||||||
Outpro<span class="accessKey">x</span>ies:
|
Outpro<span class="accessKey">x</span>ies:
|
||||||
</label>
|
</label>
|
||||||
<input type="text" size="30" id="proxyList" name="proxyList" title="List of Outproxy I2P destinations" value="<%=editBean.getClientDestination(curTunnel)%>" class="freetext" />
|
<input type="text" size="30" id="proxyList" name="proxyList" title="List of Outproxy I2P destinations" value="<%=editBean.getClientDestination(curTunnel)%>" class="freetext" />
|
||||||
</div>
|
</div>
|
||||||
<% } else {
|
<% } else if ("client".equals(tunnelType) || "ircclient".equals(tunnelType)) {
|
||||||
%><div id="destinationField" class="rowItem">
|
%><div id="destinationField" class="rowItem">
|
||||||
<label for="targetDestination" accesskey="T">
|
<label for="targetDestination" accesskey="T">
|
||||||
<span class="accessKey">T</span>unnel Destination:
|
<span class="accessKey">T</span>unnel Destination:
|
||||||
@ -205,7 +205,7 @@
|
|||||||
<span class="accessKey">V</span>ariance:
|
<span class="accessKey">V</span>ariance:
|
||||||
</label>
|
</label>
|
||||||
<select id="tunnelVariance" name="tunnelVariance" title="Level of Randomization for Tunnel Depth" class="selectbox">
|
<select id="tunnelVariance" name="tunnelVariance" title="Level of Randomization for Tunnel Depth" class="selectbox">
|
||||||
<% int tunnelVariance = editBean.getTunnelVariance(curTunnel, -1);
|
<% int tunnelVariance = editBean.getTunnelVariance(curTunnel, 0);
|
||||||
%><option value="0"<%=(tunnelVariance == 0 ? " selected=\"selected\"" : "") %>>0 hop variance (no randomisation, consistant performance)</option>
|
%><option value="0"<%=(tunnelVariance == 0 ? " selected=\"selected\"" : "") %>>0 hop variance (no randomisation, consistant performance)</option>
|
||||||
<option value="1"<%=(tunnelVariance == 1 ? " selected=\"selected\"" : "") %>>+ 0-1 hop variance (medium additive randomisation, subtractive performance)</option>
|
<option value="1"<%=(tunnelVariance == 1 ? " selected=\"selected\"" : "") %>>+ 0-1 hop variance (medium additive randomisation, subtractive performance)</option>
|
||||||
<option value="2"<%=(tunnelVariance == 2 ? " selected=\"selected\"" : "") %>>+ 0-2 hop variance (high additive randomisation, subtractive performance)</option>
|
<option value="2"<%=(tunnelVariance == 2 ? " selected=\"selected\"" : "") %>>+ 0-2 hop variance (high additive randomisation, subtractive performance)</option>
|
||||||
|
@ -112,10 +112,12 @@
|
|||||||
}
|
}
|
||||||
%></div>
|
%></div>
|
||||||
|
|
||||||
|
<% if (!"sockstunnel".equals(indexBean.getInternalType(curClient))) { %>
|
||||||
<div class="destinationField rowItem">
|
<div class="destinationField rowItem">
|
||||||
<label>Destination:</label>
|
<label>Destination:</label>
|
||||||
<input class="freetext" size="40" readonly="readonly" value="<%=indexBean.getClientDestination(curClient)%>" />
|
<input class="freetext" size="40" readonly="readonly" value="<%=indexBean.getClientDestination(curClient)%>" />
|
||||||
</div>
|
</div>
|
||||||
|
<% } %>
|
||||||
|
|
||||||
<div class="descriptionField rowItem">
|
<div class="descriptionField rowItem">
|
||||||
<label>Description:</label>
|
<label>Description:</label>
|
||||||
@ -140,6 +142,7 @@
|
|||||||
<option value="client">Standard</option>
|
<option value="client">Standard</option>
|
||||||
<option value="httpclient">HTTP</option>
|
<option value="httpclient">HTTP</option>
|
||||||
<option value="ircclient">IRC</option>
|
<option value="ircclient">IRC</option>
|
||||||
|
<option value="sockstunnel">SOCKS</option>
|
||||||
</select>
|
</select>
|
||||||
<input class="control" type="submit" value="Create" />
|
<input class="control" type="submit" value="Create" />
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user