* I2PTunnel: Enable persistent keying for SOCKS tunnels (ticket #1088)

This commit is contained in:
dg2-new
2013-10-28 19:15:46 +00:00
parent f0f363e8c3
commit 626daeb86e
4 changed files with 15 additions and 7 deletions

View File

@@ -954,12 +954,12 @@ public class I2PTunnel extends EventDispatcherImpl implements Logging {
* "openSOCKSTunnelResult" = "ok" or "error" after the client tunnel has
* started.
*
* @param args {portNumber [, sharedClient]}
* @param args {portNumber [, sharedClient]} or (portNumber, ignored (false), privKeyFile)
* @param l logger to receive events and output
* @throws IllegalArgumentException on config problem
*/
public void runSOCKSTunnel(String args[], Logging l) {
if (args.length >= 1 && args.length <= 2) {
if (args.length >= 1 && args.length <= 3) {
int _port = -1;
try {
_port = Integer.parseInt(args[0]);
@@ -972,12 +972,15 @@ public class I2PTunnel extends EventDispatcherImpl implements Logging {
throw new IllegalArgumentException(getPrefix() + "Bad port " + args[0]);
boolean isShared = false;
if (args.length > 1)
if (args.length == 2)
isShared = Boolean.parseBoolean(args[1].trim());
ownDest = !isShared;
String privateKeyFile = null;
if (args.length == 3)
privateKeyFile = args[2];
try {
I2PTunnelTask task = new I2PSOCKSTunnel(_port, l, ownDest, this, this, null);
I2PTunnelTask task = new I2PSOCKSTunnel(_port, l, ownDest, this, this, privateKeyFile);
addtask(task);
notifyEvent("sockstunnelTaskId", Integer.valueOf(task.getId()));
} catch (IllegalArgumentException iae) {

View File

@@ -263,7 +263,12 @@ public class TunnelController implements Logging {
if (!props.containsKey(I2PSOCKSTunnel.PROP_PROXY_DEFAULT))
props.setProperty(I2PSOCKSTunnel.PROP_PROXY_DEFAULT, proxyList);
}
_tunnel.runSOCKSTunnel(new String[] { listenPort, sharedClient }, this);
if (getPersistentClientKey()) {
String privKeyFile = getPrivKeyFile();
_tunnel.runSOCKSTunnel(new String[] { listenPort, "false", privKeyFile }, this);
} else {
_tunnel.runSOCKSTunnel(new String[] { listenPort, sharedClient }, this);
}
}
/** @since 0.7.12 */