diff --git a/apps/routerconsole/java/src/net/i2p/router/web/NetDbRenderer.java b/apps/routerconsole/java/src/net/i2p/router/web/NetDbRenderer.java index 199c076053..2d33188239 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/NetDbRenderer.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/NetDbRenderer.java @@ -142,9 +142,50 @@ class NetDbRenderer { int rapCount = 0; BigInteger median = null; int c = 0; + + + // Summary + FloodfillNetworkDatabaseFacade netdb = (FloodfillNetworkDatabaseFacade)_context.netDb(); + if (debug) { + buf.append("\n"); + } else { + buf.append("
\n"); + } + buf.append("") + .append("\n") + .append("\n"); + if (debug) { + buf.append("\n") + .append("") + .append("\n") + .append("") + .append("\n"); + } + int ff = _context.peerManager().getPeersByCapability(FloodfillNetworkDatabaseFacade.CAPABILITY_FLOODFILL).size(); + buf.append("\n") + .append("\n"); + if (debug) { + buf.append("") + .append("\n"); + // 2 for 4 floodfills... -1 for median + // this can be way off for unknown reasons + int total = (int) Math.round(Math.pow(2, 2 + 256 - 1 - log2)); + buf.append("\n"); + buf.append("\n"); + } + buf.append("
Leaseset SummaryConfigure Floodfill Participation
Total Leasesets:").append(leases.size()).append("
Published (RAP) Leasesets:").append(netdb.getKnownLeaseSets()).append("
Mod Data:").append(DataHelper.getUTF8(_context.routerKeyGenerator().getModData())).append("Last Changed:").append(new Date(_context.routerKeyGenerator().getLastChanged())).append("
Next Mod Data:").append(DataHelper.getUTF8(_context.routerKeyGenerator().getNextModData())).append("Change in:").append(DataHelper.formatDuration(_context.routerKeyGenerator().getTimeTillMidnight())).append("
Known Floodfills:").append(ff).append("
Currently Floodfill?").append(netdb.floodfillEnabled() ? "yes" : "no").append("
Network data (only valid if floodfill):"); + //buf.append("

Center of Key Space (router hash): " + ourRKey.toBase64()); + if (median != null) { + double log2 = biLog2(median); + buf.append("

Median distance (bits):").append(fmt.format(log2)).append("
Estimated total floodfills:").append(total).append("
Estimated total leasesets:").append(total * rapCount / 4); + } else { + buf.append("Not floodfill or no data."); + } + buf.append("
\n"); + if (leases.isEmpty()) { if (!debug) - buf.append("").append(_t("none")).append(""); + buf.append("
").append(_t("No Leasesets currently active.")).append("
"); } else { if (debug) { // Find the center of the RAP leasesets @@ -154,109 +195,91 @@ class NetDbRenderer { } medianCount = rapCount / 2; } + long now = _context.clock().now(); for (LeaseSet ls : leases) { Destination dest = ls.getDestination(); Hash key = dest.calculateHash(); - buf.append("").append(_t("LeaseSet")).append(": ").append(key.toBase64()).append("\n"); + buf.append("\n") + .append(""); if (_context.clientManager().isLocal(dest)) { - buf.append(" (" + _t("Local") + " "); + buf.append("\n"); String host = _context.namingService().reverseLookup(dest); if (host == null) { - buf.append("").append(_t("Add to local addressbook")).append("
\n"); + buf.append(""); } } else { - buf.append(" (").append(_t("Destination")).append(' '); + buf.append(""); } else { String b32 = dest.toBase32(); - buf.append(dest.toBase64().substring(0, 6)).append(")
\n" + - "").append(b32).append("
\n" + - "").append(_t("Add to local addressbook")).append("
\n"); + buf.append("").append(dest.toBase64().substring(0, 6)).append("") + .append("\n") + .append("\n") + .append(""); } } + buf.append("\n\n"); if (debug) { - buf.append("RAP? " + ls.getReceivedAsPublished()); - buf.append(" RAR? " + ls.getReceivedAsReply()); + buf.append("\n\n"); + } for (int i = 0; i < ls.getLeaseCount(); i++) { Lease lease = ls.getLease(i); - buf.append(_t("Lease")).append(' ').append(i + 1).append(": ").append(_t("Gateway")).append(' '); + buf.append("\n"); } - buf.append("
\n"); + buf.append("
").append(_t("LeaseSet")).append(": ").append(key.toBase64()).append("" + _t("Local") + " "); if (! _context.clientManager().shouldPublishLeaseSet(key)) buf.append(_t("Unpublished") + ' '); - buf.append(_t("Destination") + ' '); + buf.append("").append(_t("Destination")).append(": "); TunnelPoolSettings in = _context.tunnelManager().getInboundSettings(key); if (in != null && in.getDestinationNickname() != null) buf.append(in.getDestinationNickname()); else buf.append(dest.toBase64().substring(0, 6)); - buf.append(")
\n"); + buf.append("
"); String b32 = dest.toBase32(); - buf.append("").append(b32).append("
\n"); + buf.append("").append(b32).append("
").append("").append(_t("Add to local addressbook")).append("").append(_t("Destination")).append(": "); String host = _context.namingService().reverseLookup(dest); if (host != null) { - buf.append("").append(host).append(")
\n"); + buf.append("").append(host).append("
").append(b32).append("").append(_t("Add to local addressbook")).append("
\n"); long exp = ls.getLatestLeaseDate()-now; if (exp > 0) - buf.append(_t("Expires in {0}", DataHelper.formatDuration2(exp))); + buf.append("").append(_t("Expires in {0}", DataHelper.formatDuration2(exp))).append(""); else - buf.append(_t("Expired {0} ago", DataHelper.formatDuration2(0-exp))); - buf.append("
\n"); + buf.append("").append(_t("Expired {0} ago", DataHelper.formatDuration2(0-exp))).append(""); + buf.append("
"); + buf.append("RAP? ").append(ls.getReceivedAsPublished()); + buf.append(" RAR? ").append(ls.getReceivedAsReply()); BigInteger dist = HashDistance.getDistance(ourRKey, ls.getRoutingKey()); if (ls.getReceivedAsPublished()) { if (c++ == medianCount) median = dist; } - buf.append(" Dist: ").append(fmt.format(biLog2(dist))).append("
"); + buf.append(" Distance: ").append(fmt.format(biLog2(dist))).append(""); + buf.append("
"); //buf.append(dest.toBase32()).append("
"); - buf.append("Sig type: ").append(dest.getSigningPublicKey().getType()).append("
"); - buf.append("Routing Key: ").append(ls.getRoutingKey().toBase64()); - buf.append("
"); - buf.append("Encryption Key: ").append(ls.getEncryptionKey().toBase64().substring(0, 20)).append("...
"); + buf.append("Signature type: ").append(dest.getSigningPublicKey().getType()); + buf.append(" Encryption Key: ").append(ls.getEncryptionKey().toBase64().substring(0, 20)).append("…"); + buf.append("
"); + buf.append("Routing Key: ").append(ls.getRoutingKey().toBase64()); + buf.append("
"); + buf.append("").append(_t("Lease")).append(' ').append(i + 1).append(": ").append(_t("Gateway")).append(' '); buf.append(_context.commSystem().renderPeerHTML(lease.getGateway())); buf.append(' ').append(_t("Tunnel")).append(' ').append(lease.getTunnelId().getTunnelId()).append(' '); if (debug) { long exl = lease.getEndDate().getTime() - now; if (exl > 0) - buf.append(_t("Expires in {0}", DataHelper.formatDuration2(exl))); + buf.append("").append(_t("Expires in {0}", DataHelper.formatDuration2(exl))).append(""); else - buf.append(_t("Expired {0} ago", DataHelper.formatDuration2(0-exl))); + buf.append("").append(_t("Expired {0} ago", DataHelper.formatDuration2(0-exl))).append(""); } - buf.append("
\n"); + buf.append("
\n"); out.write(buf.toString()); buf.setLength(0); } // for each } // !empty - if (debug) { - FloodfillNetworkDatabaseFacade netdb = (FloodfillNetworkDatabaseFacade)_context.netDb(); - buf.append("

Total Leasesets: ").append(leases.size()); - buf.append("

Published (RAP) Leasesets: ").append(netdb.getKnownLeaseSets()); - buf.append("

Mod Data: \"").append(DataHelper.getUTF8(_context.routerKeyGenerator().getModData())) - .append("\" Last Changed: ").append(new Date(_context.routerKeyGenerator().getLastChanged())); - buf.append("

Next Mod Data: \"").append(DataHelper.getUTF8(_context.routerKeyGenerator().getNextModData())) - .append("\" Change in: ").append(DataHelper.formatDuration(_context.routerKeyGenerator().getTimeTillMidnight())); - int ff = _context.peerManager().getPeersByCapability(FloodfillNetworkDatabaseFacade.CAPABILITY_FLOODFILL).size(); - buf.append("

Known Floodfills: ").append(ff); - buf.append("

Currently Floodfill? "); - buf.append(netdb.floodfillEnabled() ? "yes" : "no"); - buf.append("

Network data (only valid if floodfill):"); - //buf.append("

Center of Key Space (router hash): " + ourRKey.toBase64()); - if (median != null) { - double log2 = biLog2(median); - buf.append("

Median distance (bits): ").append(fmt.format(log2)); - // 2 for 4 floodfills... -1 for median - // this can be way off for unknown reasons - int total = (int) Math.round(Math.pow(2, 2 + 256 - 1 - log2)); - buf.append("

Estimated total floodfills: ").append(total); - buf.append("

Estimated total leasesets: ").append(total * rapCount / 4); - } else { - buf.append("

Not floodfill or no data"); - } - buf.append("

"); - } out.write(buf.toString()); out.flush(); } @@ -448,31 +471,39 @@ class NetDbRenderer { */ private void renderRouterInfo(StringBuilder buf, RouterInfo info, boolean isUs, boolean full) { String hash = info.getIdentity().getHash().toBase64(); - buf.append("
"); + buf.append("") + .append("\n"); long age = _context.clock().now() - info.getPublished(); if (isUs && _context.router().isHidden()) { - buf.append("").append(_t("Hidden")).append(", ").append(_t("Updated")).append(": ") - .append(_t("{0} ago", DataHelper.formatDuration2(age))).append("
\n"); + buf.append("") + .append(""); } else if (age > 0) { - buf.append("").append(_t("Published")).append(": ") - .append(_t("{0} ago", DataHelper.formatDuration2(age))).append("
\n"); + buf.append("") + .append(""); } else { // shouldnt happen - buf.append("" + _t("Published") + ": in ").append(DataHelper.formatDuration2(0-age)).append("???
\n"); + buf.append(""); } + buf.append("\n\n") + .append("") + .append("\n"); if (full) { - buf.append("
"); if (isUs) { - buf.append("" + _t("Our info") + ": ").append(hash).append("
\n"); + buf.append("" + _t("Our info") + ": ").append(hash).append(""); } else { - buf.append("" + _t("Peer info for") + ": ").append(hash).append("\n"); + buf.append("" + _t("Peer info for") + ": ").append(hash).append(""); if (!full) { - buf.append("[").append(_t("Full entry")).append("]"); + buf.append("").append(_t("Full entry")).append(""); } - buf.append("
\n"); } - + buf.append("
").append(_t("Hidden")).append(", ").append(_t("Updated")).append(":") + .append(_t("{0} ago", DataHelper.formatDuration2(age))) + .append("").append(_t("Published")).append(":") + .append(_t("{0} ago", DataHelper.formatDuration2(age))) + .append("").append(_t("Published")).append(": in ").append(DataHelper.formatDuration2(0-age)).append("???
"); buf.append("").append(_t("Signing Key")).append(": ") + .append("") .append(info.getIdentity().getSigningPublicKey().getType().toString()); - buf.append("
\n" + _t("Address(es)") + ": "); + buf.append("
" + _t("Address(es)") + ":"); String country = _context.commSystem().getCountry(info.getIdentity().getHash()); if(country != null) { buf.append("\"").append(country.toUpperCase(Locale.US)).append('\"');
" + _t("Stats") + ":
"); + buf.append("
" + _t("Stats") + ":"); Map p = info.getOptionsMap(); for (Map.Entry e : p.entrySet()) { String key = (String) e.getKey(); diff --git a/apps/routerconsole/java/src/net/i2p/router/web/SybilRenderer.java b/apps/routerconsole/java/src/net/i2p/router/web/SybilRenderer.java index abc818f119..a9879448fa 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/SybilRenderer.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/SybilRenderer.java @@ -189,12 +189,13 @@ class SybilRenderer { tot += d; } double avgMinDist = tot / count; - buf.append("

Average closest floodfill distance: " + fmt.format(avgMinDist) + "

"); - buf.append("

Routing Data: \"").append(DataHelper.getUTF8(_context.routerKeyGenerator().getModData())) - .append("\" Last Changed: ").append(new Date(_context.routerKeyGenerator().getLastChanged())); - buf.append("

Next Routing Data: \"").append(DataHelper.getUTF8(_context.routerKeyGenerator().getNextModData())) - .append("\" Rotates in: ").append(DataHelper.formatDuration(_context.routerKeyGenerator().getTimeTillMidnight())); - buf.append("

"); + buf.append("
\n"); + buf.append("Average closest floodfill distance: ").append(fmt.format(avgMinDist)).append("
\n"); + buf.append("Routing Data: \"").append(DataHelper.getUTF8(_context.routerKeyGenerator().getModData())) + .append("\" Last Changed: ").append(new Date(_context.routerKeyGenerator().getLastChanged())).append("
\n"); + buf.append("Next Routing Data: \"").append(DataHelper.getUTF8(_context.routerKeyGenerator().getNextModData())) + .append("\" Rotates in: ").append(DataHelper.formatDuration(_context.routerKeyGenerator().getTimeTillMidnight())).append("\n"); + buf.append("
\n"); Map points = new HashMap(64); @@ -760,35 +761,35 @@ class SybilRenderer { */ private double renderRouterInfo(StringBuilder buf, RouterInfo info, Hash us, boolean isUs, boolean full) { String hash = info.getIdentity().getHash().toBase64(); - buf.append("
"); + buf.append(""); double distance = 0; if (isUs) { - buf.append("" + _t("Our info") + ": ").append(hash).append("\n"); } else { - buf.append("" + _t("Router") + ": ").append(hash).append("\n"); + buf.append("\n"); if (us != null) { BigInteger dist = HashDistance.getDistance(us, info.getHash()); distance = biLog2(dist); - buf.append("Hash Distance: ").append(fmt.format(distance)).append("
"); + buf.append("\n"); } } - buf.append("Routing Key: ").append(info.getRoutingKey().toBase64()).append("
\n"); - buf.append("Version: ").append(DataHelper.stripHTML(info.getVersion())).append("
\n"); - buf.append("Caps: ").append(DataHelper.stripHTML(info.getCapabilities())).append("
\n"); + buf.append("\n"); + buf.append("\n"); + buf.append("\n"); String fam = info.getOption("family"); if (fam != null) - buf.append("Family: ").append(DataHelper.escapeHTML(fam)).append("
\n"); + buf.append("\n"); String kls = info.getOption("netdb.knownLeaseSets"); if (kls != null) - buf.append("Lease Sets: ").append(DataHelper.stripHTML(kls)).append("
\n"); + buf.append("\n"); String kr = info.getOption("netdb.knownRouters"); if (kr != null) - buf.append("Routers: ").append(DataHelper.stripHTML(kr)).append("
\n"); + buf.append("\n"); long now = _context.clock().now(); if (!isUs) { @@ -797,46 +798,46 @@ class SybilRenderer { long heard = prof.getFirstHeardAbout(); if (heard > 0) { long age = Math.max(now - heard, 1); - buf.append("First heard about: ") - .append(_t("{0} ago", DataHelper.formatDuration2(age))).append("
\n"); + buf.append("\n"); } heard = prof.getLastHeardAbout(); if (heard > 0) { long age = Math.max(now - heard, 1); - buf.append("Last heard about: ") - .append(_t("{0} ago", DataHelper.formatDuration2(age))).append("
\n"); + buf.append("\n"); } heard = prof.getLastHeardFrom(); if (heard > 0) { long age = Math.max(now - heard, 1); - buf.append("Last heard from: ") - .append(_t("{0} ago", DataHelper.formatDuration2(age))).append("
\n"); + buf.append("\n"); } DBHistory dbh = prof.getDBHistory(); if (dbh != null) { heard = dbh.getLastLookupSuccessful(); if (heard > 0) { long age = Math.max(now - heard, 1); - buf.append("Last lookup successful: ") - .append(_t("{0} ago", DataHelper.formatDuration2(age))).append("
\n"); + buf.append("\n"); } heard = dbh.getLastLookupFailed(); if (heard > 0) { long age = Math.max(now - heard, 1); - buf.append("Last lookup failed: ") - .append(_t("{0} ago", DataHelper.formatDuration2(age))).append("
\n"); + buf.append("\n"); } heard = dbh.getLastStoreSuccessful(); if (heard > 0) { long age = Math.max(now - heard, 1); - buf.append("Last store successful: ") - .append(_t("{0} ago", DataHelper.formatDuration2(age))).append("
\n"); + buf.append("\n"); } heard = dbh.getLastStoreFailed(); if (heard > 0) { long age = Math.max(now - heard, 1); - buf.append("Last store failed: ") - .append(_t("{0} ago", DataHelper.formatDuration2(age))).append("
\n"); + buf.append("\n"); } } // any other profile stuff? @@ -844,15 +845,15 @@ class SybilRenderer { } long age = Math.max(now - info.getPublished(), 1); if (isUs && _context.router().isHidden()) { - buf.append("").append(_t("Hidden")).append(", ").append(_t("Updated")).append(": ") - .append(_t("{0} ago", DataHelper.formatDuration2(age))).append("
\n"); + buf.append("\n"); } else { - buf.append("").append(_t("Published")).append(": ") - .append(_t("{0} ago", DataHelper.formatDuration2(age))).append("
\n"); + buf.append("\n"); } - buf.append("").append(_t("Signing Key")).append(": ") - .append(info.getIdentity().getSigningPublicKey().getType().toString()); - buf.append("
\n" + _t("Addresses") + ": "); + buf.append("\n"); + buf.append("
\n"); + buf.append("" + _t("Our info") + ": ").append(hash).append("
" + _t("Router") + ": ").append(hash).append("\n"); if (!full) { - buf.append("[").append(_t("Full entry")).append("]"); + buf.append("").append(_t("Full entry")).append(""); } - buf.append(" "); - buf.append("
\n"); + buf.append(" "); + buf.append("
Hash Distance:").append(fmt.format(distance)).append("
Routing Key:").append(info.getRoutingKey().toBase64()).append("
Version:").append(DataHelper.stripHTML(info.getVersion())).append("
Caps:").append(DataHelper.stripHTML(info.getCapabilities())).append("
Family:").append(DataHelper.escapeHTML(fam)).append("
Lease Sets:").append(DataHelper.stripHTML(kls)).append("
Routers:").append(DataHelper.stripHTML(kr)).append("
First heard about:") + .append(_t("{0} ago", DataHelper.formatDuration2(age))).append("
Last heard about:") + .append(_t("{0} ago", DataHelper.formatDuration2(age))).append("
Last heard from:") + .append(_t("{0} ago", DataHelper.formatDuration2(age))).append("
Last lookup successful:") + .append(_t("{0} ago", DataHelper.formatDuration2(age))).append("
Last lookup failed: ") + .append(_t("{0} ago", DataHelper.formatDuration2(age))).append("
Last store successful:") + .append(_t("{0} ago", DataHelper.formatDuration2(age))).append("
Last store failed:") + .append(_t("{0} ago", DataHelper.formatDuration2(age))).append("
").append(_t("Hidden")).append(", ").append(_t("Updated")).append(":") + .append(_t("{0} ago", DataHelper.formatDuration2(age))).append("
").append(_t("Published")).append(":") + .append(_t("{0} ago", DataHelper.formatDuration2(age))).append("
").append(_t("Signing Key")).append(":") + .append(info.getIdentity().getSigningPublicKey().getType().toString()).append("
" + _t("Addresses") + ":"); String country = _context.commSystem().getCountry(info.getIdentity().getHash()); if(country != null) { buf.append("