- Add container divs and styling markup
- Add top navigation menu
This commit is contained in:
str4d
2017-07-26 23:14:30 +00:00
parent ee1112cca7
commit 30eb089623
6 changed files with 70 additions and 41 deletions

View File

@ -15,15 +15,39 @@
<%@include file="summary.jsi" %> <%@include file="summary.jsi" %>
<h1>Router Debug</h1> <h1>Router Debug</h1>
<div class="main" id="debug"> <div class="main" id="debug">
<div class="confignav">
<span class="tab"><a href="#debug_portmapper">Port Mapper</a></span>
<span class="tab"><a href="#appmanager">App Manager</a></span>
<span class="tab"><a href="#updatemanager">Update Manager</a></span>
<span class="tab"><a href="#skm">Session Key Manager</a></span>
<span class="tab"><a href="#dht">Router DHT</a></span>
</div>
<% <%
/* /*
* Quick and easy place to put debugging stuff * Quick and easy place to put debugging stuff
*/ */
net.i2p.router.RouterContext ctx = (net.i2p.router.RouterContext) net.i2p.I2PAppContext.getGlobalContext(); net.i2p.router.RouterContext ctx = (net.i2p.router.RouterContext) net.i2p.I2PAppContext.getGlobalContext();
/*
* Print out the status for the PortMapper
*/
ctx.portMapper().renderStatusHTML(out);
/*
* Print out the status for the AppManager
*/
out.print("<div class=\"debug_section\" id=\"appmanager\">");
ctx.routerAppManager().renderStatusHTML(out);
out.print("</div>");
/* /*
* Print out the status for the UpdateManager * Print out the status for the UpdateManager
*/ */
out.print("<div class=\"debug_section\" id=\"updatemanager\">");
net.i2p.app.ClientAppManager cmgr = ctx.clientAppManager(); net.i2p.app.ClientAppManager cmgr = ctx.clientAppManager();
if (cmgr != null) { if (cmgr != null) {
net.i2p.router.update.ConsoleUpdateManager umgr = net.i2p.router.update.ConsoleUpdateManager umgr =
@ -31,37 +55,32 @@
if (umgr != null) { if (umgr != null) {
umgr.renderStatusHTML(out); umgr.renderStatusHTML(out);
} }
out.print("</div>");
} }
/*
* Print out the status for the AppManager
*/
ctx.routerAppManager().renderStatusHTML(out);
/*
* Print out the status for the PortMapper
*/
ctx.portMapper().renderStatusHTML(out);
/* /*
* Print out the status for all the SessionKeyManagers * Print out the status for all the SessionKeyManagers
*/ */
out.print("<h2>Router SKM</h2>"); out.print("<div class=\"debug_section\" id=\"skm\">");
out.print("<h2>Router Session Key Manager</h2>");
ctx.sessionKeyManager().renderStatusHTML(out); ctx.sessionKeyManager().renderStatusHTML(out);
java.util.Set<net.i2p.data.Destination> clients = ctx.clientManager().listClients(); java.util.Set<net.i2p.data.Destination> clients = ctx.clientManager().listClients();
out.print("</div>");
for (net.i2p.data.Destination dest : clients) { for (net.i2p.data.Destination dest : clients) {
net.i2p.data.Hash h = dest.calculateHash(); net.i2p.data.Hash h = dest.calculateHash();
net.i2p.crypto.SessionKeyManager skm = ctx.clientManager().getClientSessionKeyManager(h); net.i2p.crypto.SessionKeyManager skm = ctx.clientManager().getClientSessionKeyManager(h);
if (skm != null) { if (skm != null) {
out.print("<h2>" + h.toBase64().substring(0,6) + " SKM</h2>"); out.print("<div class=\"debug_section\">");
out.print("<h2>" + h.toBase64().substring(0,6) + " Session Key Manager</h2>");
skm.renderStatusHTML(out); skm.renderStatusHTML(out);
out.print("</div>");
} }
} }
/* /*
* Print out the status for the NetDB * Print out the status for the NetDB
*/ */
out.print("<h2>Router DHT</h2>"); out.print("<h2 id=\"dht\">Router DHT</h2>");
ctx.netDb().renderStatusHTML(out); ctx.netDb().renderStatusHTML(out);
%> %>

View File

@ -765,6 +765,7 @@ public class KBucketSet<T extends SimpleDataStructure> {
@Override @Override
public String toString() { public String toString() {
StringBuilder buf = new StringBuilder(1024); StringBuilder buf = new StringBuilder(1024);
buf.append("<div class=\"debug_container buckets\">");
buf.append("<hr><b>Bucket set rooted on:</b> ").append(_us.toString()) buf.append("<hr><b>Bucket set rooted on:</b> ").append(_us.toString())
.append(" K=").append(BUCKET_SIZE) .append(" K=").append(BUCKET_SIZE)
.append(" B=").append(B_VALUE) .append(" B=").append(B_VALUE)
@ -779,6 +780,7 @@ public class KBucketSet<T extends SimpleDataStructure> {
buf.append(b.toString()).append("<br>\n"); buf.append(b.toString()).append("<br>\n");
} }
} finally { releaseReadLock(); } } finally { releaseReadLock(); }
buf.append("</div>");
return buf.toString(); return buf.toString();
} }
} }

View File

@ -179,7 +179,7 @@ public class PortMapper {
*/ */
public void renderStatusHTML(Writer out) throws IOException { public void renderStatusHTML(Writer out) throws IOException {
List<String> services = new ArrayList<String>(_dir.keySet()); List<String> services = new ArrayList<String>(_dir.keySet());
out.write("<h2>Port Mapper</h2><table><tr><th>Service<th>Host<th>Port\n"); out.write("<h2 id=\"debug_portmapper\">Port Mapper</h2><table id=\"portmapper\"><tr><th>Service<th>Host<th>Port\n");
Collections.sort(services); Collections.sort(services);
for (String s : services) { for (String s : services) {
InetSocketAddress ia = _dir.get(s); InetSocketAddress ia = _dir.get(s);

View File

@ -1,4 +1,8 @@
2017-07-26 str4d 2017-07-26 str4d
* Console:
- /debug:
- Add container divs and styling markup
- Add top navigation menu
* I2PSnark: * I2PSnark:
- Mitigate truncation of ratings dropdown in comments section (translations) - Mitigate truncation of ratings dropdown in comments section (translations)
- light: Reduce contrast of display text - light: Reduce contrast of display text

View File

@ -719,7 +719,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
@Override @Override
public void renderStatusHTML(Writer out) throws IOException { public void renderStatusHTML(Writer out) throws IOException {
StringBuilder buf = new StringBuilder(1024); StringBuilder buf = new StringBuilder(1024);
buf.append("<h2>Inbound sessions</h2>" + buf.append("<h3 class=\"debug_inboundsessions\">Inbound sessions</h3>" +
"<table>"); "<table>");
Set<TagSet> inbound = getInboundTagSets(); Set<TagSet> inbound = getInboundTagSets();
Map<SessionKey, Set<TagSet>> inboundSets = new HashMap<SessionKey, Set<TagSet>>(inbound.size()); Map<SessionKey, Set<TagSet>> inboundSets = new HashMap<SessionKey, Set<TagSet>>(inbound.size());
@ -738,18 +738,18 @@ public class TransientSessionKeyManager extends SessionKeyManager {
SessionKey skey = e.getKey(); SessionKey skey = e.getKey();
Set<TagSet> sets = new TreeSet<TagSet>(new TagSetComparator()); Set<TagSet> sets = new TreeSet<TagSet>(new TagSetComparator());
sets.addAll(e.getValue()); sets.addAll(e.getValue());
buf.append("<tr><td><b>Session key</b>: ").append(skey.toBase64()).append("</td>" + buf.append("<tr><td><b>Session key:</b> ").append(skey.toBase64()).append("</td>" +
"<td><b># Sets:</b> ").append(sets.size()).append("</td></tr>" + "<td><b># Sets:</b> ").append(sets.size()).append("</td></tr>" +
"<tr><td colspan=\"2\"><ul>"); "<tr class=\"expiry\"><td colspan=\"2\"><ul>");
for (TagSet ts : sets) { for (TagSet ts : sets) {
int size = ts.getTags().size(); int size = ts.getTags().size();
total += size; total += size;
buf.append("<li><b>ID: ").append(ts.getID()); buf.append("<li><b>ID: ").append(ts.getID());
long expires = ts.getDate() - now; long expires = ts.getDate() - now;
if (expires > 0) if (expires > 0)
buf.append(" Expires in:</b> ").append(DataHelper.formatDuration2(expires)).append(" with "); buf.append(" expires in:</b> ").append(DataHelper.formatDuration2(expires)).append(" with ");
else else
buf.append(" Expired:</b> ").append(DataHelper.formatDuration2(0 - expires)).append(" ago with "); buf.append(" expired:</b> ").append(DataHelper.formatDuration2(0 - expires)).append(" ago with ");
buf.append(size).append('/').append(ts.getOriginalSize()).append(" tags remaining</li>"); buf.append(size).append('/').append(ts.getOriginalSize()).append(" tags remaining</li>");
} }
buf.append("</ul></td></tr>\n"); buf.append("</ul></td></tr>\n");
@ -759,7 +759,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
buf.append("<tr><th colspan=\"2\">Total tags: ").append(total).append(" ("); buf.append("<tr><th colspan=\"2\">Total tags: ").append(total).append(" (");
buf.append(DataHelper.formatSize2(32*total)).append("B)</th></tr>\n" + buf.append(DataHelper.formatSize2(32*total)).append("B)</th></tr>\n" +
"</table>" + "</table>" +
"<h2><b>Outbound sessions</b></h2>" + "<h3 class=\"debug_outboundsessions\">Outbound sessions</h3>" +
"<table>"); "<table>");
total = 0; total = 0;
Set<OutboundSession> outbound = getOutboundSessions(); Set<OutboundSession> outbound = getOutboundSessions();
@ -767,11 +767,11 @@ public class TransientSessionKeyManager extends SessionKeyManager {
OutboundSession sess = iter.next(); OutboundSession sess = iter.next();
Set<TagSet> sets = new TreeSet<TagSet>(new TagSetComparator()); Set<TagSet> sets = new TreeSet<TagSet>(new TagSetComparator());
sets.addAll(sess.getTagSets()); sets.addAll(sess.getTagSets());
buf.append("<tr><td><b>Target public key:</b> ").append(toString(sess.getTarget())).append("<br>" + buf.append("<tr class=\"debug_outboundtarget\"><td><div class=\"debug_targetinfo\"><b>Target public key:</b> ").append(toString(sess.getTarget())).append("<br>" +
"<b>Established:</b> ").append(DataHelper.formatDuration2(now - sess.getEstablishedDate())).append(" ago<br>" + "<b>Established:</b> ").append(DataHelper.formatDuration2(now - sess.getEstablishedDate())).append(" ago<br>" +
"<b>Ack Received?</b> ").append(sess.getAckReceived()).append("<br>" + "<b>Ack Received?</b> ").append(sess.getAckReceived()).append("<br>" +
"<b>Last Used:</b> ").append(DataHelper.formatDuration2(now - sess.getLastUsedDate())).append(" ago<br>" + "<b>Last Used:</b> ").append(DataHelper.formatDuration2(now - sess.getLastUsedDate())).append(" ago<br>" +
"<b>Session key:</b> ").append(sess.getCurrentKey().toBase64()).append("</td>" + "<b>Session key:</b> ").append(sess.getCurrentKey().toBase64()).append("</div></td>" +
"<td><b># Sets:</b> ").append(sess.getTagSets().size()).append("</td></tr>" + "<td><b># Sets:</b> ").append(sess.getTagSets().size()).append("</td></tr>" +
"<tr><td colspan=\"2\"><ul>"); "<tr><td colspan=\"2\"><ul>");
for (Iterator<TagSet> siter = sets.iterator(); siter.hasNext();) { for (Iterator<TagSet> siter = sets.iterator(); siter.hasNext();) {

View File

@ -187,9 +187,13 @@ public class RouterAppManager extends ClientAppManagerImpl {
StringBuilder buf = new StringBuilder(1024); StringBuilder buf = new StringBuilder(1024);
buf.append("<h2>App Manager</h2>"); buf.append("<h2>App Manager</h2>");
buf.append("<h3>Tracked</h3>"); buf.append("<h3>Tracked</h3>");
buf.append("<div class=\"debug_container\">");
toString1(buf); toString1(buf);
buf.append("</div>");
buf.append("<h3>Registered</h3>"); buf.append("<h3>Registered</h3>");
buf.append("<div class=\"debug_container\">");
toString2(buf); toString2(buf);
buf.append("</div>");
out.write(buf.toString()); out.write(buf.toString());
} }
@ -202,7 +206,7 @@ public class RouterAppManager extends ClientAppManagerImpl {
for (Map.Entry<ClientApp, String[]> entry : _clients.entrySet()) { for (Map.Entry<ClientApp, String[]> entry : _clients.entrySet()) {
ClientApp key = entry.getKey(); ClientApp key = entry.getKey();
String[] val = entry.getValue(); String[] val = entry.getValue();
list.add("[" + key.getName() + "] = [" + key.getClass().getName() + ' ' + Arrays.toString(val) + "] " + key.getState() + "<br>"); list.add("[<b>" + key.getName() + "</b>] = [" + key.getClass().getName() + ' ' + Arrays.toString(val) + "] <i>" + key.getState() + "</i><br>");
} }
Collections.sort(list); Collections.sort(list);
for (String e : list) { for (String e : list) {
@ -219,7 +223,7 @@ public class RouterAppManager extends ClientAppManagerImpl {
for (Map.Entry<String, ClientApp> entry : _registered.entrySet()) { for (Map.Entry<String, ClientApp> entry : _registered.entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
ClientApp val = entry.getValue(); ClientApp val = entry.getValue();
list.add("[" + key + "] = [" + val.getClass().getName() + "]<br>"); list.add("[<b>" + key + "</b>] = [" + val.getClass().getName() + "]<br>");
} }
Collections.sort(list); Collections.sort(list);
for (String e : list) { for (String e : list) {