laptop mode

This commit is contained in:
zzz
2010-01-02 02:46:23 +00:00
parent 2d5decd943
commit 5ed29b6c27
7 changed files with 75 additions and 11 deletions

View File

@ -4,7 +4,7 @@ import net.i2p.router.Router;
import net.i2p.router.transport.FIFOBandwidthRefiller;
import net.i2p.router.transport.TransportManager;
import net.i2p.router.transport.udp.UDPTransport;
import net.i2p.router.web.ConfigServiceHandler.UpdateWrapperManagerAndRekeyTask;
import net.i2p.router.web.ConfigServiceHandler;
/**
* Handler to deal with form submissions from the main config form and act
@ -30,6 +30,7 @@ public class ConfigNetHandler extends FormHandler {
private String _ntcpAutoIP;
private boolean _ntcpAutoPort;
private boolean _upnp;
private boolean _laptop;
private String _inboundRate;
private String _inboundBurstRate;
private String _inboundBurst;
@ -70,6 +71,7 @@ public class ConfigNetHandler extends FormHandler {
_ntcpAutoPort = mode.equals("2");
}
public void setUpnp(String moo) { _upnp = true; }
public void setLaptop(String moo) { _laptop = true; }
public void setHostname(String hostname) {
_hostname = (hostname != null ? hostname.trim() : null);
@ -230,6 +232,16 @@ public class ConfigNetHandler extends FormHandler {
}
_context.router().setConfigSetting(TransportManager.PROP_ENABLE_UPNP, "" + _upnp);
if (Boolean.valueOf(_context.getProperty(UDPTransport.PROP_LAPTOP_MODE)).booleanValue() !=
_laptop) {
// This is minor, don't set restartRequired
if (_laptop)
addFormNotice(_("Enabling laptop mode"));
else
addFormNotice(_("Disabling laptop mode"));
}
_context.router().setConfigSetting(UDPTransport.PROP_LAPTOP_MODE, "" + _laptop);
if (_requireIntroductions) {
_context.router().setConfigSetting(UDPTransport.PROP_FORCE_INTRODUCERS, "true");
addFormNotice(_("Requiring SSU introducers"));
@ -274,6 +286,7 @@ public class ConfigNetHandler extends FormHandler {
// There's a few changes that don't really require restart (e.g. enabling inbound TCP)
// But it would be hard to get right, so just do a restart.
addFormError(_("Gracefully restarting I2P to change published router address"));
_context.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_GRACEFUL_RESTART));
_context.router().shutdownGracefully(Router.EXIT_GRACEFUL_RESTART);
}
}
@ -281,7 +294,7 @@ public class ConfigNetHandler extends FormHandler {
private void hiddenSwitch() {
// Full restart required to generate new keys
_context.addShutdownTask(new UpdateWrapperManagerAndRekeyTask(Router.EXIT_GRACEFUL_RESTART));
_context.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerAndRekeyTask(Router.EXIT_GRACEFUL_RESTART));
_context.router().shutdownGracefully(Router.EXIT_GRACEFUL_RESTART);
}

View File

@ -84,6 +84,10 @@ public class ConfigNetHelper extends HelperBase {
return getChecked(Router.PROP_DYNAMIC_KEYS);
}
public String getLaptopChecked() {
return getChecked(UDPTransport.PROP_LAPTOP_MODE);
}
public String getTcpAutoPortChecked(int mode) {
String port = _context.getProperty(PROP_I2NP_NTCP_PORT);
boolean specified = port != null && port.length() > 0;