2004-07-31 02:34:24 +00:00
|
|
|
package net.i2p.router.web;
|
|
|
|
|
2005-11-26 09:16:11 +00:00
|
|
|
import net.i2p.data.RouterInfo;
|
2008-07-16 13:42:54 +00:00
|
|
|
import net.i2p.router.Router;
|
2008-12-03 18:53:57 +00:00
|
|
|
import net.i2p.router.transport.FIFOBandwidthRefiller;
|
2009-04-28 19:49:09 +00:00
|
|
|
import net.i2p.router.transport.TransportManager;
|
2008-07-16 13:42:54 +00:00
|
|
|
import net.i2p.router.transport.udp.UDPTransport;
|
2005-11-26 09:16:11 +00:00
|
|
|
import net.i2p.router.web.ConfigServiceHandler.UpdateWrapperManagerAndRekeyTask;
|
2008-07-16 13:42:54 +00:00
|
|
|
import net.i2p.time.Timestamper;
|
2004-07-31 02:34:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handler to deal with form submissions from the main config form and act
|
|
|
|
* upon the values.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public class ConfigNetHandler extends FormHandler {
|
|
|
|
private String _hostname;
|
|
|
|
private boolean _reseedRequested;
|
|
|
|
private boolean _saveRequested;
|
2005-08-10 23:55:40 +00:00
|
|
|
private boolean _recheckReachabilityRequested;
|
2004-07-31 02:34:24 +00:00
|
|
|
private boolean _timeSyncEnabled;
|
2005-09-13 00:11:56 +00:00
|
|
|
private boolean _requireIntroductions;
|
2005-11-26 09:16:11 +00:00
|
|
|
private boolean _hiddenMode;
|
|
|
|
private boolean _dynamicKeys;
|
2006-07-04 21:17:44 +00:00
|
|
|
private String _ntcpHostname;
|
|
|
|
private String _ntcpPort;
|
2005-07-27 19:03:43 +00:00
|
|
|
private String _tcpPort;
|
2009-05-01 00:42:31 +00:00
|
|
|
private String _udpHost1;
|
|
|
|
private String _udpHost2;
|
2005-07-27 19:03:43 +00:00
|
|
|
private String _udpPort;
|
2009-05-01 00:42:31 +00:00
|
|
|
private String _udpAutoIP;
|
2009-04-30 21:03:00 +00:00
|
|
|
private String _ntcpAutoIP;
|
2007-07-07 20:03:50 +00:00
|
|
|
private boolean _ntcpAutoPort;
|
2009-04-28 19:49:09 +00:00
|
|
|
private boolean _upnp;
|
2004-07-31 02:34:24 +00:00
|
|
|
private String _inboundRate;
|
2005-09-17 23:01:44 +00:00
|
|
|
private String _inboundBurstRate;
|
2004-07-31 02:34:24 +00:00
|
|
|
private String _inboundBurst;
|
|
|
|
private String _outboundRate;
|
2005-09-17 23:01:44 +00:00
|
|
|
private String _outboundBurstRate;
|
2004-07-31 02:34:24 +00:00
|
|
|
private String _outboundBurst;
|
|
|
|
private String _reseedFrom;
|
2006-02-16 10:33:29 +00:00
|
|
|
private boolean _enableLoadTesting;
|
2005-02-16 jrandom
* (Merged the 0.5-pre branch back into CVS HEAD)
* Replaced the old tunnel routing crypto with the one specified in
router/doc/tunnel-alt.html, including updates to the web console to view
and tweak it.
* Provide the means for routers to reject tunnel requests with a wider
range of responses:
probabalistic rejection, due to approaching overload
transient rejection, due to temporary overload
bandwidth rejection, due to persistent bandwidth overload
critical rejection, due to general router fault (or imminent shutdown)
The different responses are factored into the profiles accordingly.
* Replaced the old I2CP tunnel related options (tunnels.depthInbound, etc)
with a series of new properties, relevent to the new tunnel routing code:
inbound.nickname (used on the console)
inbound.quantity (# of tunnels to use in any leaseSets)
inbound.backupQuantity (# of tunnels to keep in the ready)
inbound.length (# of remote peers in the tunnel)
inbound.lengthVariance (if > 0, permute the length by adding a random #
up to the variance. if < 0, permute the length
by adding or subtracting a random # up to the
variance)
outbound.* (same as the inbound, except for the, uh, outbound tunnels
in that client's pool)
There are other options, and more will be added later, but the above are
the most relevent ones.
* Replaced Jetty 4.2.21 with Jetty 5.1.2
* Compress all profile data on disk.
* Adjust the reseeding functionality to work even when the JVM's http proxy
is set.
* Enable a poor-man's interactive-flow in the streaming lib by choking the
max window size.
* Reduced the default streaming lib max message size to 16KB (though still
configurable by the user), also doubling the default maximum window
size.
* Replaced the RouterIdentity in a Lease with its SHA256 hash.
* Reduced the overall I2NP message checksum from a full 32 byte SHA256 to
the first byte of the SHA256.
* Added a new "netId" flag to let routers drop references to other routers
who we won't be able to talk to.
* Extended the timestamper to get a second (or third) opinion whenever it
wants to actually adjust the clock offset.
* Replaced that kludge of a timestamp I2NP message with a full blown
DateMessage.
* Substantial memory optimizations within the router and the SDK to reduce
GC churn. Client apps and the streaming libs have not been tuned,
however.
* More bugfixes thank you can shake a stick at.
2005-02-13 jrandom
* Updated jbigi source to handle 64bit CPUs. The bundled jbigi.jar still
only contains 32bit versions, so build your own, placing libjbigi.so in
your install dir if necessary. (thanks mule!)
* Added support for libjbigi-$os-athlon64 to NativeBigInteger and CPUID
(thanks spaetz!)
2005-02-16 22:23:47 +00:00
|
|
|
private String _sharePct;
|
2009-05-10 15:40:50 +00:00
|
|
|
private static final boolean _ratesOnly = false; // always false - delete me
|
2009-05-01 00:42:31 +00:00
|
|
|
private static final String PROP_HIDDEN = Router.PROP_HIDDEN_HIDDEN; // see Router for other choice
|
2004-07-31 02:34:24 +00:00
|
|
|
|
|
|
|
protected void processForm() {
|
2007-01-21 03:35:49 +00:00
|
|
|
if (_saveRequested || ( (_action != null) && ("Save changes".equals(_action)) )) {
|
2004-07-31 02:34:24 +00:00
|
|
|
saveChanges();
|
2005-08-10 23:55:40 +00:00
|
|
|
} else if (_recheckReachabilityRequested) {
|
|
|
|
recheckReachability();
|
2004-07-31 02:34:24 +00:00
|
|
|
} else {
|
|
|
|
// noop
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSave(String moo) { _saveRequested = true; }
|
|
|
|
public void setEnabletimesync(String moo) { _timeSyncEnabled = true; }
|
2005-08-10 23:55:40 +00:00
|
|
|
public void setRecheckReachability(String moo) { _recheckReachabilityRequested = true; }
|
2005-09-13 00:11:56 +00:00
|
|
|
public void setRequireIntroductions(String moo) { _requireIntroductions = true; }
|
2005-11-26 09:16:11 +00:00
|
|
|
public void setDynamicKeys(String moo) { _dynamicKeys = true; }
|
2006-02-16 10:33:29 +00:00
|
|
|
public void setEnableloadtesting(String moo) { _enableLoadTesting = true; }
|
2009-05-01 00:42:31 +00:00
|
|
|
public void setUdpAutoIP(String mode) {
|
|
|
|
_udpAutoIP = mode;
|
|
|
|
_hiddenMode = "hidden".equals(mode);
|
|
|
|
}
|
2009-04-28 22:45:26 +00:00
|
|
|
public void setNtcpAutoIP(String mode) {
|
2009-04-30 21:03:00 +00:00
|
|
|
_ntcpAutoIP = mode;
|
2009-04-28 22:45:26 +00:00
|
|
|
}
|
|
|
|
public void setNtcpAutoPort(String mode) {
|
|
|
|
_ntcpAutoPort = mode.equals("2");
|
|
|
|
}
|
2009-04-28 19:49:09 +00:00
|
|
|
public void setUpnp(String moo) { _upnp = true; }
|
2004-07-31 02:34:24 +00:00
|
|
|
|
|
|
|
public void setHostname(String hostname) {
|
|
|
|
_hostname = (hostname != null ? hostname.trim() : null);
|
|
|
|
}
|
2005-07-27 19:03:43 +00:00
|
|
|
public void setTcpPort(String port) {
|
|
|
|
_tcpPort = (port != null ? port.trim() : null);
|
|
|
|
}
|
2006-07-04 21:17:44 +00:00
|
|
|
public void setNtcphost(String host) {
|
|
|
|
_ntcpHostname = (host != null ? host.trim() : null);
|
|
|
|
}
|
|
|
|
public void setNtcpport(String port) {
|
|
|
|
_ntcpPort = (port != null ? port.trim() : null);
|
|
|
|
}
|
2009-05-01 00:42:31 +00:00
|
|
|
public void setUdpHost1(String host) {
|
|
|
|
_udpHost1 = (host != null ? host.trim() : null);
|
|
|
|
}
|
|
|
|
public void setUdpHost2(String host) {
|
|
|
|
_udpHost2 = (host != null ? host.trim() : null);
|
|
|
|
}
|
2005-07-27 19:03:43 +00:00
|
|
|
public void setUdpPort(String port) {
|
|
|
|
_udpPort = (port != null ? port.trim() : null);
|
2004-07-31 02:34:24 +00:00
|
|
|
}
|
|
|
|
public void setInboundrate(String rate) {
|
|
|
|
_inboundRate = (rate != null ? rate.trim() : null);
|
|
|
|
}
|
2005-09-17 23:01:44 +00:00
|
|
|
public void setInboundburstrate(String rate) {
|
|
|
|
_inboundBurstRate = (rate != null ? rate.trim() : null);
|
|
|
|
}
|
2004-07-31 02:34:24 +00:00
|
|
|
public void setInboundburstfactor(String factor) {
|
|
|
|
_inboundBurst = (factor != null ? factor.trim() : null);
|
|
|
|
}
|
|
|
|
public void setOutboundrate(String rate) {
|
|
|
|
_outboundRate = (rate != null ? rate.trim() : null);
|
|
|
|
}
|
2005-09-17 23:01:44 +00:00
|
|
|
public void setOutboundburstrate(String rate) {
|
|
|
|
_outboundBurstRate = (rate != null ? rate.trim() : null);
|
|
|
|
}
|
2004-07-31 02:34:24 +00:00
|
|
|
public void setOutboundburstfactor(String factor) {
|
|
|
|
_outboundBurst = (factor != null ? factor.trim() : null);
|
|
|
|
}
|
2005-02-16 jrandom
* (Merged the 0.5-pre branch back into CVS HEAD)
* Replaced the old tunnel routing crypto with the one specified in
router/doc/tunnel-alt.html, including updates to the web console to view
and tweak it.
* Provide the means for routers to reject tunnel requests with a wider
range of responses:
probabalistic rejection, due to approaching overload
transient rejection, due to temporary overload
bandwidth rejection, due to persistent bandwidth overload
critical rejection, due to general router fault (or imminent shutdown)
The different responses are factored into the profiles accordingly.
* Replaced the old I2CP tunnel related options (tunnels.depthInbound, etc)
with a series of new properties, relevent to the new tunnel routing code:
inbound.nickname (used on the console)
inbound.quantity (# of tunnels to use in any leaseSets)
inbound.backupQuantity (# of tunnels to keep in the ready)
inbound.length (# of remote peers in the tunnel)
inbound.lengthVariance (if > 0, permute the length by adding a random #
up to the variance. if < 0, permute the length
by adding or subtracting a random # up to the
variance)
outbound.* (same as the inbound, except for the, uh, outbound tunnels
in that client's pool)
There are other options, and more will be added later, but the above are
the most relevent ones.
* Replaced Jetty 4.2.21 with Jetty 5.1.2
* Compress all profile data on disk.
* Adjust the reseeding functionality to work even when the JVM's http proxy
is set.
* Enable a poor-man's interactive-flow in the streaming lib by choking the
max window size.
* Reduced the default streaming lib max message size to 16KB (though still
configurable by the user), also doubling the default maximum window
size.
* Replaced the RouterIdentity in a Lease with its SHA256 hash.
* Reduced the overall I2NP message checksum from a full 32 byte SHA256 to
the first byte of the SHA256.
* Added a new "netId" flag to let routers drop references to other routers
who we won't be able to talk to.
* Extended the timestamper to get a second (or third) opinion whenever it
wants to actually adjust the clock offset.
* Replaced that kludge of a timestamp I2NP message with a full blown
DateMessage.
* Substantial memory optimizations within the router and the SDK to reduce
GC churn. Client apps and the streaming libs have not been tuned,
however.
* More bugfixes thank you can shake a stick at.
2005-02-13 jrandom
* Updated jbigi source to handle 64bit CPUs. The bundled jbigi.jar still
only contains 32bit versions, so build your own, placing libjbigi.so in
your install dir if necessary. (thanks mule!)
* Added support for libjbigi-$os-athlon64 to NativeBigInteger and CPUID
(thanks spaetz!)
2005-02-16 22:23:47 +00:00
|
|
|
public void setSharePercentage(String pct) {
|
|
|
|
_sharePct = (pct != null ? pct.trim() : null);
|
|
|
|
}
|
2004-07-31 02:34:24 +00:00
|
|
|
|
2005-08-10 23:55:40 +00:00
|
|
|
private void recheckReachability() {
|
|
|
|
_context.commSystem().recheckReachability();
|
|
|
|
addFormNotice("Rechecking router reachability...");
|
|
|
|
}
|
|
|
|
|
2004-07-31 02:34:24 +00:00
|
|
|
/**
|
|
|
|
* The user made changes to the network config and wants to save them, so
|
|
|
|
* lets go ahead and do so.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
private void saveChanges() {
|
|
|
|
boolean restartRequired = false;
|
|
|
|
|
2006-02-15 05:33:17 +00:00
|
|
|
if (!_ratesOnly) {
|
2009-05-01 00:42:31 +00:00
|
|
|
// IP Settings
|
|
|
|
String oldUdp = _context.getProperty(UDPTransport.PROP_SOURCES, UDPTransport.DEFAULT_SOURCES);
|
|
|
|
String oldUHost = _context.getProperty(UDPTransport.PROP_EXTERNAL_HOST, "");
|
|
|
|
if (_udpAutoIP != null) {
|
|
|
|
String uhost = "";
|
|
|
|
if (_udpAutoIP.equals("fixed")) {
|
|
|
|
if (_udpHost1 != null && _udpHost1.length() > 0)
|
|
|
|
uhost = _udpHost1;
|
|
|
|
else if (_udpHost2 != null && _udpHost2.length() > 0)
|
2009-05-10 15:40:50 +00:00
|
|
|
uhost = _udpHost2;
|
2009-05-01 00:42:31 +00:00
|
|
|
else
|
|
|
|
_udpAutoIP = UDPTransport.DEFAULT_SOURCES;
|
|
|
|
}
|
|
|
|
_context.router().setConfigSetting(UDPTransport.PROP_SOURCES, _udpAutoIP);
|
2009-05-10 15:40:50 +00:00
|
|
|
// Todo: Catch local IPs right here rather than complaining later
|
2009-05-01 00:42:31 +00:00
|
|
|
_context.router().setConfigSetting(UDPTransport.PROP_EXTERNAL_HOST, uhost);
|
|
|
|
if ((!oldUdp.equals(_udpAutoIP)) || (!oldUHost.equals(uhost))) {
|
|
|
|
addFormNotice("Updating IP address");
|
|
|
|
restartRequired = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NTCP Settings
|
2007-07-07 20:03:50 +00:00
|
|
|
// Normalize some things to make the following code a little easier...
|
2009-05-04 19:54:33 +00:00
|
|
|
String oldNHost = _context.getProperty(ConfigNetHelper.PROP_I2NP_NTCP_HOSTNAME, "");
|
|
|
|
String oldNPort = _context.getProperty(ConfigNetHelper.PROP_I2NP_NTCP_PORT, "");
|
|
|
|
String oldAutoHost = _context.getProperty(ConfigNetHelper.PROP_I2NP_NTCP_AUTO_IP, "true");
|
|
|
|
String sAutoPort = _context.getProperty(ConfigNetHelper.PROP_I2NP_NTCP_AUTO_PORT, "true");
|
2007-07-07 20:03:50 +00:00
|
|
|
boolean oldAutoPort = "true".equalsIgnoreCase(sAutoPort);
|
2009-04-30 21:03:00 +00:00
|
|
|
if (_ntcpHostname == null) _ntcpHostname = "";
|
|
|
|
if (_ntcpPort == null) _ntcpPort = "";
|
2009-05-04 19:54:33 +00:00
|
|
|
if (_ntcpAutoIP == null) _ntcpAutoIP = "true";
|
2007-07-07 20:03:50 +00:00
|
|
|
|
2009-05-04 19:54:33 +00:00
|
|
|
if ((!oldAutoHost.equals(_ntcpAutoIP)) || ! oldNHost.equalsIgnoreCase(_ntcpHostname)) {
|
2009-05-06 00:54:24 +00:00
|
|
|
if ("disabled".equals(_ntcpAutoIP)) {
|
|
|
|
addFormNotice("Disabling TCP completely");
|
|
|
|
} else if ("false".equals(_ntcpAutoIP) && _ntcpHostname.length() > 0) {
|
2009-05-10 15:40:50 +00:00
|
|
|
// Todo: Catch local IPs right here rather than complaining later
|
2006-07-04 21:17:44 +00:00
|
|
|
_context.router().setConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_HOSTNAME, _ntcpHostname);
|
2007-07-07 20:03:50 +00:00
|
|
|
addFormNotice("Updating inbound TCP address to " + _ntcpHostname);
|
|
|
|
} else {
|
2006-07-04 21:17:44 +00:00
|
|
|
_context.router().removeConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_HOSTNAME);
|
2009-04-30 21:03:00 +00:00
|
|
|
if ("false".equals(_ntcpAutoIP))
|
|
|
|
addFormNotice("Disabling inbound TCP");
|
|
|
|
else
|
2009-05-04 19:54:33 +00:00
|
|
|
addFormNotice("Updating inbound TCP address to auto"); // true or always
|
2007-07-07 20:03:50 +00:00
|
|
|
}
|
2009-04-30 21:03:00 +00:00
|
|
|
_context.router().setConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_AUTO_IP, _ntcpAutoIP);
|
2009-05-06 00:54:24 +00:00
|
|
|
_context.router().setConfigSetting(TransportManager.PROP_ENABLE_NTCP, "" + !"disabled".equals(_ntcpAutoIP));
|
2007-07-07 20:03:50 +00:00
|
|
|
restartRequired = true;
|
|
|
|
}
|
|
|
|
if (oldAutoPort != _ntcpAutoPort || ! oldNPort.equals(_ntcpPort)) {
|
2009-04-30 16:50:47 +00:00
|
|
|
if (_ntcpPort.length() > 0 && !_ntcpAutoPort) {
|
2007-07-07 20:03:50 +00:00
|
|
|
_context.router().setConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_PORT, _ntcpPort);
|
|
|
|
addFormNotice("Updating inbound TCP port to " + _ntcpPort);
|
|
|
|
} else {
|
|
|
|
_context.router().removeConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_PORT);
|
2009-04-30 16:50:47 +00:00
|
|
|
addFormNotice("Updating inbound TCP port to auto");
|
2006-07-04 21:17:44 +00:00
|
|
|
}
|
2009-04-30 16:50:47 +00:00
|
|
|
_context.router().setConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_AUTO_PORT, "" + _ntcpAutoPort);
|
2007-07-07 20:03:50 +00:00
|
|
|
restartRequired = true;
|
2006-07-04 21:17:44 +00:00
|
|
|
}
|
|
|
|
|
2009-05-01 00:42:31 +00:00
|
|
|
// UDP Settings
|
2006-02-15 05:33:17 +00:00
|
|
|
if ( (_udpPort != null) && (_udpPort.length() > 0) ) {
|
2009-04-28 19:01:52 +00:00
|
|
|
String oldPort = "" + _context.getProperty(UDPTransport.PROP_INTERNAL_PORT, UDPTransport.DEFAULT_INTERNAL_PORT);
|
|
|
|
if (!oldPort.equals(_udpPort)) {
|
|
|
|
_context.router().setConfigSetting(UDPTransport.PROP_INTERNAL_PORT, _udpPort);
|
2009-04-28 22:45:26 +00:00
|
|
|
_context.router().setConfigSetting(UDPTransport.PROP_EXTERNAL_PORT, _udpPort);
|
2006-02-15 05:33:17 +00:00
|
|
|
addFormNotice("Updating UDP port from " + oldPort + " to " + _udpPort);
|
|
|
|
restartRequired = true;
|
|
|
|
}
|
2004-07-31 02:34:24 +00:00
|
|
|
}
|
2006-02-15 05:33:17 +00:00
|
|
|
|
2004-07-31 02:34:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
updateRates();
|
|
|
|
|
2009-05-01 00:42:31 +00:00
|
|
|
boolean switchRequired = false;
|
2006-02-15 05:33:17 +00:00
|
|
|
if (!_ratesOnly) {
|
|
|
|
// If hidden mode value changes, restart is required
|
2009-05-01 00:42:31 +00:00
|
|
|
switchRequired = _hiddenMode != _context.router().isHidden();
|
|
|
|
if (switchRequired) {
|
|
|
|
_context.router().setConfigSetting(PROP_HIDDEN, "" + _hiddenMode);
|
|
|
|
if (_hiddenMode)
|
2009-05-28 13:49:57 +00:00
|
|
|
addFormError("Gracefully restarting into Hidden Router Mode");
|
2009-05-01 00:42:31 +00:00
|
|
|
else
|
2009-05-28 13:49:57 +00:00
|
|
|
addFormError("Gracefully restarting to exit Hidden Router Mode");
|
2006-02-15 05:33:17 +00:00
|
|
|
}
|
2005-11-26 09:16:11 +00:00
|
|
|
|
2009-04-28 19:49:09 +00:00
|
|
|
_context.router().setConfigSetting(Router.PROP_DYNAMIC_KEYS, "" + _dynamicKeys);
|
|
|
|
|
|
|
|
if (Boolean.valueOf(_context.getProperty(TransportManager.PROP_ENABLE_UPNP)).booleanValue() !=
|
|
|
|
_upnp) {
|
2009-05-28 13:49:57 +00:00
|
|
|
// This is minor, don't set restartRequired
|
2009-04-28 19:49:09 +00:00
|
|
|
if (_upnp)
|
|
|
|
addFormNotice("Enabling UPnP, restart required to take effect");
|
|
|
|
else
|
|
|
|
addFormNotice("Disabling UPnP, restart required to take effect");
|
2006-02-15 05:33:17 +00:00
|
|
|
}
|
2009-04-28 19:49:09 +00:00
|
|
|
_context.router().setConfigSetting(TransportManager.PROP_ENABLE_UPNP, "" + _upnp);
|
2006-02-15 05:33:17 +00:00
|
|
|
|
|
|
|
if (_requireIntroductions) {
|
|
|
|
_context.router().setConfigSetting(UDPTransport.PROP_FORCE_INTRODUCERS, "true");
|
|
|
|
addFormNotice("Requiring SSU introduers");
|
|
|
|
} else {
|
|
|
|
_context.router().removeConfigSetting(UDPTransport.PROP_FORCE_INTRODUCERS);
|
|
|
|
}
|
|
|
|
|
2009-04-28 19:49:09 +00:00
|
|
|
// Time sync enable, means NOT disabled
|
2009-05-28 13:49:57 +00:00
|
|
|
// Hmm router sets this at startup, not required here
|
|
|
|
//_context.router().setConfigSetting(Timestamper.PROP_DISABLED, "false");
|
2006-02-16 10:33:29 +00:00
|
|
|
|
2009-05-28 13:49:57 +00:00
|
|
|
// Hidden in the GUI
|
|
|
|
//LoadTestManager.setEnableLoadTesting(_context, _enableLoadTesting);
|
2004-07-31 02:34:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
boolean saved = _context.router().saveConfig();
|
2006-02-15 05:33:17 +00:00
|
|
|
if ( (_action != null) && ("Save changes".equals(_action)) ) {
|
|
|
|
if (saved)
|
|
|
|
addFormNotice("Configuration saved successfully");
|
|
|
|
else
|
|
|
|
addFormNotice("Error saving the configuration (applied but not saved) - please see the error logs");
|
|
|
|
}
|
2004-07-31 02:34:24 +00:00
|
|
|
|
2009-05-01 00:42:31 +00:00
|
|
|
if (switchRequired) {
|
|
|
|
hiddenSwitch();
|
|
|
|
} else if (restartRequired) {
|
2009-05-28 13:49:57 +00:00
|
|
|
// Wow this dumps all conns immediately and really isn't nice
|
2009-04-28 19:01:52 +00:00
|
|
|
//addFormNotice("Performing a soft restart");
|
|
|
|
//_context.router().restart();
|
|
|
|
//addFormNotice("Soft restart complete");
|
2009-05-28 13:49:57 +00:00
|
|
|
|
2009-04-28 19:01:52 +00:00
|
|
|
// Most of the time we aren't changing addresses, just enabling or disabling
|
|
|
|
// things, so let's try just a new routerInfo and see how that works.
|
|
|
|
// Maybe we should restart if we change addresses though?
|
2009-05-28 13:49:57 +00:00
|
|
|
// No, this doesn't work well, really need to call SSU Transport externalAddressReceived(),
|
|
|
|
// but that's hard to get to, and doesn't handle port changes, etc.
|
|
|
|
// So don't do this...
|
|
|
|
//_context.router().rebuildRouterInfo();
|
|
|
|
//addFormNotice("Router Info rebuilt");
|
|
|
|
|
|
|
|
// 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.router().shutdownGracefully(Router.EXIT_GRACEFUL_RESTART);
|
2004-07-31 02:34:24 +00:00
|
|
|
}
|
|
|
|
}
|
2005-11-26 09:16:11 +00:00
|
|
|
|
|
|
|
private void hiddenSwitch() {
|
|
|
|
// Full restart required to generate new keys
|
2009-02-25 00:05:30 +00:00
|
|
|
_context.addShutdownTask(new UpdateWrapperManagerAndRekeyTask(Router.EXIT_GRACEFUL_RESTART));
|
2005-11-26 09:16:11 +00:00
|
|
|
_context.router().shutdownGracefully(Router.EXIT_GRACEFUL_RESTART);
|
|
|
|
}
|
2004-07-31 02:34:24 +00:00
|
|
|
|
|
|
|
private void updateRates() {
|
|
|
|
boolean updated = false;
|
2009-05-04 19:54:33 +00:00
|
|
|
|
|
|
|
if (_sharePct != null) {
|
|
|
|
String old = _context.router().getConfigSetting(Router.PROP_BANDWIDTH_SHARE_PERCENTAGE);
|
|
|
|
if ( (old == null) || (!old.equalsIgnoreCase(_sharePct)) ) {
|
|
|
|
_context.router().setConfigSetting(Router.PROP_BANDWIDTH_SHARE_PERCENTAGE, _sharePct);
|
|
|
|
addFormNotice("Updating bandwidth share percentage");
|
|
|
|
updated = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( (_inboundRate != null) && (_inboundRate.length() > 0) &&
|
|
|
|
!_inboundRate.equals(_context.getProperty(FIFOBandwidthRefiller.PROP_INBOUND_BANDWIDTH, "" + FIFOBandwidthRefiller.DEFAULT_INBOUND_BANDWIDTH))) {
|
2008-12-03 18:53:57 +00:00
|
|
|
_context.router().setConfigSetting(FIFOBandwidthRefiller.PROP_INBOUND_BANDWIDTH, _inboundRate);
|
2004-07-31 02:34:24 +00:00
|
|
|
updated = true;
|
|
|
|
}
|
2009-05-04 19:54:33 +00:00
|
|
|
if ( (_outboundRate != null) && (_outboundRate.length() > 0) &&
|
|
|
|
!_outboundRate.equals(_context.getProperty(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH, "" + FIFOBandwidthRefiller.DEFAULT_OUTBOUND_BANDWIDTH))) {
|
2008-12-03 18:53:57 +00:00
|
|
|
_context.router().setConfigSetting(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH, _outboundRate);
|
2004-07-31 02:34:24 +00:00
|
|
|
updated = true;
|
|
|
|
}
|
2009-05-29 12:08:36 +00:00
|
|
|
|
|
|
|
/******* These aren't in the GUI for now
|
|
|
|
|
2009-05-04 19:54:33 +00:00
|
|
|
if ( (_inboundBurstRate != null) && (_inboundBurstRate.length() > 0) &&
|
|
|
|
!_inboundBurstRate.equals(_context.getProperty(FIFOBandwidthRefiller.PROP_INBOUND_BURST_BANDWIDTH, "" + FIFOBandwidthRefiller.DEFAULT_INBOUND_BURST_BANDWIDTH))) {
|
2008-12-03 18:53:57 +00:00
|
|
|
_context.router().setConfigSetting(FIFOBandwidthRefiller.PROP_INBOUND_BURST_BANDWIDTH, _inboundBurstRate);
|
2005-09-17 23:01:44 +00:00
|
|
|
updated = true;
|
|
|
|
}
|
2009-05-04 19:54:33 +00:00
|
|
|
if ( (_outboundBurstRate != null) && (_outboundBurstRate.length() > 0) &&
|
|
|
|
!_outboundBurstRate.equals(_context.getProperty(FIFOBandwidthRefiller.PROP_OUTBOUND_BURST_BANDWIDTH, "" + FIFOBandwidthRefiller.DEFAULT_OUTBOUND_BURST_BANDWIDTH))) {
|
2008-12-03 18:53:57 +00:00
|
|
|
_context.router().setConfigSetting(FIFOBandwidthRefiller.PROP_OUTBOUND_BURST_BANDWIDTH, _outboundBurstRate);
|
2005-09-17 23:01:44 +00:00
|
|
|
updated = true;
|
|
|
|
}
|
2004-07-31 02:34:24 +00:00
|
|
|
|
2008-12-03 18:53:57 +00:00
|
|
|
String inBurstRate = _context.router().getConfigSetting(FIFOBandwidthRefiller.PROP_INBOUND_BURST_BANDWIDTH);
|
2004-07-31 02:34:24 +00:00
|
|
|
|
|
|
|
if (_inboundBurst != null) {
|
|
|
|
int rateKBps = 0;
|
|
|
|
int burstSeconds = 0;
|
|
|
|
try {
|
2005-09-17 23:01:44 +00:00
|
|
|
rateKBps = Integer.parseInt(inBurstRate);
|
2004-07-31 02:34:24 +00:00
|
|
|
burstSeconds = Integer.parseInt(_inboundBurst);
|
|
|
|
} catch (NumberFormatException nfe) {
|
|
|
|
// ignore
|
|
|
|
}
|
|
|
|
if ( (rateKBps > 0) && (burstSeconds > 0) ) {
|
|
|
|
int kb = rateKBps * burstSeconds;
|
2008-12-03 18:53:57 +00:00
|
|
|
_context.router().setConfigSetting(FIFOBandwidthRefiller.PROP_INBOUND_BANDWIDTH_PEAK, "" + kb);
|
2004-07-31 02:34:24 +00:00
|
|
|
updated = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-03 18:53:57 +00:00
|
|
|
String outBurstRate = _context.router().getConfigSetting(FIFOBandwidthRefiller.PROP_OUTBOUND_BURST_BANDWIDTH);
|
2004-07-31 02:34:24 +00:00
|
|
|
|
|
|
|
if (_outboundBurst != null) {
|
|
|
|
int rateKBps = 0;
|
|
|
|
int burstSeconds = 0;
|
|
|
|
try {
|
2005-09-17 23:01:44 +00:00
|
|
|
rateKBps = Integer.parseInt(outBurstRate);
|
2004-07-31 02:34:24 +00:00
|
|
|
burstSeconds = Integer.parseInt(_outboundBurst);
|
|
|
|
} catch (NumberFormatException nfe) {
|
|
|
|
// ignore
|
|
|
|
}
|
|
|
|
if ( (rateKBps > 0) && (burstSeconds > 0) ) {
|
|
|
|
int kb = rateKBps * burstSeconds;
|
2008-12-03 18:53:57 +00:00
|
|
|
_context.router().setConfigSetting(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH_PEAK, "" + kb);
|
2004-07-31 02:34:24 +00:00
|
|
|
updated = true;
|
|
|
|
}
|
|
|
|
}
|
2009-05-29 12:08:36 +00:00
|
|
|
|
|
|
|
***********/
|
|
|
|
|
2004-07-31 02:34:24 +00:00
|
|
|
|
2009-05-04 19:54:33 +00:00
|
|
|
if (updated && !_ratesOnly) {
|
2008-12-03 18:53:57 +00:00
|
|
|
_context.bandwidthLimiter().reinitialize();
|
2004-07-31 02:34:24 +00:00
|
|
|
addFormNotice("Updated bandwidth limits");
|
2009-05-04 19:54:33 +00:00
|
|
|
}
|
2004-07-31 02:34:24 +00:00
|
|
|
}
|
|
|
|
}
|