2004-07-24 02:06:07 +00:00
|
|
|
package net.i2p.router.web;
|
|
|
|
|
2005-02-22 07:07:29 +00:00
|
|
|
import java.text.DateFormat;
|
2004-07-24 02:06:07 +00:00
|
|
|
import java.text.DecimalFormat;
|
2005-02-22 07:07:29 +00:00
|
|
|
import java.util.Date;
|
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
|
|
|
import java.util.Iterator;
|
2005-02-22 07:07:29 +00:00
|
|
|
import java.util.Locale;
|
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
|
|
|
import java.util.Set;
|
2004-07-24 02:06:07 +00:00
|
|
|
|
|
|
|
import net.i2p.data.DataHelper;
|
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
|
|
|
import net.i2p.data.Destination;
|
|
|
|
import net.i2p.data.LeaseSet;
|
2004-07-24 02:06:07 +00:00
|
|
|
import net.i2p.stat.Rate;
|
|
|
|
import net.i2p.stat.RateStat;
|
|
|
|
import net.i2p.router.Router;
|
|
|
|
import net.i2p.router.RouterContext;
|
|
|
|
import net.i2p.router.RouterVersion;
|
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
|
|
|
import net.i2p.router.TunnelPoolSettings;
|
2004-07-24 02:06:07 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Simple helper to query the appropriate router for data necessary to render
|
|
|
|
* the summary sections on the router console.
|
|
|
|
*/
|
|
|
|
public class SummaryHelper {
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieve the shortened 4 character ident for the router located within
|
|
|
|
* the current JVM at the given context.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public String getIdent() {
|
|
|
|
if (_context == null) return "[no router]";
|
|
|
|
|
|
|
|
if (_context.routerHash() != null)
|
|
|
|
return _context.routerHash().toBase64().substring(0, 4);
|
|
|
|
else
|
|
|
|
return "[unknown]";
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Retrieve the version number of the router.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public String getVersion() {
|
2004-09-02 20:00:28 +00:00
|
|
|
return RouterVersion.VERSION + "-" + RouterVersion.BUILD;
|
2004-07-24 02:06:07 +00:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Retrieve a pretty printed uptime count (ala 4d or 7h or 39m)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public String getUptime() {
|
|
|
|
if (_context == null) return "[no router]";
|
|
|
|
|
|
|
|
Router router = _context.router();
|
|
|
|
if (router == null)
|
|
|
|
return "[not up]";
|
|
|
|
else
|
|
|
|
return DataHelper.formatDuration(router.getUptime());
|
|
|
|
}
|
2005-02-22 07:07:29 +00:00
|
|
|
|
|
|
|
private static final DateFormat _fmt = new java.text.SimpleDateFormat("HH:mm:ss", Locale.UK);
|
|
|
|
public String getTime() {
|
|
|
|
if (_context == null) return "";
|
|
|
|
|
|
|
|
String now = null;
|
|
|
|
synchronized (_fmt) {
|
|
|
|
now = _fmt.format(new Date(_context.clock().now()));
|
|
|
|
}
|
|
|
|
|
|
|
|
long ms = _context.clock().getOffset();
|
|
|
|
|
|
|
|
if (ms < 60 * 1000) {
|
|
|
|
return now + " (" + (ms / 1000) + "s)";
|
2005-03-17 05:29:55 +00:00
|
|
|
} else if (ms < 60 * 60 * 1000) {
|
2005-02-22 07:07:29 +00:00
|
|
|
return now + " (" + (ms / (60 * 1000)) + "m)";
|
|
|
|
} else if (ms < 24 * 60 * 60 * 1000) {
|
|
|
|
return now + " (" + (ms / (60 * 60 * 1000)) + "h)";
|
|
|
|
} else {
|
|
|
|
return now + " (" + (ms / (24 * 60 * 60 * 1000)) + "d)";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean allowReseed() {
|
|
|
|
return (_context.netDb().getKnownRouters() < 10);
|
|
|
|
}
|
2005-03-23 21:13:03 +00:00
|
|
|
|
2004-08-11 22:23:48 +00:00
|
|
|
/**
|
|
|
|
* Retrieve amount of used memory.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public String getMemory() {
|
2004-08-16 20:27:06 +00:00
|
|
|
DecimalFormat integerFormatter = new DecimalFormat("###,###,##0");
|
2004-08-11 22:23:48 +00:00
|
|
|
long used = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())/1024;
|
|
|
|
long usedPc = 100 - ((Runtime.getRuntime().freeMemory() * 100) / Runtime.getRuntime().totalMemory());
|
2004-08-16 20:27:06 +00:00
|
|
|
return integerFormatter.format(used) + "KB (" + usedPc + "%)";
|
2004-08-11 22:23:48 +00:00
|
|
|
}
|
2004-07-24 02:06:07 +00:00
|
|
|
|
|
|
|
/**
|
2004-09-09 02:26:42 +00:00
|
|
|
* How many peers we are talking to now
|
2004-07-24 02:06:07 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
public int getActivePeers() {
|
2004-09-09 02:26:42 +00:00
|
|
|
if (_context == null)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return _context.commSystem().countActivePeers();
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* How many active identities have we spoken with recently
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public int getActiveProfiles() {
|
2004-07-24 02:06:07 +00:00
|
|
|
if (_context == null)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return _context.profileOrganizer().countActivePeers();
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* How many active peers the router ranks as fast.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public int getFastPeers() {
|
|
|
|
if (_context == null)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return _context.profileOrganizer().countFastPeers();
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* How many active peers the router ranks as having a high capacity.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public int getHighCapacityPeers() {
|
|
|
|
if (_context == null)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return _context.profileOrganizer().countHighCapacityPeers();
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* How many active peers the router ranks as well integrated.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public int getWellIntegratedPeers() {
|
|
|
|
if (_context == null)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return _context.profileOrganizer().countWellIntegratedPeers();
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* How many peers the router ranks as failing.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public int getFailingPeers() {
|
|
|
|
if (_context == null)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return _context.profileOrganizer().countFailingPeers();
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* How many peers totally suck.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public int getShitlistedPeers() {
|
|
|
|
if (_context == null)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return _context.shitlist().getRouterCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* How fast we have been receiving data over the last minute (pretty printed
|
|
|
|
* string with 2 decimal places representing the KBps)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public String getInboundMinuteKBps() {
|
|
|
|
if (_context == null)
|
|
|
|
return "0.0";
|
|
|
|
|
|
|
|
RateStat receiveRate = _context.statManager().getRate("transport.receiveMessageSize");
|
|
|
|
Rate rate = receiveRate.getRate(60*1000);
|
|
|
|
double bytes = rate.getLastTotalValue();
|
|
|
|
double bps = (bytes*1000.0d)/(rate.getPeriod()*1024.0d);
|
|
|
|
|
|
|
|
DecimalFormat fmt = new DecimalFormat("##0.00");
|
|
|
|
return fmt.format(bps);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* How fast we have been sending data over the last minute (pretty printed
|
|
|
|
* string with 2 decimal places representing the KBps)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public String getOutboundMinuteKBps() {
|
|
|
|
if (_context == null)
|
|
|
|
return "0.0";
|
|
|
|
|
|
|
|
RateStat receiveRate = _context.statManager().getRate("transport.sendMessageSize");
|
|
|
|
Rate rate = receiveRate.getRate(60*1000);
|
|
|
|
double bytes = rate.getLastTotalValue();
|
|
|
|
double bps = (bytes*1000.0d)/(rate.getPeriod()*1024.0d);
|
|
|
|
|
|
|
|
DecimalFormat fmt = new DecimalFormat("##0.00");
|
|
|
|
return fmt.format(bps);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* How fast we have been receiving data over the last 5 minutes (pretty printed
|
|
|
|
* string with 2 decimal places representing the KBps)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public String getInboundFiveMinuteKBps() {
|
|
|
|
if (_context == null)
|
|
|
|
return "0.0";
|
|
|
|
|
|
|
|
RateStat receiveRate = _context.statManager().getRate("transport.receiveMessageSize");
|
|
|
|
Rate rate = receiveRate.getRate(5*60*1000);
|
|
|
|
double bytes = rate.getLastTotalValue();
|
|
|
|
double bps = (bytes*1000.0d)/(rate.getPeriod()*1024.0d);
|
|
|
|
|
|
|
|
DecimalFormat fmt = new DecimalFormat("##0.00");
|
|
|
|
return fmt.format(bps);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* How fast we have been sending data over the last 5 minutes (pretty printed
|
|
|
|
* string with 2 decimal places representing the KBps)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public String getOutboundFiveMinuteKBps() {
|
|
|
|
if (_context == null)
|
|
|
|
return "0.0";
|
|
|
|
|
|
|
|
RateStat receiveRate = _context.statManager().getRate("transport.sendMessageSize");
|
|
|
|
Rate rate = receiveRate.getRate(5*60*1000);
|
|
|
|
double bytes = rate.getLastTotalValue();
|
|
|
|
double bps = (bytes*1000.0d)/(rate.getPeriod()*1024.0d);
|
|
|
|
|
|
|
|
DecimalFormat fmt = new DecimalFormat("##0.00");
|
|
|
|
return fmt.format(bps);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* How fast we have been receiving data since the router started (pretty printed
|
|
|
|
* string with 2 decimal places representing the KBps)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public String getInboundLifetimeKBps() {
|
|
|
|
if (_context == null)
|
|
|
|
return "0.0";
|
|
|
|
|
|
|
|
long received = _context.bandwidthLimiter().getTotalAllocatedInboundBytes();
|
|
|
|
|
|
|
|
DecimalFormat fmt = new DecimalFormat("##0.00");
|
|
|
|
|
|
|
|
// we use the unadjusted time, since thats what getWhenStarted is based off
|
|
|
|
long lifetime = _context.clock().now()-_context.clock().getOffset()
|
|
|
|
- _context.router().getWhenStarted();
|
|
|
|
lifetime /= 1000;
|
|
|
|
if (received > 0) {
|
|
|
|
double receivedKBps = received / (lifetime*1024.0);
|
|
|
|
return fmt.format(receivedKBps);
|
|
|
|
} else {
|
|
|
|
return "0.0";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* How fast we have been sending data since the router started (pretty printed
|
|
|
|
* string with 2 decimal places representing the KBps)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public String getOutboundLifetimeKBps() {
|
|
|
|
if (_context == null)
|
|
|
|
return "0.0";
|
|
|
|
|
|
|
|
long sent = _context.bandwidthLimiter().getTotalAllocatedOutboundBytes();
|
|
|
|
|
|
|
|
DecimalFormat fmt = new DecimalFormat("##0.00");
|
|
|
|
|
|
|
|
// we use the unadjusted time, since thats what getWhenStarted is based off
|
|
|
|
long lifetime = _context.clock().now()-_context.clock().getOffset()
|
|
|
|
- _context.router().getWhenStarted();
|
|
|
|
lifetime /= 1000;
|
|
|
|
if (sent > 0) {
|
|
|
|
double sendKBps = sent / (lifetime*1024.0);
|
|
|
|
return fmt.format(sendKBps);
|
|
|
|
} else {
|
|
|
|
return "0.0";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* How much data have we received since the router started (pretty printed
|
|
|
|
* string with 2 decimal places and the appropriate units - GB/MB/KB/bytes)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public String getInboundTransferred() {
|
|
|
|
if (_context == null)
|
|
|
|
return "0.0";
|
|
|
|
|
|
|
|
long received = _context.bandwidthLimiter().getTotalAllocatedInboundBytes();
|
|
|
|
|
|
|
|
return getTransferred(received);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* How much data have we sent since the router started (pretty printed
|
|
|
|
* string with 2 decimal places and the appropriate units - GB/MB/KB/bytes)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public String getOutboundTransferred() {
|
|
|
|
if (_context == null)
|
|
|
|
return "0.0";
|
|
|
|
|
|
|
|
long sent = _context.bandwidthLimiter().getTotalAllocatedOutboundBytes();
|
|
|
|
return getTransferred(sent);
|
|
|
|
}
|
|
|
|
|
|
|
|
private static String getTransferred(long bytes) {
|
2004-09-13 03:08:16 +00:00
|
|
|
double val = bytes;
|
2004-07-24 02:06:07 +00:00
|
|
|
int scale = 0;
|
|
|
|
if (bytes > 1024*1024*1024) {
|
|
|
|
// gigs transferred
|
|
|
|
scale = 3;
|
2004-09-13 03:08:16 +00:00
|
|
|
val /= (double)(1024*1024*1024);
|
2004-07-24 02:06:07 +00:00
|
|
|
} else if (bytes > 1024*1024) {
|
|
|
|
// megs transferred
|
|
|
|
scale = 2;
|
2004-09-13 03:08:16 +00:00
|
|
|
val /= (double)(1024*1024);
|
2004-07-24 02:06:07 +00:00
|
|
|
} else if (bytes > 1024) {
|
|
|
|
// kbytes transferred
|
|
|
|
scale = 1;
|
2004-09-13 03:08:16 +00:00
|
|
|
val /= (double)1024;
|
2004-07-24 02:06:07 +00:00
|
|
|
} else {
|
|
|
|
scale = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
DecimalFormat fmt = new DecimalFormat("##0.00");
|
|
|
|
|
2004-09-13 03:08:16 +00:00
|
|
|
String str = fmt.format(val);
|
2004-07-24 02:06:07 +00:00
|
|
|
switch (scale) {
|
|
|
|
case 1: return str + "KB";
|
|
|
|
case 2: return str + "MB";
|
|
|
|
case 3: return str + "GB";
|
|
|
|
default: return bytes + "bytes";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-30 20:28:19 +00:00
|
|
|
/**
|
|
|
|
* How many client destinations are connected locally.
|
|
|
|
*
|
|
|
|
* @return html section summary
|
|
|
|
*/
|
|
|
|
public String getDestinations() {
|
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
|
|
|
Set clients = _context.clientManager().listClients();
|
|
|
|
|
|
|
|
StringBuffer buf = new StringBuffer(512);
|
|
|
|
buf.append("<u><b>Local destinations</b></u><br />");
|
|
|
|
|
|
|
|
for (Iterator iter = clients.iterator(); iter.hasNext(); ) {
|
|
|
|
Destination client = (Destination)iter.next();
|
|
|
|
TunnelPoolSettings in = _context.tunnelManager().getInboundSettings(client.calculateHash());
|
|
|
|
TunnelPoolSettings out = _context.tunnelManager().getOutboundSettings(client.calculateHash());
|
|
|
|
String name = (in != null ? in.getDestinationNickname() : null);
|
|
|
|
if (name == null)
|
|
|
|
name = (out != null ? out.getDestinationNickname() : null);
|
|
|
|
if (name == null)
|
|
|
|
name = client.calculateHash().toBase64().substring(0,6);
|
|
|
|
|
|
|
|
buf.append("<b>*</b> ").append(name).append("<br />\n");
|
|
|
|
LeaseSet ls = _context.netDb().lookupLeaseSetLocally(client.calculateHash());
|
|
|
|
if (ls != null) {
|
|
|
|
long timeToExpire = ls.getEarliestLeaseDate() - _context.clock().now();
|
|
|
|
if (timeToExpire < 0) {
|
|
|
|
buf.append("<i>expired ").append(DataHelper.formatDuration(0-timeToExpire));
|
|
|
|
buf.append(" ago</i><br />\n");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
buf.append("<i>No leases</i><br />\n");
|
|
|
|
}
|
|
|
|
buf.append("<a href=\"tunnels.jsp#").append(client.calculateHash().toBase64().substring(0,4));
|
|
|
|
buf.append("\">Details</a> ");
|
|
|
|
buf.append("<a href=\"configtunnels.jsp#").append(client.calculateHash().toBase64().substring(0,4));
|
|
|
|
buf.append("\">Config</a><br />\n");
|
2004-07-30 20:28:19 +00:00
|
|
|
}
|
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
|
|
|
buf.append("<hr />\n");
|
|
|
|
return buf.toString();
|
2004-07-30 20:28:19 +00:00
|
|
|
}
|
|
|
|
|
2004-07-24 02:06:07 +00:00
|
|
|
/**
|
|
|
|
* How many free inbound tunnels we have.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public int getInboundTunnels() {
|
|
|
|
if (_context == null)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return _context.tunnelManager().getFreeTunnelCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* How many active outbound tunnels we have.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public int getOutboundTunnels() {
|
|
|
|
if (_context == null)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return _context.tunnelManager().getOutboundTunnelCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* How many tunnels we are participating in.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public int getParticipatingTunnels() {
|
|
|
|
if (_context == null)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return _context.tunnelManager().getParticipatingCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* How lagged our job queue is over the last minute (pretty printed with
|
|
|
|
* the units attached)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public String getJobLag() {
|
|
|
|
if (_context == null)
|
|
|
|
return "0ms";
|
|
|
|
|
|
|
|
Rate lagRate = _context.statManager().getRate("jobQueue.jobLag").getRate(60*1000);
|
|
|
|
return ((int)lagRate.getAverageValue()) + "ms";
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* How long it takes us to pump out a message, averaged over the last minute
|
|
|
|
* (pretty printed with the units attached)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public String getMessageDelay() {
|
|
|
|
if (_context == null)
|
|
|
|
return "0ms";
|
|
|
|
|
2004-09-29 22:49:19 +00:00
|
|
|
return _context.throttle().getMessageDelay() + "ms";
|
2004-07-24 02:06:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* How long it takes us to test our tunnels, averaged over the last 10 minutes
|
|
|
|
* (pretty printed with the units attached)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public String getTunnelLag() {
|
|
|
|
if (_context == null)
|
|
|
|
return "0ms";
|
|
|
|
|
2004-09-29 22:49:19 +00:00
|
|
|
return _context.throttle().getTunnelLag() + "ms";
|
2004-07-24 02:06:07 +00:00
|
|
|
}
|
2005-03-23 21:13:03 +00:00
|
|
|
|
2005-03-24 01:19:52 +00:00
|
|
|
public boolean updateAvailable() {
|
2005-04-05 16:06:14 +00:00
|
|
|
return NewsFetcher.getInstance(_context).updateAvailable();
|
2005-03-24 01:19:52 +00:00
|
|
|
}
|
2004-07-24 02:06:07 +00:00
|
|
|
}
|