forked from I2P_Developers/i2p.i2p
propagate from branch 'i2p.i2p' (head e014bb054baa0d8e844e9a97ad6f5b04ed7c0e56)
to branch 'i2p.i2p.zzz.test' (head 1e0af137b9c4c873fea72d661f2ee351a640734f)
This commit is contained in:
@@ -455,9 +455,15 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
|
||||
!Boolean.valueOf(getTunnel().getClientOptions().getProperty(PROP_DISABLE_HELPER)).booleanValue()) {
|
||||
pos2 = fragment.indexOf("=");
|
||||
ahelperKey = fragment.substring(pos2 + 1);
|
||||
|
||||
// Key contains data, lets not ignore it
|
||||
if (ahelperKey != null) {
|
||||
if(ahelperKey.endsWith(".b32.i2p")) {
|
||||
// allow i2paddresshelper=<b32>.b32.i2p syntax.
|
||||
Destination dest = _context.namingService().lookup(ahelperKey);
|
||||
if(dest==null)
|
||||
throw new RuntimeException("Could not find destination for "+ahelperKey);
|
||||
ahelperKey = dest.toBase64();
|
||||
}
|
||||
ahelperPresent = true;
|
||||
// ahelperKey will be validated later
|
||||
if (host == null || "i2p".equals(host)) {
|
||||
|
@@ -8,6 +8,7 @@ package net.i2p.i2ptunnel.web;
|
||||
*
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -31,6 +32,7 @@ import net.i2p.i2ptunnel.I2PTunnelIRCClient;
|
||||
import net.i2p.i2ptunnel.TunnelController;
|
||||
import net.i2p.i2ptunnel.TunnelControllerGroup;
|
||||
import net.i2p.util.ConcurrentHashSet;
|
||||
import net.i2p.util.FileUtil;
|
||||
import net.i2p.util.Log;
|
||||
|
||||
/**
|
||||
@@ -41,9 +43,9 @@ import net.i2p.util.Log;
|
||||
* Usage by classes outside of i2ptunnel.war is deprecated.
|
||||
*/
|
||||
public class IndexBean {
|
||||
protected I2PAppContext _context;
|
||||
protected Log _log;
|
||||
protected TunnelControllerGroup _group;
|
||||
protected final I2PAppContext _context;
|
||||
protected final Log _log;
|
||||
protected final TunnelControllerGroup _group;
|
||||
private String _action;
|
||||
private int _tunnel;
|
||||
//private long _prevNonce;
|
||||
@@ -75,8 +77,8 @@ public class IndexBean {
|
||||
private boolean _sharedClient;
|
||||
private boolean _privKeyGenerate;
|
||||
private boolean _removeConfirmed;
|
||||
private Set<String> _booleanOptions;
|
||||
private Map<String, String> _otherOptions;
|
||||
private final Set<String> _booleanOptions;
|
||||
private final Map<String, String> _otherOptions;
|
||||
private int _hashCashValue;
|
||||
private int _certType;
|
||||
private String _certSigner;
|
||||
@@ -199,17 +201,17 @@ public class IndexBean {
|
||||
}
|
||||
private String stopAll() {
|
||||
if (_group == null) return "";
|
||||
List msgs = _group.stopAllControllers();
|
||||
List<String> msgs = _group.stopAllControllers();
|
||||
return getMessages(msgs);
|
||||
}
|
||||
private String startAll() {
|
||||
if (_group == null) return "";
|
||||
List msgs = _group.startAllControllers();
|
||||
List<String> msgs = _group.startAllControllers();
|
||||
return getMessages(msgs);
|
||||
}
|
||||
private String restartAll() {
|
||||
if (_group == null) return "";
|
||||
List msgs = _group.restartAllControllers();
|
||||
List<String> msgs = _group.restartAllControllers();
|
||||
return getMessages(msgs);
|
||||
}
|
||||
private String reloadConfig() {
|
||||
@@ -317,6 +319,10 @@ public class IndexBean {
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the tunnel, delete from config,
|
||||
* rename the private key file if in the default directory
|
||||
*/
|
||||
private String deleteTunnel() {
|
||||
if (!_removeConfirmed)
|
||||
return "Please confirm removal";
|
||||
@@ -325,8 +331,38 @@ public class IndexBean {
|
||||
if (cur == null)
|
||||
return "Invalid tunnel number";
|
||||
|
||||
List msgs = _group.removeController(cur);
|
||||
List<String> msgs = _group.removeController(cur);
|
||||
msgs.addAll(doSave());
|
||||
|
||||
// Rename private key file if it was a default name in
|
||||
// the default directory, so it doesn't get reused when a new
|
||||
// tunnel is created.
|
||||
// Use configured file name if available, not the one from the form.
|
||||
String pk = cur.getPrivKeyFile();
|
||||
if (pk == null)
|
||||
pk = _privKeyFile;
|
||||
if (pk != null && pk.startsWith("i2ptunnel") && pk.endsWith("-privKeys.dat")) {
|
||||
File pkf = new File(_context.getConfigDir(), pk);
|
||||
if (pkf.exists()) {
|
||||
String name = cur.getName();
|
||||
if (name == null) {
|
||||
name = cur.getDescription();
|
||||
if (name == null) {
|
||||
name = cur.getType();
|
||||
if (name == null)
|
||||
name = Long.toString(_context.clock().now());
|
||||
}
|
||||
}
|
||||
name = "i2ptunnel-deleted-" + name.replace(' ', '_') + "-privkeys.dat";
|
||||
File to = new File(_context.getConfigDir(), name);
|
||||
if (to.exists())
|
||||
to = new File(_context.getConfigDir(), name + '-' + _context.clock().now());
|
||||
boolean success = FileUtil.rename(pkf, to);
|
||||
if (success)
|
||||
msgs.add("Private key file " + pkf.getAbsolutePath() +
|
||||
" renamed to " + to.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
return getMessages(msgs);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user