persist bandwidth slider setting across restarts

pull/13/head
knaccc 5 years ago
parent edbe1ac938
commit 903f96d0b4

@ -315,8 +315,6 @@ public class Controller {
var params = Gui.instance.getParameters().getNamed();
Properties routerProperties = new Properties();
routerProperties.put("i2np.inboundKBytesPerSecond", getBandwidthLimitKBPerSec());
routerProperties.put("i2np.outboundKBytesPerSecond", getBandwidthLimitKBPerSec());
routerProperties.put("router.sharePercentage", 80);
params.entrySet().stream().forEach(e->routerProperties.put(e.getKey(), e.getValue()));
routerWrapper = new RouterWrapper(routerProperties);

@ -16,12 +16,9 @@ public class Main {
"Press Ctrl-C to gracefully shut down the router (or send the SIGINT signal to the process).");
Properties p = new Properties();
// bandwidth limits in K bytes per second
p.put("i2np.inboundKBytesPerSecond","50");
p.put("i2np.outboundKBytesPerSecond","50");
p.put("router.sharePercentage","80");
// allow default properties to be overridden via command line args, e.g. --i2p.dir.base=/usr/share/i2p
// allow default properties to be added via command line args, e.g. --i2p.dir.base=/usr/share/i2p
for(var arg : args) {
if(arg.startsWith("--")) {
String[] s = arg.split("=");

@ -28,11 +28,15 @@ public class RouterWrapper {
private File i2PConfigDir;
private File i2PBaseDir;
public RouterWrapper(Properties p) {
this.routerProperties = p;
public RouterWrapper(Properties routerProperties) {
this.routerProperties = routerProperties;
p.put("i2p.dir.base", System.getProperty("user.home") + File.separator + ".i2p-zero" + File.separator + "base");
p.put("i2p.dir.config", System.getProperty("user.home") + File.separator + ".i2p-zero" + File.separator + "config");
int bandwidthLimitKBps = loadBandwidthLimitKBps();
routerProperties.put("i2np.inboundKBytesPerSecond", bandwidthLimitKBps);
routerProperties.put("i2np.outboundKBytesPerSecond", bandwidthLimitKBps);
routerProperties.put("i2p.dir.base", System.getProperty("user.home") + File.separator + ".i2p-zero" + File.separator + "base");
routerProperties.put("i2p.dir.config", System.getProperty("user.home") + File.separator + ".i2p-zero" + File.separator + "config");
i2PConfigDir = new File(routerProperties.getProperty("i2p.dir.config"));
if(!i2PConfigDir.exists()) i2PConfigDir.mkdirs();
@ -87,8 +91,6 @@ public class RouterWrapper {
}
}
updateBandwidthLimitKBps(loadBandwidthLimitKBps());
tunnelControl = new TunnelControl(this, i2PConfigDir, new File(i2PConfigDir, "tunnelTemp"));
new Thread(tunnelControl).start();

Loading…
Cancel
Save