- 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

@ -730,13 +730,13 @@ public class KBucketSet<T extends SimpleDataStructure> {
public void getEntries(SelectionCollector<T> collector) { public void getEntries(SelectionCollector<T> collector) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public void clear() {} public void clear() {}
public boolean add(T peer) { public boolean add(T peer) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public boolean remove(T peer) { public boolean remove(T peer) {
return false; return false;
} }
@ -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

@ -89,7 +89,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
private final int _tagsToSend; private final int _tagsToSend;
private final int _lowThreshold; private final int _lowThreshold;
/** /**
* Let outbound session tags sit around for this long before expiring them. * Let outbound session tags sit around for this long before expiring them.
* Inbound tag expiration is set by SESSION_LIFETIME_MAX_MS * Inbound tag expiration is set by SESSION_LIFETIME_MAX_MS
*/ */
@ -155,7 +155,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
/** ditto */ /** ditto */
public static final int LOW_THRESHOLD = 30; public static final int LOW_THRESHOLD = 30;
/** /**
* The session key manager should only be constructed and accessed through the * The session key manager should only be constructed and accessed through the
* application context. This constructor should only be used by the * application context. This constructor should only be used by the
* appropriate application context itself. * appropriate application context itself.
@ -165,7 +165,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
this(context, DEFAULT_TAGS, LOW_THRESHOLD); this(context, DEFAULT_TAGS, LOW_THRESHOLD);
} }
/** /**
* @param tagsToSend how many to send at a time, may be lower or higher than lowThreshold. 1-128 * @param tagsToSend how many to send at a time, may be lower or higher than lowThreshold. 1-128
* @param lowThreshold below this, send more. 1-128 * @param lowThreshold below this, send more. 1-128
* @since 0.9.2 * @since 0.9.2
@ -185,7 +185,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
_alive = true; _alive = true;
_context.simpleTimer2().addEvent(new CleanupEvent(), 60*1000); _context.simpleTimer2().addEvent(new CleanupEvent(), 60*1000);
} }
@Override @Override
public void shutdown() { public void shutdown() {
_alive = false; _alive = false;
@ -408,7 +408,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
else else
return end - _context.clock().now(); return end - _context.clock().now();
} }
return 0; return 0;
} }
/** /**
@ -559,7 +559,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
_log.warn("Current tag set creation: " + tagSet + ": key=" + tagSet.getAssociatedKey()); _log.warn("Current tag set creation: " + tagSet + ": key=" + tagSet.getAssociatedKey());
} }
} }
int overage = _inboundTagSets.size() - MAX_INBOUND_SESSION_TAGS; int overage = _inboundTagSets.size() - MAX_INBOUND_SESSION_TAGS;
if (overage > 0) if (overage > 0)
clearExcess(overage); clearExcess(overage);
@ -568,7 +568,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
// _log.debug("Received 0 tags for key " + key); // _log.debug("Received 0 tags for key " + key);
//if (false) aggressiveExpire(); //if (false) aggressiveExpire();
} }
/** /**
* remove a bunch of arbitrarily selected tags, then drop all of * remove a bunch of arbitrarily selected tags, then drop all of
* the associated tag sets. this is very time consuming - iterating * the associated tag sets. this is very time consuming - iterating
@ -616,7 +616,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
} }
} }
} }
_log.logAlways(Log.WARN, "TOO MANY SESSION TAGS! removed " + removed.size() _log.logAlways(Log.WARN, "TOO MANY SESSION TAGS! removed " + removed.size()
+ " tag sets arbitrarily, with " + tags + " tags," + " tag sets arbitrarily, with " + tags + " tags,"
+ "where there are " + old + " long lasting sessions, " + "where there are " + old + " long lasting sessions, "
+ recent + " ones created in the last few minutes, and " + recent + " ones created in the last few minutes, and "
@ -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();) {
@ -1162,7 +1162,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
iter.remove(); iter.remove();
return first; return first;
} }
//public Exception getCreatedBy() { return _createdBy; } //public Exception getCreatedBy() { return _createdBy; }
/** /**
@ -1174,7 +1174,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
* For outbound only. * For outbound only.
*/ */
public boolean getAcked() { return _acked; } public boolean getAcked() { return _acked; }
/****** this will return a dup if two in the same ms, so just use java /****** this will return a dup if two in the same ms, so just use java
@Override @Override
public int hashCode() { public int hashCode() {
@ -1184,12 +1184,12 @@ public class TransientSessionKeyManager extends SessionKeyManager {
// no need to hashCode the tags, key + date should be enough // no need to hashCode the tags, key + date should be enough
return (int) rv; return (int) rv;
} }
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if ((o == null) || !(o instanceof TagSet)) return false; if ((o == null) || !(o instanceof TagSet)) return false;
TagSet ts = (TagSet) o; TagSet ts = (TagSet) o;
return DataHelper.eq(ts.getAssociatedKey(), _key) return DataHelper.eq(ts.getAssociatedKey(), _key)
//&& DataHelper.eq(ts.getTags(), getTags()) //&& DataHelper.eq(ts.getTags(), getTags())
&& ts.getDate() == _date; && ts.getDate() == _date;
} }

View File

@ -23,7 +23,7 @@ import net.i2p.util.Log;
* @since 0.9.4 * @since 0.9.4
*/ */
public class RouterAppManager extends ClientAppManagerImpl { public class RouterAppManager extends ClientAppManagerImpl {
private final RouterContext _context; private final RouterContext _context;
private final Log _log; private final Log _log;
// client to args // client to args
@ -127,7 +127,7 @@ public class RouterAppManager extends ClientAppManagerImpl {
break; break;
} }
} }
/** /**
* Register with the manager under the given name, * Register with the manager under the given name,
* so that other clients may find it. * so that other clients may find it.
@ -150,7 +150,7 @@ public class RouterAppManager extends ClientAppManagerImpl {
// TODO if old app in there is not running and != this app, allow replacement // TODO if old app in there is not running and != this app, allow replacement
return super.register(app); return super.register(app);
} }
/// end ClientAppManager interface /// end ClientAppManager interface
/** /**
@ -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) {