forked from I2P_Developers/i2p.i2p
i2ptunnel: Allow alt priv key file to be added without restarting I2P
Display message requiring tunnel restart if tunnel is running
This commit is contained in:
@@ -159,9 +159,9 @@ public class TunnelController implements Logging {
|
|||||||
setConfig(config, prefix);
|
setConfig(config, prefix);
|
||||||
_messages = new ArrayList<String>(4);
|
_messages = new ArrayList<String>(4);
|
||||||
boolean keyOK = true;
|
boolean keyOK = true;
|
||||||
if (createKey && (getType().endsWith("server") || getPersistentClientKey())) {
|
if (createKey && (!isClient() || getPersistentClientKey())) {
|
||||||
keyOK = createPrivateKey();
|
keyOK = createPrivateKey();
|
||||||
if (keyOK && getType().endsWith("server") && !getType().equals(TYPE_STREAMR_SERVER)) {
|
if (keyOK && !isClient() && !getType().equals(TYPE_STREAMR_SERVER)) {
|
||||||
// check rv?
|
// check rv?
|
||||||
createAltPrivateKey();
|
createAltPrivateKey();
|
||||||
}
|
}
|
||||||
@@ -380,13 +380,17 @@ public class TunnelController implements Logging {
|
|||||||
}
|
}
|
||||||
// Config options may have changed since instantiation, so do this again.
|
// Config options may have changed since instantiation, so do this again.
|
||||||
// Or should we take it out of the constructor completely?
|
// Or should we take it out of the constructor completely?
|
||||||
if (type.endsWith("server") || getPersistentClientKey()) {
|
if (!isClient() || getPersistentClientKey()) {
|
||||||
boolean ok = createPrivateKey();
|
boolean ok = createPrivateKey();
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
changeState(TunnelState.STOPPED);
|
changeState(TunnelState.STOPPED);
|
||||||
log("Failed to start tunnel " + getName() + " as the private key file could not be created");
|
log("Failed to start tunnel " + getName() + " as the private key file could not be created");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!isClient() && !getType().equals(TYPE_STREAMR_SERVER)) {
|
||||||
|
// check rv?
|
||||||
|
createAltPrivateKey();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setI2CPOptions();
|
setI2CPOptions();
|
||||||
setSessionOptions();
|
setSessionOptions();
|
||||||
@@ -754,6 +758,7 @@ public class TunnelController implements Logging {
|
|||||||
props.setProperty(key, val);
|
props.setProperty(key, val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Properties oldConfig = _config;
|
||||||
_config = props;
|
_config = props;
|
||||||
|
|
||||||
// Set up some per-type defaults
|
// Set up some per-type defaults
|
||||||
@@ -798,6 +803,15 @@ public class TunnelController implements Logging {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (oldConfig != null) {
|
||||||
|
if (configChanged(_config, oldConfig, PROP_FILE) ||
|
||||||
|
configChanged(_config, oldConfig, OPT_ALT_PKF) ||
|
||||||
|
configChanged(_config, oldConfig, OPT_SIG_TYPE)) {
|
||||||
|
log("Tunnel must be stopped and restarted for private key file changes to take effect");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Running, so check sessions
|
// Running, so check sessions
|
||||||
Collection<I2PSession> sessions = getAllSessions();
|
Collection<I2PSession> sessions = getAllSessions();
|
||||||
if (sessions.isEmpty()) {
|
if (sessions.isEmpty()) {
|
||||||
@@ -817,6 +831,17 @@ public class TunnelController implements Logging {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is property p different in p1 and p2?
|
||||||
|
* @since 0.9.30
|
||||||
|
*/
|
||||||
|
private static boolean configChanged(Properties p1, Properties p2, String p) {
|
||||||
|
String s1 = p1.getProperty(p);
|
||||||
|
String s2 = p2.getProperty(p);
|
||||||
|
return (s1 != null && !s1.equals(s2)) ||
|
||||||
|
(s1 == null && s2 != null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a copy
|
* @return a copy
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user