2004-07-24 02:06:07 +00:00
|
|
|
package net.i2p.router.web;
|
|
|
|
|
2004-08-13 21:15:22 +00:00
|
|
|
import net.i2p.time.Timestamper;
|
2004-07-24 02:06:07 +00:00
|
|
|
import net.i2p.router.RouterContext;
|
|
|
|
|
|
|
|
public class ConfigNetHelper {
|
|
|
|
private RouterContext _context;
|
|
|
|
/**
|
|
|
|
* Configure this bean to query a particular router context
|
|
|
|
*
|
|
|
|
* @param contextId begging few characters of the routerHash, or null to pick
|
|
|
|
* the first one we come across.
|
|
|
|
*/
|
|
|
|
public void setContextId(String contextId) {
|
|
|
|
try {
|
|
|
|
_context = ContextHelper.getContext(contextId);
|
|
|
|
} catch (Throwable t) {
|
|
|
|
t.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public ConfigNetHelper() {}
|
|
|
|
|
|
|
|
/** copied from various private TCP components */
|
2004-07-31 02:34:24 +00:00
|
|
|
public final static String PROP_I2NP_TCP_HOSTNAME = "i2np.tcp.hostname";
|
|
|
|
public final static String PROP_I2NP_TCP_PORT = "i2np.tcp.port";
|
2004-07-24 02:06:07 +00:00
|
|
|
|
|
|
|
public String getHostname() {
|
|
|
|
return _context.getProperty(PROP_I2NP_TCP_HOSTNAME);
|
|
|
|
}
|
|
|
|
public String getPort() {
|
|
|
|
int port = 8887;
|
|
|
|
String val = _context.getProperty(PROP_I2NP_TCP_PORT);
|
|
|
|
if (val != null) {
|
|
|
|
try {
|
|
|
|
port = Integer.parseInt(val);
|
|
|
|
} catch (NumberFormatException nfe) {
|
|
|
|
// ignore, use default from above
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "" + port;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getEnableTimeSyncChecked() {
|
2004-08-24 19:59:54 +00:00
|
|
|
String disabled = _context.getProperty(Timestamper.PROP_DISABLED, "false");
|
|
|
|
if ( (disabled != null) && ("true".equalsIgnoreCase(disabled)) )
|
2004-07-24 02:06:07 +00:00
|
|
|
return "";
|
|
|
|
else
|
|
|
|
return " checked ";
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final String PROP_INBOUND_KBPS = "i2np.bandwidth.inboundKBytesPerSecond";
|
|
|
|
public static final String PROP_OUTBOUND_KBPS = "i2np.bandwidth.outboundKBytesPerSecond";
|
|
|
|
public static final String PROP_INBOUND_BURST = "i2np.bandwidth.inboundBurstKBytes";
|
|
|
|
public static final String PROP_OUTBOUND_BURST = "i2np.bandwidth.outboundBurstKBytes";
|
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 static final String PROP_SHARE_PERCENTAGE = "router.sharePercentage";
|
|
|
|
public static final int DEFAULT_SHARE_PERCENTAGE = 80;
|
2004-07-24 02:06:07 +00:00
|
|
|
|
|
|
|
public String getInboundRate() {
|
|
|
|
String rate = _context.getProperty(PROP_INBOUND_KBPS);
|
|
|
|
if (rate != null)
|
|
|
|
return rate;
|
|
|
|
else
|
|
|
|
return "-1";
|
|
|
|
}
|
|
|
|
public String getOutboundRate() {
|
|
|
|
String rate = _context.getProperty(PROP_OUTBOUND_KBPS);
|
|
|
|
if (rate != null)
|
|
|
|
return rate;
|
|
|
|
else
|
2004-08-01 21:50:49 +00:00
|
|
|
return "-1";
|
2004-07-24 02:06:07 +00:00
|
|
|
}
|
|
|
|
public String getInboundBurstFactorBox() {
|
|
|
|
String rate = _context.getProperty(PROP_INBOUND_KBPS);
|
|
|
|
String burst = _context.getProperty(PROP_INBOUND_BURST);
|
|
|
|
int numSeconds = 1;
|
|
|
|
if ( (burst != null) && (rate != null) ) {
|
|
|
|
int rateKBps = 0;
|
|
|
|
int burstKB = 0;
|
|
|
|
try {
|
|
|
|
rateKBps = Integer.parseInt(rate);
|
|
|
|
burstKB = Integer.parseInt(burst);
|
|
|
|
} catch (NumberFormatException nfe) {
|
|
|
|
// ignore
|
|
|
|
}
|
|
|
|
if ( (rateKBps > 0) && (burstKB > 0) ) {
|
|
|
|
numSeconds = burstKB / rateKBps;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return getBurstFactor(numSeconds, "inboundburstfactor");
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getOutboundBurstFactorBox() {
|
|
|
|
String rate = _context.getProperty(PROP_OUTBOUND_KBPS);
|
|
|
|
String burst = _context.getProperty(PROP_OUTBOUND_BURST);
|
|
|
|
int numSeconds = 1;
|
|
|
|
if ( (burst != null) && (rate != null) ) {
|
|
|
|
int rateKBps = 0;
|
|
|
|
int burstKB = 0;
|
|
|
|
try {
|
|
|
|
rateKBps = Integer.parseInt(rate);
|
|
|
|
burstKB = Integer.parseInt(burst);
|
|
|
|
} catch (NumberFormatException nfe) {
|
|
|
|
// ignore
|
|
|
|
}
|
|
|
|
if ( (rateKBps > 0) && (burstKB > 0) ) {
|
|
|
|
numSeconds = burstKB / rateKBps;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return getBurstFactor(numSeconds, "outboundburstfactor");
|
|
|
|
}
|
|
|
|
|
|
|
|
private static String getBurstFactor(int numSeconds, String name) {
|
|
|
|
StringBuffer buf = new StringBuffer(256);
|
|
|
|
buf.append("<select name=\"").append(name).append("\">\n");
|
2004-11-30 23:41:51 +00:00
|
|
|
boolean found = false;
|
2004-11-21 23:23:42 +00:00
|
|
|
for (int i = 10; i <= 60; i += 10) {
|
2004-07-24 02:06:07 +00:00
|
|
|
buf.append("<option value=\"").append(i).append("\" ");
|
2004-11-30 23:41:51 +00:00
|
|
|
if (i == numSeconds) {
|
2004-07-24 02:06:07 +00:00
|
|
|
buf.append("selected ");
|
2004-11-30 23:41:51 +00:00
|
|
|
found = true;
|
|
|
|
} else if ( (i == 60) && (!found) ) {
|
|
|
|
buf.append("selected ");
|
|
|
|
}
|
2004-07-24 02:06:07 +00:00
|
|
|
buf.append(">");
|
2004-11-21 23:23:42 +00:00
|
|
|
buf.append(i).append(" seconds</option>\n");
|
2004-07-24 02:06:07 +00:00
|
|
|
}
|
|
|
|
buf.append("</select>\n");
|
|
|
|
return buf.toString();
|
|
|
|
}
|
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 String getSharePercentageBox() {
|
|
|
|
String pctStr = _context.getProperty(PROP_SHARE_PERCENTAGE);
|
|
|
|
int pct = DEFAULT_SHARE_PERCENTAGE;
|
|
|
|
if (pctStr != null)
|
|
|
|
try { pct = Integer.parseInt(pctStr); } catch (NumberFormatException nfe) {}
|
|
|
|
StringBuffer buf = new StringBuffer(256);
|
|
|
|
buf.append("<select name=\"sharePercentage\">\n");
|
|
|
|
boolean found = false;
|
|
|
|
for (int i = 30; i <= 100; i += 10) {
|
|
|
|
buf.append("<option value=\"").append(i).append("\" ");
|
|
|
|
if (pct == i) {
|
|
|
|
buf.append("selected=\"true\" ");
|
|
|
|
found = true;
|
|
|
|
} else if ( (i == DEFAULT_SHARE_PERCENTAGE) && (!found) ) {
|
|
|
|
buf.append("selected=\"true\" ");
|
|
|
|
}
|
|
|
|
buf.append(">Up to ").append(i).append("%</option>\n");
|
|
|
|
}
|
|
|
|
buf.append("</select>\n");
|
|
|
|
return buf.toString();
|
|
|
|
}
|
2004-07-24 02:06:07 +00:00
|
|
|
}
|