forked from I2P_Developers/i2p.i2p
Compare commits
1 Commits
i2p.i2p-ne
...
i2p.i2p-46
Author | SHA1 | Date | |
---|---|---|---|
d60bb12d00 |
@ -6,14 +6,12 @@ import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import net.i2p.crypto.EncType;
|
||||
import net.i2p.crypto.SigType;
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.data.Hash;
|
||||
import net.i2p.data.router.RouterInfo;
|
||||
import net.i2p.util.SystemVersion;
|
||||
import net.i2p.router.sybil.Analysis;
|
||||
import net.i2p.router.web.FormHandler;
|
||||
@ -49,16 +47,14 @@ public class NetDbHelper extends FormHandler {
|
||||
_x("Local Router"), // 1
|
||||
_x("Router Lookup"), // 2
|
||||
// advanced below here
|
||||
_x("All Routers in Floodfill NetDB"), // 3
|
||||
_x("All Routers in Floodfill NetDB with Full Stats"), // 4
|
||||
_x("All Routers"), // 3
|
||||
_x("All Routers with Full Stats"), // 4
|
||||
_x("LeaseSets"), // 5
|
||||
"LeaseSet Debug", // 6
|
||||
"Sybil", // 7
|
||||
"Advanced Lookup", // 8
|
||||
"LeaseSet Lookup", // 9
|
||||
_x("All Routers in Client NetDBs"), // 10
|
||||
_x("All Routers in Client NetDBs with Full Stats"), // 11
|
||||
_x("LeaseSets in Client NetDBs"), // 12
|
||||
"LeaseSets (Client DBs)" // 10
|
||||
};
|
||||
|
||||
private static final String links[] =
|
||||
@ -72,9 +68,7 @@ public class NetDbHelper extends FormHandler {
|
||||
"?f=3", // 7
|
||||
"?f=4", // 8
|
||||
"", // 9
|
||||
"?f=5", // 10
|
||||
"?f=6", // 11
|
||||
"?l=7", // 12
|
||||
"?l=7", // 10
|
||||
};
|
||||
|
||||
|
||||
@ -251,14 +245,6 @@ public class NetDbHelper extends FormHandler {
|
||||
_icount = Integer.parseInt(f);
|
||||
} catch (NumberFormatException nfe) {}
|
||||
}
|
||||
|
||||
public void setClientPage(String f) {
|
||||
try {
|
||||
|
||||
} catch(Exception e){
|
||||
//if (_log.shouldLog)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* call for non-text-mode browsers
|
||||
@ -326,27 +312,21 @@ public class NetDbHelper extends FormHandler {
|
||||
/**
|
||||
* storeWriter() must be called previously
|
||||
*/
|
||||
public String getFloodfillNetDbSummary() {
|
||||
return getNetDbSummary(null, false);
|
||||
}
|
||||
|
||||
public String getNetDbSummary(Hash client, boolean clientOnly) {
|
||||
public String getNetDbSummary() {
|
||||
NetDbRenderer renderer = new NetDbRenderer(_context);
|
||||
try {
|
||||
if (client == null && !clientOnly)
|
||||
renderNavBar();
|
||||
renderNavBar();
|
||||
if (_routerPrefix != null || _version != null || _country != null ||
|
||||
_family != null || _caps != null || _ip != null || _sybil != null ||
|
||||
_port != 0 || _type != null || _mtu != null || _ipv6 != null ||
|
||||
_ssucaps != null || _transport != null || _cost != 0 || _etype != null ||
|
||||
_icount > 0) {
|
||||
if (client == null && !clientOnly)
|
||||
renderer.renderRouterInfoHTML(_out, _limit, _page,
|
||||
renderer.renderRouterInfoHTML(_out, _limit, _page,
|
||||
_routerPrefix, _version, _country,
|
||||
_family, _caps, _ip, _sybil, _port, _highPort, _type, _etype,
|
||||
_mtu, _ipv6, _ssucaps, _transport, _cost, _icount, client, clientOnly);
|
||||
_mtu, _ipv6, _ssucaps, _transport, _cost, _icount);
|
||||
} else if (_lease) {
|
||||
renderer.renderLeaseSetHTML(_out, _debug, client, _clientOnly);
|
||||
renderer.renderLeaseSetHTML(_out, _debug, null);
|
||||
} else if (_hostname != null) {
|
||||
renderer.renderLeaseSet(_out, _hostname, true);
|
||||
} else if (_full == 3) {
|
||||
@ -357,18 +337,14 @@ public class NetDbHelper extends FormHandler {
|
||||
(new SybilRenderer(_context)).getNetDbSummary(_out, _newNonce, _mode, _date);
|
||||
} else if (_full == 4) {
|
||||
renderLookupForm();
|
||||
} else if (_full == 5) {
|
||||
renderer.renderStatusHTML(_out, _limit, _page, _full, null, true);
|
||||
} else if (_full == 6) {
|
||||
renderer.renderStatusHTML(_out, _limit, _page, _full, null, true);
|
||||
} else if (_clientOnly && client == null) {
|
||||
for (Hash _client : _context.clientManager().getPrimaryHashes()) {
|
||||
renderer.renderLeaseSetHTML(_out, _debug, _client, clientOnly);
|
||||
} else if (_clientOnly) {
|
||||
for (Hash client : _context.clientManager().getPrimaryHashes()) {
|
||||
renderer.renderLeaseSetHTML(_out, false, client);
|
||||
}
|
||||
} else {
|
||||
if (_full == 0 && _sort != null)
|
||||
_full = 3;
|
||||
renderer.renderStatusHTML(_out, _limit, _page, _full, client, clientOnly);
|
||||
renderer.renderStatusHTML(_out, _limit, _page, _full);
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
@ -376,10 +352,6 @@ public class NetDbHelper extends FormHandler {
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getClientNetDbSummary(Hash client) {
|
||||
return getNetDbSummary(client, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 0.9.1
|
||||
*/
|
||||
@ -405,12 +377,8 @@ public class NetDbHelper extends FormHandler {
|
||||
return 8;
|
||||
if (_hostname != null)
|
||||
return 9;
|
||||
if (_full == 5)
|
||||
return 10;
|
||||
if (_full == 6)
|
||||
return 11;
|
||||
if (_clientOnly)
|
||||
return 12;
|
||||
return 10;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -431,8 +399,9 @@ public class NetDbHelper extends FormHandler {
|
||||
continue; // can't nav to lookup
|
||||
if (i > 2 && i != tab && !isAdvanced())
|
||||
continue;
|
||||
if (i == 10 || i == 11) {
|
||||
if (_context.netDbSegmentor().getRoutersKnownToClients().size() == 0)
|
||||
if (i == 10) {
|
||||
// skip if no clients
|
||||
if (_context.clientManager().getPrimaryHashes().isEmpty() && i != tab)
|
||||
continue;
|
||||
}
|
||||
if (i == tab) {
|
||||
|
@ -41,13 +41,12 @@ import net.i2p.data.router.RouterAddress;
|
||||
import net.i2p.data.router.RouterInfo;
|
||||
import net.i2p.data.router.RouterKeyGenerator;
|
||||
import net.i2p.router.JobImpl;
|
||||
import net.i2p.router.NetworkDatabaseFacade;
|
||||
import net.i2p.router.RouterContext;
|
||||
import net.i2p.router.TunnelPoolSettings;
|
||||
import net.i2p.router.crypto.FamilyKeyCrypto;
|
||||
import net.i2p.router.networkdb.kademlia.FloodfillNetworkDatabaseSegmentor;
|
||||
import net.i2p.router.networkdb.kademlia.SegmentedNetworkDatabaseFacade;
|
||||
import net.i2p.router.util.HashDistance; // debug
|
||||
import net.i2p.router.networkdb.kademlia.FloodfillNetworkDatabaseFacade;
|
||||
import net.i2p.router.util.HashDistance; // debug
|
||||
import static net.i2p.router.sybil.Util.biLog2;
|
||||
import net.i2p.router.transport.GeoIP;
|
||||
import net.i2p.router.web.HelperBase;
|
||||
@ -115,34 +114,9 @@ class NetDbRenderer {
|
||||
String ip, String sybil, int port, int highPort, SigType type, EncType etype,
|
||||
String mtu, String ipv6, String ssucaps,
|
||||
String tr, int cost, int icount) throws IOException {
|
||||
renderRouterInfoHTML(out, pageSize, page,
|
||||
routerPrefix, version,
|
||||
country, family, caps,
|
||||
ip, sybil, port, highPort, type, etype,
|
||||
mtu, ipv6, ssucaps,
|
||||
tr, cost, icount, null, false);
|
||||
}
|
||||
public void renderRouterInfoHTML(Writer out, int pageSize, int page,
|
||||
String routerPrefix, String version,
|
||||
String country, String family, String caps,
|
||||
String ip, String sybil, int port, int highPort, SigType type, EncType etype,
|
||||
String mtu, String ipv6, String ssucaps,
|
||||
String tr, int cost, int icount, Hash client, boolean allClients) throws IOException {
|
||||
StringBuilder buf = new StringBuilder(4*1024);
|
||||
List<Hash> sybils = sybil != null ? new ArrayList<Hash>(128) : null;
|
||||
FloodfillNetworkDatabaseFacade netdb = _context.netDb();
|
||||
if (allClients) {
|
||||
netdb = _context.netDb();
|
||||
}else{
|
||||
if (client != null) {
|
||||
Log _log = _context.logManager().getLog(NetDbRenderer.class);
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("client subdb for: " + client);
|
||||
netdb = _context.clientNetDb(client);
|
||||
}
|
||||
else
|
||||
netdb = _context.netDb();
|
||||
}
|
||||
NetworkDatabaseFacade netdb = _context.netDb();
|
||||
|
||||
if (".".equals(routerPrefix)) {
|
||||
buf.append("<table><tr><td class=\"infohelp\">")
|
||||
@ -234,15 +208,7 @@ class NetDbRenderer {
|
||||
}
|
||||
boolean notFound = true;
|
||||
Set<RouterInfo> routers = new HashSet<RouterInfo>();
|
||||
if (allClients){
|
||||
routers.addAll(_context.netDbSegmentor().getRoutersKnownToClients());
|
||||
} else {
|
||||
if (client == null)
|
||||
routers.addAll(_context.netDb().getRouters());
|
||||
else
|
||||
routers.addAll(_context.clientNetDb(client).getRouters());
|
||||
|
||||
}
|
||||
routers.addAll(_context.netDb().getRouters());
|
||||
int ipMode = 0;
|
||||
String ipArg = ip; // save for error message
|
||||
String altIPv6 = null;
|
||||
@ -611,27 +577,20 @@ class NetDbRenderer {
|
||||
*
|
||||
* @param debug @since 0.7.14 sort by distance from us, display
|
||||
* median distance, and other stuff, useful when floodfill
|
||||
* @param client null for main db; non-null for client db
|
||||
*/
|
||||
public void renderLeaseSetHTML(Writer out, boolean debug, Hash client, boolean clientsOnly) throws IOException {
|
||||
public void renderLeaseSetHTML(Writer out, boolean debug, Hash client) throws IOException {
|
||||
StringBuilder buf = new StringBuilder(4*1024);
|
||||
if (debug)
|
||||
buf.append("<p id=\"debugmode\">Debug mode - Sorted by hash distance, closest first</p>\n");
|
||||
Hash ourRKey;
|
||||
Set<LeaseSet> leases;
|
||||
DecimalFormat fmt;
|
||||
FloodfillNetworkDatabaseFacade netdb = null;
|
||||
if (clientsOnly){
|
||||
NetworkDatabaseFacade netdb;
|
||||
if (client == null)
|
||||
netdb = _context.netDb();
|
||||
}else{
|
||||
if (client != null) {
|
||||
Log _log = _context.logManager().getLog(NetDbRenderer.class);
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("client subdb for: " + client);
|
||||
netdb = _context.clientNetDb(client);
|
||||
}
|
||||
else
|
||||
netdb = _context.netDb();
|
||||
}
|
||||
else
|
||||
netdb = _context.clientNetDb(client);
|
||||
if (debug) {
|
||||
ourRKey = _context.routerHash();
|
||||
leases = new TreeSet<LeaseSet>(new LeaseSetRoutingKeyComparator(ourRKey));
|
||||
@ -641,11 +600,7 @@ class NetDbRenderer {
|
||||
leases = new TreeSet<LeaseSet>(new LeaseSetComparator());
|
||||
fmt = null;
|
||||
}
|
||||
if (clientsOnly)
|
||||
leases.addAll(_context.netDbSegmentor().getLeasesKnownToClients());
|
||||
else{
|
||||
leases.addAll(netdb.getLeases());
|
||||
}
|
||||
leases.addAll(netdb.getLeases());
|
||||
int medianCount = 0;
|
||||
int rapCount = 0;
|
||||
BigInteger median = null;
|
||||
@ -658,16 +613,15 @@ class NetDbRenderer {
|
||||
} else {
|
||||
buf.append("<table id=\"leasesetsummary\">\n");
|
||||
}
|
||||
if (clientsOnly)
|
||||
buf.append("<tr><th colspan=\"3\">Leaseset Summary for All Clients: ").append(client).append("</th>");
|
||||
else if (client != null)
|
||||
buf.append("<tr><th colspan=\"3\">Leaseset Summary for Client: ").append(client).append("</th>");
|
||||
else
|
||||
buf.append("<tr><th colspan=\"3\">Leaseset Summary for Floodfill</th>");
|
||||
buf.append("<th><a href=\"/configadvanced\" title=\"").append(_t("Manually Configure Floodfill Participation")).append("\">[")
|
||||
.append(_t("Configure Floodfill Participation"))
|
||||
.append("]</a></th></tr>\n")
|
||||
.append("<tr><td><b>Total Leasesets:</b></td><td colspan=\"3\">").append(leases.size()).append("</td></tr>\n");
|
||||
if (client != null) {
|
||||
buf.append("<tr><th colspan=\"3\">Leasesets for Client: ").append(client.toBase32()).append("</th><th></th></tr>\n");
|
||||
} else {
|
||||
buf.append("<tr><th colspan=\"3\">Leaseset Summary for Floodfill</th>" +
|
||||
"<th><a href=\"/configadvanced\" title=\"").append(_t("Manually Configure Floodfill Participation")).append("\">[")
|
||||
.append(_t("Configure Floodfill Participation"))
|
||||
.append("]</a></th></tr>\n");
|
||||
}
|
||||
buf.append("<tr><td><b>Total Leasesets:</b></td><td colspan=\"3\">").append(leases.size()).append("</td></tr>\n");
|
||||
if (debug) {
|
||||
RouterKeyGenerator gen = _context.routerKeyGenerator();
|
||||
buf.append("<tr><td><b>Published (RAP) Leasesets:</b></td><td colspan=\"3\">").append(leases).append("</td></tr>\n")
|
||||
@ -676,17 +630,17 @@ class NetDbRenderer {
|
||||
.append("<tr><td><b>Next Mod Data:</b></td><td>").append(DataHelper.getUTF8(gen.getNextModData())).append("</td>")
|
||||
.append("<td><b>Change in:</b></td><td>").append(DataHelper.formatDuration(gen.getTimeTillMidnight())).append("</td></tr>\n");
|
||||
}
|
||||
int ff = 0;
|
||||
if (client == null) {
|
||||
ff = _context.peerManager().getPeersByCapability(FloodfillNetworkDatabaseFacade.CAPABILITY_FLOODFILL).size();
|
||||
int ff = _context.peerManager().getPeersByCapability(FloodfillNetworkDatabaseFacade.CAPABILITY_FLOODFILL).size();
|
||||
buf.append("<tr><td><b>Known Floodfills:</b></td><td colspan=\"3\">").append(ff).append("</td></tr>\n");
|
||||
buf.append("<tr><td><b>Currently Floodfill?</b></td><td>").append(netdb.floodfillEnabled() ? "yes" : "no");
|
||||
if (debug)
|
||||
buf.append("</td><td><b>Routing Key:</b></td><td>").append(ourRKey.toBase64());
|
||||
else
|
||||
buf.append("</td><td colspan=\"2\">");
|
||||
buf.append("</td></tr>\n");
|
||||
}
|
||||
if (debug)
|
||||
buf.append("</td><td><b>Routing Key:</b></td><td>").append(ourRKey.toBase64());
|
||||
else
|
||||
buf.append("</td><td colspan=\"2\">");
|
||||
buf.append("</td></tr>\n</table>\n");
|
||||
buf.append("</table>\n");
|
||||
|
||||
if (leases.isEmpty()) {
|
||||
//if (!debug)
|
||||
@ -960,7 +914,7 @@ class NetDbRenderer {
|
||||
* @param mode 0: charts only; 1: full routerinfos; 2: abbreviated routerinfos
|
||||
* mode 3: Same as 0 but sort countries by count
|
||||
*/
|
||||
public void renderStatusHTML(Writer out, int pageSize, int page, int mode, Hash client, boolean clientsOnly) throws IOException {
|
||||
public void renderStatusHTML(Writer out, int pageSize, int page, int mode) throws IOException {
|
||||
if (!_context.netDb().isInitialized()) {
|
||||
out.write("<div id=\"notinitialized\">");
|
||||
out.write(_t("Not initialized"));
|
||||
@ -977,13 +931,7 @@ class NetDbRenderer {
|
||||
Hash us = _context.routerHash();
|
||||
|
||||
Set<RouterInfo> routers = new TreeSet<RouterInfo>(new RouterInfoComparator());
|
||||
if (client != null) {
|
||||
routers.addAll(_context.clientNetDb(client).getRouters());
|
||||
} else if (clientsOnly) {
|
||||
routers.addAll(_context.netDbSegmentor().getRoutersKnownToClients());
|
||||
} else {
|
||||
routers.addAll(_context.netDb().getRouters());
|
||||
}
|
||||
routers.addAll(_context.netDb().getRouters());
|
||||
int toSkip = pageSize * page;
|
||||
boolean nextpg = routers.size() > toSkip + pageSize;
|
||||
StringBuilder buf = new StringBuilder(8192);
|
||||
@ -1071,19 +1019,9 @@ class NetDbRenderer {
|
||||
if (!showStats) {
|
||||
|
||||
// the summary table
|
||||
if (client != null) {
|
||||
buf.append("<table id=\"netdboverview\" border=\"0\" cellspacing=\"30\"><tr><th colspan=\"3\">")
|
||||
.append(_t("Network Database Router Statistics for Client " + client))
|
||||
.append("</th></tr><tr><td style=\"vertical-align: top;\">");
|
||||
} else if (clientsOnly) {
|
||||
buf.append("<table id=\"netdboverview\" border=\"0\" cellspacing=\"30\"><tr><th colspan=\"3\">")
|
||||
.append(_t("Network Database Router Statistics for all Clients"))
|
||||
.append("</th></tr><tr><td style=\"vertical-align: top;\">");
|
||||
} else {
|
||||
buf.append("<table id=\"netdboverview\" border=\"0\" cellspacing=\"30\"><tr><th colspan=\"3\">")
|
||||
.append(_t("Network Database Router Statistics for Floodfill Router"))
|
||||
.append("</th></tr><tr><td style=\"vertical-align: top;\">");
|
||||
}
|
||||
buf.append("<table id=\"netdboverview\" border=\"0\" cellspacing=\"30\"><tr><th colspan=\"3\">");
|
||||
buf.append(_t("Network Database Router Statistics"));
|
||||
buf.append("</th></tr><tr><td style=\"vertical-align: top;\">");
|
||||
// versions table
|
||||
List<String> versionList = new ArrayList<String>(versions.objects());
|
||||
if (!versionList.isEmpty()) {
|
||||
|
@ -41,5 +41,5 @@
|
||||
<jsp:setProperty name="formhandler" property="sort" value="<%=request.getParameter(\"s\")%>" />
|
||||
<jsp:setProperty name="formhandler" property="intros" value="<%=request.getParameter(\"i\")%>" />
|
||||
<%@include file="formhandler.jsi" %>
|
||||
<jsp:getProperty name="formhandler" property="floodfillNetDbSummary" />
|
||||
<jsp:getProperty name="formhandler" property="netDbSummary" />
|
||||
</div></body></html>
|
||||
|
Reference in New Issue
Block a user