forked from I2P_Developers/i2p.i2p
Add a bunch of ids and classes to routerconsole HTML for styling
This commit is contained in:
@@ -154,15 +154,15 @@ class SybilRenderer {
|
||||
ris.add(ri);
|
||||
}
|
||||
if (ris.isEmpty()) {
|
||||
out.write("<h3>No known floodfills</h3>");
|
||||
out.write("<h3 class=\"sybils\">No known floodfills</h3>");
|
||||
return;
|
||||
}
|
||||
|
||||
StringBuilder buf = new StringBuilder(4*1024);
|
||||
buf.append("<p><b>This is an experimental network database tool for debugging and analysis. Do not panic even if you see warnings below. " +
|
||||
buf.append("<p id=\"sybilinfo\"><b>This is an experimental network database tool for debugging and analysis. Do not panic even if you see warnings below. " +
|
||||
"Possible \"threats\" are summarized at the bottom, however these are unlikely to be real threats. " +
|
||||
"If you see anything you would like to discuss with the devs, contact us on IRC #i2p-dev.</b></p>" +
|
||||
"<ul><li><a href=\"#known\">FF Summary</a>" +
|
||||
"<div id=\"sybilnav\"><ul><li><a href=\"#known\">FF Summary</a>" +
|
||||
"</li><li><a href=\"#family\">Same Family</a>" +
|
||||
"</li><li><a href=\"#ourIP\">IP close to us</a>" +
|
||||
"</li><li><a href=\"#sameIP\">Same IP</a>" +
|
||||
@@ -174,10 +174,10 @@ class SybilRenderer {
|
||||
"</li><li><a href=\"#dht\">DHT neighbors</a>" +
|
||||
"</li><li><a href=\"#dest\">Close to our destinations</a>" +
|
||||
"</li><li><a href=\"#threats\">Highest threats</a>" +
|
||||
"</li></ul>");
|
||||
"</li></ul></div>");
|
||||
|
||||
renderRouterInfo(buf, _context.router().getRouterInfo(), null, true, false);
|
||||
buf.append("<h3 id=\"known\">Known Floodfills: ").append(ris.size()).append("</h3>");
|
||||
buf.append("<h3 id=\"known\" class=\"sybils\">Known Floodfills: ").append(ris.size()).append("</h3>");
|
||||
|
||||
double tot = 0;
|
||||
int count = 200;
|
||||
@@ -209,18 +209,18 @@ class SybilRenderer {
|
||||
renderPairDistance(out, buf, ris, points);
|
||||
|
||||
// Distance to our router analysis
|
||||
buf.append("<h3 id=\"ritoday\">Closest Floodfills to Our Routing Key (Where we Store our RI)</h3>");
|
||||
buf.append("<h3 id=\"ritoday\" class=\"sybils\">Closest Floodfills to Our Routing Key (Where we Store our RI)</h3>");
|
||||
renderRouterInfoHTML(out, buf, ourRKey, avgMinDist, ris, points);
|
||||
RouterKeyGenerator rkgen = _context.routerKeyGenerator();
|
||||
Hash nkey = rkgen.getNextRoutingKey(us);
|
||||
buf.append("<h3 id=\"ritmrw\">Closest Floodfills to Tomorrow's Routing Key (Where we will Store our RI)</h3>");
|
||||
buf.append("<h3 id=\"ritmrw\" class=\"sybils\">Closest Floodfills to Tomorrow's Routing Key (Where we will Store our RI)</h3>");
|
||||
renderRouterInfoHTML(out, buf, nkey, avgMinDist, ris, points);
|
||||
|
||||
buf.append("<h3 id=\"dht\">Closest Floodfills to Our Router Hash (DHT Neighbors if we are Floodfill)</h3>");
|
||||
buf.append("<h3 id=\"dht\" class=\"sybils\">Closest Floodfills to Our Router Hash (DHT Neighbors if we are Floodfill)</h3>");
|
||||
renderRouterInfoHTML(out, buf, us, avgMinDist, ris, points);
|
||||
|
||||
// Distance to our published destinations analysis
|
||||
buf.append("<h3 id=\"dest\">Floodfills Close to Our Destinations</h3>");
|
||||
buf.append("<h3 id=\"dest\" class=\"sybils\">Floodfills Close to Our Destinations</h3>");
|
||||
Map<Hash, TunnelPool> clientInboundPools = _context.tunnelManager().getInboundClientPools();
|
||||
List<Hash> destinations = new ArrayList<Hash>(clientInboundPools.keySet());
|
||||
boolean debug = _context.getBooleanProperty(HelperBase.PROP_ADVANCED);
|
||||
@@ -236,10 +236,10 @@ class SybilRenderer {
|
||||
Hash rkey = ls.getRoutingKey();
|
||||
TunnelPool in = clientInboundPools.get(client);
|
||||
String name = (in != null) ? in.getSettings().getDestinationNickname() : client.toBase64().substring(0,4);
|
||||
buf.append("<h3>Closest floodfills to the Routing Key for " + DataHelper.escapeHTML(name) + " (where we store our LS)</h3>");
|
||||
buf.append("<h3 class=\"sybils\">Closest floodfills to the Routing Key for " + DataHelper.escapeHTML(name) + " (where we store our LS)</h3>");
|
||||
renderRouterInfoHTML(out, buf, rkey, avgMinDist, ris, points);
|
||||
nkey = rkgen.getNextRoutingKey(ls.getHash());
|
||||
buf.append("<h3>Closest floodfills to Tomorrow's Routing Key for " + DataHelper.escapeHTML(name) + " (where we will store our LS)</h3>");
|
||||
buf.append("<h3 class=\"sybils\">Closest floodfills to Tomorrow's Routing Key for " + DataHelper.escapeHTML(name) + " (where we will store our LS)</h3>");
|
||||
renderRouterInfoHTML(out, buf, nkey, avgMinDist, ris, points);
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ class SybilRenderer {
|
||||
if (!points.isEmpty()) {
|
||||
List<Hash> warns = new ArrayList<Hash>(points.keySet());
|
||||
Collections.sort(warns, new PointsComparator(points));
|
||||
buf.append("<h3 id=\"threats\">Routers with Most Threat Points</h3>");
|
||||
buf.append("<h3 id=\"threats\" class=\"sybils\">Routers with Most Threat Points</h3>");
|
||||
for (Hash h : warns) {
|
||||
RouterInfo ri = _context.netDb().lookupRouterInfoLocally(h);
|
||||
if (ri == null)
|
||||
@@ -259,7 +259,7 @@ class SybilRenderer {
|
||||
double p = pp.points;
|
||||
if (p < MIN_DISPLAY_POINTS)
|
||||
break; // sorted
|
||||
buf.append("<p><b>Threat Points: " + fmt.format(p) + "</b><ul>");
|
||||
buf.append("<p class=\"threatpoints\"><b>Threat Points: " + fmt.format(p) + "</b><ul>");
|
||||
for (String s : pp.reasons) {
|
||||
buf.append("<li>").append(s).append("</li>");
|
||||
}
|
||||
@@ -307,9 +307,9 @@ class SybilRenderer {
|
||||
}
|
||||
|
||||
double avg = total / (sz * sz / 2);
|
||||
buf.append("<h3>Average Floodfill Distance is ").append(fmt.format(avg)).append("</h3>");
|
||||
buf.append("<h3 class=\"sybils\">Average Floodfill Distance is ").append(fmt.format(avg)).append("</h3>");
|
||||
|
||||
buf.append("<h3 id=\"pairs\">Closest Floodfill Pairs by Hash</h3>");
|
||||
buf.append("<h3 id=\"pairs\" class=\"sybils\">Closest Floodfill Pairs by Hash</h3>");
|
||||
for (Pair p : pairs) {
|
||||
double distance = biLog2(p.dist);
|
||||
double point = MIN_CLOSE - distance;
|
||||
@@ -317,7 +317,7 @@ class SybilRenderer {
|
||||
break; // sorted;
|
||||
if (point >= 2) {
|
||||
// limit display
|
||||
buf.append("<p><b>Hash Distance: ").append(fmt.format(distance)).append(": </b>");
|
||||
buf.append("<p class=\"hashdist\"><b>Hash Distance: ").append(fmt.format(distance)).append(": </b>");
|
||||
buf.append("</p>");
|
||||
renderRouterInfo(buf, p.r1, null, false, false);
|
||||
renderRouterInfo(buf, p.r2, null, false, false);
|
||||
@@ -386,14 +386,14 @@ class SybilRenderer {
|
||||
byte[] ourIP = getIP(us);
|
||||
if (ourIP == null)
|
||||
return;
|
||||
buf.append("<h3 \"ourIP\">Floodfills close to Our IP</h3>");
|
||||
buf.append("<h3 id=\"ourIP\" class=\"sybils\">Floodfills close to Our IP</h3>");
|
||||
boolean found = false;
|
||||
for (RouterInfo info : ris) {
|
||||
byte[] ip = getIP(info);
|
||||
if (ip == null)
|
||||
continue;
|
||||
if (ip[0] == ourIP[0] && ip[1] == ourIP[1]) {
|
||||
buf.append("<p><b>");
|
||||
buf.append("<p id=\"sybil_floodfill\"><b>");
|
||||
if (ip[2] == ourIP[2]) {
|
||||
if (ip[3] == ourIP[3]) {
|
||||
buf.append("Same IP as us");
|
||||
@@ -412,14 +412,14 @@ class SybilRenderer {
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
buf.append("<p>None</p>");
|
||||
buf.append("<p class=\"notfound\">None</p>");
|
||||
out.write(buf.toString());
|
||||
out.flush();
|
||||
buf.setLength(0);
|
||||
}
|
||||
|
||||
private void renderIPGroups32(Writer out, StringBuilder buf, List<RouterInfo> ris, Map<Hash, Points> points) throws IOException {
|
||||
buf.append("<h3 id=\"sameIP\">Floodfills with the Same IP</h3>");
|
||||
buf.append("<h3 id=\"sameIP\" class=\"sybils\">Floodfills with the Same IP</h3>");
|
||||
ObjectCounter<Integer> oc = new ObjectCounter<Integer>();
|
||||
for (RouterInfo info : ris) {
|
||||
byte[] ip = getIP(info);
|
||||
@@ -443,7 +443,7 @@ class SybilRenderer {
|
||||
int i1 = (i >> 16) & 0xff;
|
||||
int i2 = (i >> 8) & 0xff;
|
||||
int i3 = i & 0xff;
|
||||
buf.append("<p><b>").append(count).append(" floodfills with IP ").append(i0).append('.')
|
||||
buf.append("<p class=\"sybil_floodfill\"><b>").append(count).append(" floodfills with IP ").append(i0).append('.')
|
||||
.append(i1).append('.').append(i2).append('.').append(i3)
|
||||
.append(":</b></p>");
|
||||
for (RouterInfo info : ris) {
|
||||
@@ -465,14 +465,14 @@ class SybilRenderer {
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
buf.append("<p>None</p>");
|
||||
buf.append("<p class=\"notfound\">None</p>");
|
||||
out.write(buf.toString());
|
||||
out.flush();
|
||||
buf.setLength(0);
|
||||
}
|
||||
|
||||
private void renderIPGroups24(Writer out, StringBuilder buf, List<RouterInfo> ris, Map<Hash, Points> points) throws IOException {
|
||||
buf.append("<h3 id=\"same24\">Floodfills in the Same /24 (2 minimum)</h3>");
|
||||
buf.append("<h3 id=\"same24\" class=\"sybils\">Floodfills in the Same /24 (2 minimum)</h3>");
|
||||
ObjectCounter<Integer> oc = new ObjectCounter<Integer>();
|
||||
for (RouterInfo info : ris) {
|
||||
byte[] ip = getIP(info);
|
||||
@@ -495,7 +495,7 @@ class SybilRenderer {
|
||||
int i0 = i >> 16;
|
||||
int i1 = (i >> 8) & 0xff;
|
||||
int i2 = i & 0xff;
|
||||
buf.append("<p><b>").append(count).append(" floodfills in ").append(i0).append('.')
|
||||
buf.append("<p class=\"sybil_floodfill\"><b>").append(count).append(" floodfills in ").append(i0).append('.')
|
||||
.append(i1).append('.').append(i2).append(".0/24:</b></p>");
|
||||
for (RouterInfo info : ris) {
|
||||
byte[] ip = getIP(info);
|
||||
@@ -514,14 +514,14 @@ class SybilRenderer {
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
buf.append("<p>None</p>");
|
||||
buf.append("<p class=\"notfound\">None</p>");
|
||||
out.write(buf.toString());
|
||||
out.flush();
|
||||
buf.setLength(0);
|
||||
}
|
||||
|
||||
private void renderIPGroups16(Writer out, StringBuilder buf, List<RouterInfo> ris, Map<Hash, Points> points) throws IOException {
|
||||
buf.append("<h3 id=\"same16\">Floodfills in the Same /16 (4 minimum)</h3>");
|
||||
buf.append("<h3 id=\"same16\" class=\"sybils\">Floodfills in the Same /16 (4 minimum)</h3>");
|
||||
ObjectCounter<Integer> oc = new ObjectCounter<Integer>();
|
||||
for (RouterInfo info : ris) {
|
||||
byte[] ip = getIP(info);
|
||||
@@ -543,7 +543,7 @@ class SybilRenderer {
|
||||
int i = ii.intValue();
|
||||
int i0 = i >> 8;
|
||||
int i1 = i & 0xff;
|
||||
buf.append("<p><b>").append(count).append(" floodfills in ").append(i0).append('.')
|
||||
buf.append("<p class=\"sybil_floodfill\"><b>").append(count).append(" floodfills in ").append(i0).append('.')
|
||||
.append(i1).append(".0.0/16</b></p>");
|
||||
for (RouterInfo info : ris) {
|
||||
byte[] ip = getIP(info);
|
||||
@@ -561,14 +561,14 @@ class SybilRenderer {
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
buf.append("<p>None</p>");
|
||||
buf.append("<p class=\"notfound\">None</p>");
|
||||
out.write(buf.toString());
|
||||
out.flush();
|
||||
buf.setLength(0);
|
||||
}
|
||||
|
||||
private void renderIPGroupsFamily(Writer out, StringBuilder buf, List<RouterInfo> ris, Map<Hash, Points> points) throws IOException {
|
||||
buf.append("<h3>Floodfills in the Same Declared Family</h3>");
|
||||
buf.append("<h3 id=\"samefamily\" class=\"sybils\">Floodfills in the Same Declared Family</h3>");
|
||||
ObjectCounter<String> oc = new ObjectCounter<String>();
|
||||
for (RouterInfo info : ris) {
|
||||
String fam = info.getOption("family");
|
||||
@@ -581,7 +581,7 @@ class SybilRenderer {
|
||||
boolean found = false;
|
||||
for (String s : foo) {
|
||||
int count = oc.count(s);
|
||||
buf.append("<p><b>").append(count).append(" floodfills in declared family \"").append(DataHelper.escapeHTML(s) + '"')
|
||||
buf.append("<p id=\"family\"><b>").append(count).append(" floodfills in declared family \"").append(DataHelper.escapeHTML(s) + '"')
|
||||
.append("</b></p>");
|
||||
for (RouterInfo info : ris) {
|
||||
String fam = info.getOption("family");
|
||||
@@ -600,7 +600,7 @@ class SybilRenderer {
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
buf.append("<p>None</p>");
|
||||
buf.append("<p class=\"notfound\">None</p>");
|
||||
out.write(buf.toString());
|
||||
out.flush();
|
||||
buf.setLength(0);
|
||||
@@ -725,7 +725,7 @@ class SybilRenderer {
|
||||
break;
|
||||
}
|
||||
double avg = tot / count;
|
||||
buf.append("<p><b>Totals for " + count + " floodfills: </b>MIN=" + fmt.format(min) + " AVG=" + fmt.format(avg) + " MEDIAN=" + fmt.format(median) + " MAX=" + fmt.format(max) + "</p>\n");
|
||||
buf.append("<p id=\"sybil_totals\"><b>Totals for " + count + " floodfills: </b>MIN=" + fmt.format(min) + " AVG=" + fmt.format(avg) + " MEDIAN=" + fmt.format(median) + " MAX=" + fmt.format(max) + "</p>\n");
|
||||
out.write(buf.toString());
|
||||
out.flush();
|
||||
buf.setLength(0);
|
||||
|
||||
Reference in New Issue
Block a user