Router, i2ptunnel: Add option for per-pool persistent random key,

so peer ordering does not change across restarts
This commit is contained in:
zzz
2014-11-09 13:51:19 +00:00
parent 2d3e8e0c4e
commit ae1d5648d5
3 changed files with 46 additions and 3 deletions

View File

@@ -25,6 +25,7 @@ import net.i2p.I2PAppContext;
import net.i2p.app.ClientAppManager;
import net.i2p.app.Outproxy;
import net.i2p.client.I2PClient;
import net.i2p.data.Base64;
import net.i2p.data.Certificate;
import net.i2p.data.DataHelper;
import net.i2p.data.Destination;
@@ -1331,6 +1332,20 @@ public class IndexBean {
}
}
// As of 0.9.17, add a persistent random key if not present
if (!isClient(_type) || _booleanOptions.contains("persistentClientKey")) {
String p = OPT + "inbound.randomKey";
if (!config.containsKey(p)) {
// as of 0.9.17, add a random key if not previously present
byte[] rk = new byte[32];
_context.random().nextBytes(rk);
config.setProperty(OPT + p, Base64.encode(rk));
p = OPT + "outbound.randomKey";
_context.random().nextBytes(rk);
config.setProperty(OPT + p, Base64.encode(rk));
}
}
return config;
}