2004-07-31 02:34:24 +00:00
|
|
|
package net.i2p.router.web;
|
|
|
|
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
|
|
|
|
import java.net.URL;
|
|
|
|
import java.net.URLConnection;
|
|
|
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.Set;
|
|
|
|
|
2004-08-13 21:15:22 +00:00
|
|
|
import net.i2p.time.Timestamper;
|
2005-09-13 00:11:56 +00:00
|
|
|
import net.i2p.router.transport.udp.UDPTransport;
|
2005-11-26 09:16:11 +00:00
|
|
|
import net.i2p.router.Router;
|
2006-02-16 10:33:29 +00:00
|
|
|
import net.i2p.router.LoadTestManager;
|
2005-11-26 09:16:11 +00:00
|
|
|
import net.i2p.data.RouterInfo;
|
|
|
|
import net.i2p.router.web.ConfigServiceHandler.UpdateWrapperManagerTask;
|
|
|
|
import net.i2p.router.web.ConfigServiceHandler.UpdateWrapperManagerAndRekeyTask;
|
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;
|
2005-07-27 19:03:43 +00:00
|
|
|
private String _tcpPort;
|
|
|
|
private String _udpPort;
|
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;
|
2006-02-15 05:33:17 +00:00
|
|
|
private boolean _ratesOnly;
|
2004-07-31 02:34:24 +00:00
|
|
|
|
|
|
|
protected void processForm() {
|
2006-03-16 00:49:22 +00:00
|
|
|
if (_reseedRequested) {
|
2004-07-31 02:34:24 +00:00
|
|
|
reseed();
|
2006-02-15 05:33:17 +00:00
|
|
|
} else 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 setReseed(String moo) { _reseedRequested = true; }
|
|
|
|
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 setHiddenMode(String moo) { _hiddenMode = true; }
|
|
|
|
public void setDynamicKeys(String moo) { _dynamicKeys = true; }
|
2006-02-15 05:33:17 +00:00
|
|
|
public void setUpdateratesonly(String moo) { _ratesOnly = true; }
|
2006-02-16 10:33:29 +00:00
|
|
|
public void setEnableloadtesting(String moo) { _enableLoadTesting = 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);
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
public void setReseedfrom(String url) {
|
|
|
|
_reseedFrom = (url != null ? url.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
|
|
|
|
2006-03-16 00:49:22 +00:00
|
|
|
|
2006-02-19 12:29:57 +00:00
|
|
|
private static final String DEFAULT_SEED_URL = ReseedHandler.DEFAULT_SEED_URL;
|
2004-07-31 02:34:24 +00:00
|
|
|
/**
|
|
|
|
* Reseed has been requested, so lets go ahead and do it. Fetch all of
|
|
|
|
* the routerInfo-*.dat files from the specified URL (or the default) and
|
|
|
|
* save them into this router's netDb dir.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
private void reseed() {
|
|
|
|
String seedURL = DEFAULT_SEED_URL;
|
|
|
|
if (_reseedFrom != null)
|
|
|
|
seedURL = _reseedFrom;
|
|
|
|
try {
|
|
|
|
URL dir = new URL(seedURL);
|
|
|
|
String content = new String(readURL(dir));
|
|
|
|
Set urls = new HashSet();
|
|
|
|
int cur = 0;
|
|
|
|
while (true) {
|
|
|
|
int start = content.indexOf("href=\"routerInfo-", cur);
|
|
|
|
if (start < 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
int end = content.indexOf(".dat\">", start);
|
|
|
|
String name = content.substring(start+"href=\"routerInfo-".length(), end);
|
|
|
|
urls.add(name);
|
|
|
|
cur = end + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int fetched = 0;
|
2004-10-01 14:35:49 +00:00
|
|
|
int errors = 0;
|
2004-07-31 02:34:24 +00:00
|
|
|
for (Iterator iter = urls.iterator(); iter.hasNext(); ) {
|
2004-10-01 14:35:49 +00:00
|
|
|
try {
|
|
|
|
fetchSeed(seedURL, (String)iter.next());
|
|
|
|
fetched++;
|
|
|
|
} catch (Exception e) {
|
|
|
|
errors++;
|
|
|
|
}
|
2004-07-31 02:34:24 +00:00
|
|
|
}
|
2004-10-01 14:35:49 +00:00
|
|
|
addFormNotice("Reseeded with " + fetched + " peers (and " + errors + " failures)");
|
2004-07-31 02:34:24 +00:00
|
|
|
} catch (Throwable t) {
|
|
|
|
_context.logManager().getLog(ConfigNetHandler.class).error("Error reseeding", t);
|
|
|
|
addFormError("Error reseeding (RESEED_EXCEPTION)");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void fetchSeed(String seedURL, String peer) throws Exception {
|
2004-09-01 07:00:07 +00:00
|
|
|
URL url = new URL(seedURL + (seedURL.endsWith("/") ? "" : "/") + "routerInfo-" + peer + ".dat");
|
2004-07-31 02:34:24 +00:00
|
|
|
|
|
|
|
byte data[] = readURL(url);
|
|
|
|
writeSeed(peer, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
private byte[] readURL(URL url) throws Exception {
|
|
|
|
ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
|
|
|
|
URLConnection con = url.openConnection();
|
|
|
|
InputStream in = con.getInputStream();
|
|
|
|
byte buf[] = new byte[1024];
|
|
|
|
while (true) {
|
|
|
|
int read = in.read(buf);
|
|
|
|
if (read < 0)
|
|
|
|
break;
|
|
|
|
baos.write(buf, 0, read);
|
|
|
|
}
|
|
|
|
in.close();
|
|
|
|
return baos.toByteArray();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void writeSeed(String name, byte data[]) throws Exception {
|
|
|
|
// props taken from KademliaNetworkDatabaseFacade...
|
|
|
|
String dirName = _context.getProperty("router.networkDatabase.dbDir", "netDb");
|
|
|
|
File netDbDir = new File(dirName);
|
|
|
|
if (!netDbDir.exists()) {
|
|
|
|
boolean ok = netDbDir.mkdirs();
|
|
|
|
if (ok)
|
|
|
|
addFormNotice("Network database directory created: " + dirName);
|
|
|
|
else
|
|
|
|
addFormNotice("Error creating network database directory: " + dirName);
|
|
|
|
}
|
|
|
|
FileOutputStream fos = new FileOutputStream(new File(netDbDir, "routerInfo-" + name + ".dat"));
|
|
|
|
fos.write(data);
|
|
|
|
fos.close();
|
|
|
|
}
|
|
|
|
|
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) {
|
|
|
|
if ( (_hostname != null) && (_hostname.length() > 0) ) {
|
|
|
|
String oldHost = _context.router().getConfigSetting(ConfigNetHelper.PROP_I2NP_TCP_HOSTNAME);
|
|
|
|
if ( (oldHost == null) || (!oldHost.equalsIgnoreCase(_hostname)) ) {
|
|
|
|
_context.router().setConfigSetting(ConfigNetHelper.PROP_I2NP_TCP_HOSTNAME, _hostname);
|
|
|
|
addFormNotice("Updating hostname from " + oldHost + " to " + _hostname);
|
|
|
|
restartRequired = true;
|
|
|
|
}
|
2004-07-31 02:34:24 +00:00
|
|
|
}
|
2006-02-15 05:33:17 +00:00
|
|
|
if ( (_tcpPort != null) && (_tcpPort.length() > 0) ) {
|
|
|
|
String oldPort = _context.router().getConfigSetting(ConfigNetHelper.PROP_I2NP_TCP_PORT);
|
|
|
|
if ( (oldPort == null) && (_tcpPort.equals("8887")) ) {
|
|
|
|
// still on default.. noop
|
|
|
|
} else if ( (oldPort == null) || (!oldPort.equalsIgnoreCase(_tcpPort)) ) {
|
|
|
|
// its not the default OR it has changed
|
|
|
|
_context.router().setConfigSetting(ConfigNetHelper.PROP_I2NP_TCP_PORT, _tcpPort);
|
|
|
|
addFormNotice("Updating TCP port from " + oldPort + " to " + _tcpPort);
|
|
|
|
restartRequired = true;
|
|
|
|
}
|
2005-07-27 19:03:43 +00:00
|
|
|
}
|
2006-02-15 05:33:17 +00:00
|
|
|
if ( (_udpPort != null) && (_udpPort.length() > 0) ) {
|
|
|
|
String oldPort = _context.router().getConfigSetting(ConfigNetHelper.PROP_I2NP_UDP_PORT);
|
|
|
|
if ( (oldPort == null) && (_udpPort.equals("8887")) ) {
|
|
|
|
// still on default.. noop
|
|
|
|
} else if ( (oldPort == null) || (!oldPort.equalsIgnoreCase(_udpPort)) ) {
|
|
|
|
// its not the default OR it has changed
|
|
|
|
_context.router().setConfigSetting(ConfigNetHelper.PROP_I2NP_TCP_PORT, _udpPort);
|
|
|
|
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();
|
|
|
|
|
2006-02-15 05:33:17 +00:00
|
|
|
if (!_ratesOnly) {
|
|
|
|
if (_sharePct != null) {
|
|
|
|
String old = _context.router().getConfigSetting(ConfigNetHelper.PROP_SHARE_PERCENTAGE);
|
|
|
|
if ( (old == null) || (!old.equalsIgnoreCase(_sharePct)) ) {
|
|
|
|
_context.router().setConfigSetting(ConfigNetHelper.PROP_SHARE_PERCENTAGE, _sharePct);
|
|
|
|
addFormNotice("Updating bandwidth share percentage");
|
|
|
|
}
|
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
|
|
|
}
|
2005-11-26 09:16:11 +00:00
|
|
|
|
2006-02-15 05:33:17 +00:00
|
|
|
// If hidden mode value changes, restart is required
|
|
|
|
if (_hiddenMode && "false".equalsIgnoreCase(_context.getProperty(Router.PROP_HIDDEN, "false"))) {
|
|
|
|
_context.router().setConfigSetting(Router.PROP_HIDDEN, "true");
|
2006-04-04 12:20:32 +00:00
|
|
|
_context.router().addCapabilities(_context.router().getRouterInfo());
|
2006-02-15 05:33:17 +00:00
|
|
|
addFormNotice("Gracefully restarting into Hidden Router Mode. Make sure you have no 0-1 length "
|
|
|
|
+ "<a href=\"configtunnels.jsp\">tunnels!</a>");
|
|
|
|
hiddenSwitch();
|
|
|
|
}
|
2005-11-26 09:16:11 +00:00
|
|
|
|
2006-02-15 05:33:17 +00:00
|
|
|
if (!_hiddenMode && "true".equalsIgnoreCase(_context.getProperty(Router.PROP_HIDDEN, "false"))) {
|
|
|
|
_context.router().removeConfigSetting(Router.PROP_HIDDEN);
|
|
|
|
_context.router().getRouterInfo().delCapability(RouterInfo.CAPABILITY_HIDDEN);
|
|
|
|
addFormNotice("Gracefully restarting to exit Hidden Router Mode");
|
|
|
|
hiddenSwitch();
|
|
|
|
}
|
2005-11-26 09:16:11 +00:00
|
|
|
|
2006-02-15 05:33:17 +00:00
|
|
|
if (_dynamicKeys) {
|
|
|
|
_context.router().setConfigSetting(Router.PROP_DYNAMIC_KEYS, "true");
|
|
|
|
} else {
|
|
|
|
_context.router().removeConfigSetting(Router.PROP_DYNAMIC_KEYS);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_requireIntroductions) {
|
|
|
|
_context.router().setConfigSetting(UDPTransport.PROP_FORCE_INTRODUCERS, "true");
|
|
|
|
addFormNotice("Requiring SSU introduers");
|
|
|
|
} else {
|
|
|
|
_context.router().removeConfigSetting(UDPTransport.PROP_FORCE_INTRODUCERS);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (true || _timeSyncEnabled) {
|
|
|
|
// Time sync enable, means NOT disabled
|
|
|
|
_context.router().setConfigSetting(Timestamper.PROP_DISABLED, "false");
|
|
|
|
} else {
|
|
|
|
_context.router().setConfigSetting(Timestamper.PROP_DISABLED, "true");
|
|
|
|
}
|
2006-02-16 10:33:29 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
if (restartRequired) {
|
|
|
|
addFormNotice("Performing a soft restart");
|
|
|
|
_context.router().restart();
|
|
|
|
addFormNotice("Soft restart complete");
|
|
|
|
}
|
|
|
|
}
|
2005-11-26 09:16:11 +00:00
|
|
|
|
|
|
|
private void hiddenSwitch() {
|
|
|
|
// Full restart required to generate new keys
|
|
|
|
_context.router().addShutdownTask(new UpdateWrapperManagerAndRekeyTask(Router.EXIT_GRACEFUL_RESTART));
|
|
|
|
_context.router().shutdownGracefully(Router.EXIT_GRACEFUL_RESTART);
|
|
|
|
}
|
2004-07-31 02:34:24 +00:00
|
|
|
|
|
|
|
private void updateRates() {
|
|
|
|
boolean updated = false;
|
|
|
|
if ( (_inboundRate != null) && (_inboundRate.length() > 0) ) {
|
|
|
|
_context.router().setConfigSetting(ConfigNetHelper.PROP_INBOUND_KBPS, _inboundRate);
|
|
|
|
updated = true;
|
|
|
|
}
|
|
|
|
if ( (_outboundRate != null) && (_outboundRate.length() > 0) ) {
|
|
|
|
_context.router().setConfigSetting(ConfigNetHelper.PROP_OUTBOUND_KBPS, _outboundRate);
|
|
|
|
updated = true;
|
|
|
|
}
|
2005-09-17 23:01:44 +00:00
|
|
|
if ( (_inboundBurstRate != null) && (_inboundBurstRate.length() > 0) ) {
|
|
|
|
_context.router().setConfigSetting(ConfigNetHelper.PROP_INBOUND_BURST_KBPS, _inboundBurstRate);
|
|
|
|
updated = true;
|
|
|
|
}
|
|
|
|
if ( (_outboundBurstRate != null) && (_outboundBurstRate.length() > 0) ) {
|
|
|
|
_context.router().setConfigSetting(ConfigNetHelper.PROP_OUTBOUND_BURST_KBPS, _outboundBurstRate);
|
|
|
|
updated = true;
|
|
|
|
}
|
2004-07-31 02:34:24 +00:00
|
|
|
|
2005-09-17 23:01:44 +00:00
|
|
|
String inBurstRate = _context.router().getConfigSetting(ConfigNetHelper.PROP_INBOUND_BURST_KBPS);
|
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;
|
|
|
|
_context.router().setConfigSetting(ConfigNetHelper.PROP_INBOUND_BURST, "" + kb);
|
|
|
|
updated = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-17 23:01:44 +00:00
|
|
|
String outBurstRate = _context.router().getConfigSetting(ConfigNetHelper.PROP_OUTBOUND_BURST_KBPS);
|
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;
|
|
|
|
_context.router().setConfigSetting(ConfigNetHelper.PROP_OUTBOUND_BURST, "" + kb);
|
|
|
|
updated = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-15 05:33:17 +00:00
|
|
|
if (updated && !_ratesOnly)
|
2004-07-31 02:34:24 +00:00
|
|
|
addFormNotice("Updated bandwidth limits");
|
|
|
|
}
|
|
|
|
}
|