forked from I2P_Developers/i2p.i2p
Console/NetDB: Tweak design of client netDb page
This commit is contained in:
@ -7,11 +7,13 @@ import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import net.i2p.crypto.EncType;
|
||||
import net.i2p.crypto.SigType;
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.data.Hash;
|
||||
import net.i2p.data.LeaseSet;
|
||||
import net.i2p.util.SystemVersion;
|
||||
import net.i2p.router.sybil.Analysis;
|
||||
import net.i2p.router.web.FormHandler;
|
||||
@ -41,7 +43,7 @@ public class NetDbHelper extends FormHandler {
|
||||
|
||||
private static final int DEFAULT_LIMIT = SystemVersion.isARM() ? 250 : 500;
|
||||
private static final int DEFAULT_PAGE = 0;
|
||||
|
||||
|
||||
private static final String titles[] =
|
||||
{_x("Summary"), // 0
|
||||
_x("Local Router"), // 1
|
||||
@ -70,7 +72,7 @@ public class NetDbHelper extends FormHandler {
|
||||
"", // 9
|
||||
"?l=7", // 10
|
||||
};
|
||||
|
||||
|
||||
|
||||
public void setRouter(String r) {
|
||||
if (r != null && r.length() > 0)
|
||||
@ -238,14 +240,14 @@ public class NetDbHelper extends FormHandler {
|
||||
public void setSort(String f) {
|
||||
_sort = f;
|
||||
}
|
||||
|
||||
|
||||
/** @since 0.9.58 */
|
||||
public void setIntros(String f) {
|
||||
try {
|
||||
_icount = Integer.parseInt(f);
|
||||
} catch (NumberFormatException nfe) {}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* call for non-text-mode browsers
|
||||
* @since 0.9.1
|
||||
@ -253,7 +255,7 @@ public class NetDbHelper extends FormHandler {
|
||||
public void allowGraphical() {
|
||||
_graphical = true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Override to save it
|
||||
* @since 0.9.38
|
||||
@ -338,7 +340,9 @@ public class NetDbHelper extends FormHandler {
|
||||
} else if (_full == 4) {
|
||||
renderLookupForm();
|
||||
} else if (_clientOnly) {
|
||||
for (Hash client : _context.clientManager().getPrimaryHashes()) {
|
||||
TreeSet<Hash> hashes = new TreeSet<Hash>(new HashComparator());
|
||||
hashes.addAll(_context.clientManager().getPrimaryHashes());
|
||||
for (Hash client : hashes) {
|
||||
renderer.renderLeaseSetHTML(_out, false, client);
|
||||
}
|
||||
} else {
|
||||
@ -430,7 +434,7 @@ public class NetDbHelper extends FormHandler {
|
||||
* @since 0.9.28
|
||||
*/
|
||||
private void renderLookupForm() throws IOException {
|
||||
_out.write("<form action=\"/netdb\" method=\"POST\">\n" +
|
||||
_out.write("<form action=\"/netdb\" method=\"POST\">\n" +
|
||||
"<input type=\"hidden\" name=\"nonce\" value=\"" + _newNonce + "\" >\n" +
|
||||
"<table id=\"netdblookup\"><tr><th colspan=\"3\">Network Database Search</th></tr>\n" +
|
||||
"<tr><td>Capabilities:</td><td><input type=\"text\" name=\"caps\"></td><td>e.g. f or XfR</td></tr>\n" +
|
||||
|
@ -698,6 +698,9 @@ class NetDbRenderer {
|
||||
fmt = null;
|
||||
}
|
||||
leases.addAll(netdb.getLeases());
|
||||
LeaseSet myLeaseSet = new LeaseSet();
|
||||
if (netdb.getLeases().size() > 0)
|
||||
myLeaseSet = new ArrayList<LeaseSet>(netdb.getLeases()).get(0);
|
||||
int medianCount = 0;
|
||||
int rapCount = 0;
|
||||
BigInteger median = null;
|
||||
@ -711,14 +714,77 @@ class NetDbRenderer {
|
||||
buf.append("<table id=\"leasesetsummary\">\n");
|
||||
}
|
||||
if (client != null) {
|
||||
buf.append("<tr><th colspan=\"3\">Leasesets for Client: ").append(client.toBase32()).append("</th><th></th></tr>\n");
|
||||
buf.append("<tr><th colspan=\"3\">").append(_t("Leasesets for Client")).append(": ");
|
||||
buf.append(client.toBase32());
|
||||
if (netdb.getLeases().size() > 0) {
|
||||
TunnelPoolSettings in = _context.tunnelManager().getInboundSettings(myLeaseSet.getHash());
|
||||
if (in != null && in.getDestinationNickname() != null)
|
||||
buf.append(" - ").append(DataHelper.escapeHTML(in.getDestinationNickname()));
|
||||
buf.append("</th><th></th></tr>\n");
|
||||
boolean unpublished = ! _context.clientManager().shouldPublishLeaseSet(myLeaseSet.getHash());
|
||||
if (unpublished) {
|
||||
buf.append("<tr><th colspan=\"3\">").append(_t("Local")).append(" ");
|
||||
if (myLeaseSet.getType() == DatabaseEntry.KEY_TYPE_ENCRYPTED_LS2 || _context.keyRing().get(myLeaseSet.getHash()) != null)
|
||||
buf.append(" <b>(").append(_t("Encrypted")).append(")</b>");
|
||||
buf.append(_t("Unpublished")).append(" ");
|
||||
} else {
|
||||
buf.append("<tr><th colspan=\"3\">").append(_t("Local")).append(" ");
|
||||
if (myLeaseSet.getType() == DatabaseEntry.KEY_TYPE_ENCRYPTED_LS2 || _context.keyRing().get(myLeaseSet.getHash()) != null)
|
||||
buf.append(" <b>(").append(_t("Encrypted")).append(")</b>");
|
||||
buf.append(_t("Published")).append(" ");
|
||||
LeaseSet2 ls2 = (LeaseSet2) myLeaseSet;
|
||||
long now = _context.clock().now();
|
||||
long pub = now - ls2.getPublished();
|
||||
buf.append(_t("{0} ago", DataHelper.formatDuration2(pub)));
|
||||
long exp;
|
||||
if (myLeaseSet.getType() == DatabaseEntry.KEY_TYPE_LEASESET) {
|
||||
exp = ls2.getLatestLeaseDate() - now;
|
||||
} else {
|
||||
exp = ls2.getExpires()-now;
|
||||
}
|
||||
buf.append(" - ");
|
||||
if (exp > 0)
|
||||
buf.append(_t("Expires in {0}", DataHelper.formatDuration2(exp)));
|
||||
else
|
||||
buf.append(_t("Expired {0} ago", DataHelper.formatDuration2(0-exp)));
|
||||
}
|
||||
buf.append("</th><th></th></tr>\n");
|
||||
buf.append("\n<tr><td colspan=\"2\"><ul class=\"netdb_leases\">");
|
||||
boolean isMeta = myLeaseSet.getType() == DatabaseEntry.KEY_TYPE_META_LS2;
|
||||
for (int i = 0; i < myLeaseSet.getLeaseCount(); i++) {
|
||||
Lease lease = myLeaseSet.getLease(i);
|
||||
buf.append("<li><b>").append(_t("Lease")).append(' ').append(i + 1).append(":</b> <span class=\"tunnel_peer\">");
|
||||
buf.append(_context.commSystem().renderPeerHTML(lease.getGateway()));
|
||||
buf.append("</span> ");
|
||||
if (!isMeta) {
|
||||
buf.append("<span class=\"netdb_tunnel\">").append(_t("Tunnel")).append(" <span class=\"tunnel_id\">")
|
||||
.append(lease.getTunnelId().getTunnelId()).append("</span></span> ");
|
||||
}
|
||||
if (debug) {
|
||||
long now = _context.clock().now();
|
||||
long exl = lease.getEndTime() - now;
|
||||
buf.append("<b class=\"netdb_expiry\">");
|
||||
if (exl > 0)
|
||||
buf.append(_t("Expires in {0}", DataHelper.formatDuration2(exl)));
|
||||
else
|
||||
buf.append(_t("Expired {0} ago", DataHelper.formatDuration2(0-exl)));
|
||||
buf.append("</b>");
|
||||
}
|
||||
buf.append("</li>");
|
||||
}
|
||||
buf.append("</ul></td></tr>\n");
|
||||
}
|
||||
buf.append("<tr><td><b>Total Known Remote Leasesets:</b></td><td colspan=\"3\">").append(leases.size()-1).append("</td></tr>\n");
|
||||
buf.append("</ul></td></tr>\n" +
|
||||
"</table>\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 Known Leasesets:</b></td><td colspan=\"3\">").append(leases.size()).append("</td></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(netdb.getKnownLeaseSets()).append("</td></tr>\n")
|
||||
@ -767,9 +833,11 @@ class NetDbRenderer {
|
||||
} else {
|
||||
distance = null;
|
||||
}
|
||||
renderLeaseSet(buf, ls, debug, now, linkSusi, distance);
|
||||
out.write(buf.toString());
|
||||
buf.setLength(0);
|
||||
if (myLeaseSet == null || ls.getHash() != myLeaseSet.getHash()) {
|
||||
renderLeaseSet(buf, ls, debug, now, linkSusi, distance);
|
||||
out.write(buf.toString());
|
||||
buf.setLength(0);
|
||||
}
|
||||
} // for each
|
||||
if (debug) {
|
||||
buf.append("<table id=\"leasesetdebug\"><tr><td><b>Network data (only valid if floodfill):</b></td><td colspan=\"3\">");
|
||||
@ -1221,7 +1289,7 @@ class NetDbRenderer {
|
||||
out.write(buf.toString());
|
||||
out.flush();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Countries now in a separate bundle
|
||||
* @param code two-letter country code
|
||||
@ -1478,7 +1546,7 @@ class NetDbRenderer {
|
||||
} else if (ip.contains(":0:")) {
|
||||
// convert to canonical
|
||||
return Addresses.toCanonicalString(ip);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -7158,6 +7158,8 @@ img+tt {
|
||||
-moz-column-gap: 10px;
|
||||
-webkit-column-gap: 10px;
|
||||
column-gap: 10px;
|
||||
padding: 8px;
|
||||
border: 1px groove rgb(82, 75, 94);
|
||||
}
|
||||
|
||||
th code {
|
||||
|
@ -7230,6 +7230,8 @@ a[href^="configpeer?peer"]:hover {
|
||||
-moz-column-gap: 10px;
|
||||
-webkit-column-gap: 10px;
|
||||
column-gap: 10px;
|
||||
padding: 8px;
|
||||
border: 1px groove rgb(82, 75, 94);
|
||||
}
|
||||
|
||||
th code {
|
||||
|
Reference in New Issue
Block a user