From 30eb089623f1f8dd844be06a5dcc616fbec05e5a Mon Sep 17 00:00:00 2001 From: str4d Date: Wed, 26 Jul 2017 23:14:30 +0000 Subject: [PATCH] /debug: - Add container divs and styling markup - Add top navigation menu --- apps/routerconsole/jsp/debug.jsp | 45 +++++++++++++------ .../java/src/net/i2p/kademlia/KBucketSet.java | 6 ++- core/java/src/net/i2p/util/PortMapper.java | 2 +- history.txt | 4 ++ .../crypto/TransientSessionKeyManager.java | 40 ++++++++--------- .../i2p/router/startup/RouterAppManager.java | 14 +++--- 6 files changed, 70 insertions(+), 41 deletions(-) diff --git a/apps/routerconsole/jsp/debug.jsp b/apps/routerconsole/jsp/debug.jsp index cb55e8f2d..f420c16ea 100644 --- a/apps/routerconsole/jsp/debug.jsp +++ b/apps/routerconsole/jsp/debug.jsp @@ -15,15 +15,39 @@ <%@include file="summary.jsi" %>

Router Debug

+ + + <% /* * Quick and easy place to put debugging stuff */ 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("
"); + ctx.routerAppManager().renderStatusHTML(out); + out.print("
"); + + /* * Print out the status for the UpdateManager */ + out.print("
"); net.i2p.app.ClientAppManager cmgr = ctx.clientAppManager(); if (cmgr != null) { net.i2p.router.update.ConsoleUpdateManager umgr = @@ -31,37 +55,32 @@ if (umgr != null) { umgr.renderStatusHTML(out); } + out.print("
"); } - /* - * 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 */ - out.print("

Router SKM

"); + out.print("
"); + out.print("

Router Session Key Manager

"); ctx.sessionKeyManager().renderStatusHTML(out); java.util.Set clients = ctx.clientManager().listClients(); + out.print("
"); for (net.i2p.data.Destination dest : clients) { net.i2p.data.Hash h = dest.calculateHash(); net.i2p.crypto.SessionKeyManager skm = ctx.clientManager().getClientSessionKeyManager(h); if (skm != null) { - out.print("

" + h.toBase64().substring(0,6) + " SKM

"); + out.print("
"); + out.print("

" + h.toBase64().substring(0,6) + " Session Key Manager

"); skm.renderStatusHTML(out); + out.print("
"); } } /* * Print out the status for the NetDB */ - out.print("

Router DHT

"); + out.print("

Router DHT

"); ctx.netDb().renderStatusHTML(out); %> diff --git a/core/java/src/net/i2p/kademlia/KBucketSet.java b/core/java/src/net/i2p/kademlia/KBucketSet.java index 29af4c144..c3b28943c 100644 --- a/core/java/src/net/i2p/kademlia/KBucketSet.java +++ b/core/java/src/net/i2p/kademlia/KBucketSet.java @@ -730,13 +730,13 @@ public class KBucketSet { public void getEntries(SelectionCollector collector) { throw new UnsupportedOperationException(); } - + public void clear() {} public boolean add(T peer) { throw new UnsupportedOperationException(); } - + public boolean remove(T peer) { return false; } @@ -765,6 +765,7 @@ public class KBucketSet { @Override public String toString() { StringBuilder buf = new StringBuilder(1024); + buf.append("
"); buf.append("
Bucket set rooted on: ").append(_us.toString()) .append(" K=").append(BUCKET_SIZE) .append(" B=").append(B_VALUE) @@ -779,6 +780,7 @@ public class KBucketSet { buf.append(b.toString()).append("
\n"); } } finally { releaseReadLock(); } + buf.append("
"); return buf.toString(); } } diff --git a/core/java/src/net/i2p/util/PortMapper.java b/core/java/src/net/i2p/util/PortMapper.java index 5dcf55c1b..105dc1f07 100644 --- a/core/java/src/net/i2p/util/PortMapper.java +++ b/core/java/src/net/i2p/util/PortMapper.java @@ -179,7 +179,7 @@ public class PortMapper { */ public void renderStatusHTML(Writer out) throws IOException { List services = new ArrayList(_dir.keySet()); - out.write("

Port Mapper

ServiceHostPort\n"); + out.write("

Port Mapper

ServiceHostPort\n"); Collections.sort(services); for (String s : services) { InetSocketAddress ia = _dir.get(s); diff --git a/history.txt b/history.txt index c8d2a2713..d6c1c7bbb 100644 --- a/history.txt +++ b/history.txt @@ -1,4 +1,8 @@ 2017-07-26 str4d + * Console: + - /debug: + - Add container divs and styling markup + - Add top navigation menu * I2PSnark: - Mitigate truncation of ratings dropdown in comments section (translations) - light: Reduce contrast of display text diff --git a/router/java/src/net/i2p/router/crypto/TransientSessionKeyManager.java b/router/java/src/net/i2p/router/crypto/TransientSessionKeyManager.java index 606409c2c..12d6672a8 100644 --- a/router/java/src/net/i2p/router/crypto/TransientSessionKeyManager.java +++ b/router/java/src/net/i2p/router/crypto/TransientSessionKeyManager.java @@ -89,7 +89,7 @@ public class TransientSessionKeyManager extends SessionKeyManager { private final int _tagsToSend; private final int _lowThreshold; - /** + /** * Let outbound session tags sit around for this long before expiring them. * Inbound tag expiration is set by SESSION_LIFETIME_MAX_MS */ @@ -155,7 +155,7 @@ public class TransientSessionKeyManager extends SessionKeyManager { /** ditto */ public static final int LOW_THRESHOLD = 30; - /** + /** * The session key manager should only be constructed and accessed through the * application context. This constructor should only be used by the * appropriate application context itself. @@ -165,7 +165,7 @@ public class TransientSessionKeyManager extends SessionKeyManager { 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 lowThreshold below this, send more. 1-128 * @since 0.9.2 @@ -185,7 +185,7 @@ public class TransientSessionKeyManager extends SessionKeyManager { _alive = true; _context.simpleTimer2().addEvent(new CleanupEvent(), 60*1000); } - + @Override public void shutdown() { _alive = false; @@ -408,7 +408,7 @@ public class TransientSessionKeyManager extends SessionKeyManager { else 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()); } } - + int overage = _inboundTagSets.size() - MAX_INBOUND_SESSION_TAGS; if (overage > 0) clearExcess(overage); @@ -568,7 +568,7 @@ public class TransientSessionKeyManager extends SessionKeyManager { // _log.debug("Received 0 tags for key " + key); //if (false) aggressiveExpire(); } - + /** * remove a bunch of arbitrarily selected tags, then drop all of * 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," + "where there are " + old + " long lasting sessions, " + recent + " ones created in the last few minutes, and " @@ -719,7 +719,7 @@ public class TransientSessionKeyManager extends SessionKeyManager { @Override public void renderStatusHTML(Writer out) throws IOException { StringBuilder buf = new StringBuilder(1024); - buf.append("

Inbound sessions

" + + buf.append("

Inbound sessions

" + ""); Set inbound = getInboundTagSets(); Map> inboundSets = new HashMap>(inbound.size()); @@ -738,18 +738,18 @@ public class TransientSessionKeyManager extends SessionKeyManager { SessionKey skey = e.getKey(); Set sets = new TreeSet(new TagSetComparator()); sets.addAll(e.getValue()); - buf.append("" + + buf.append("" + "" + - "\n"); @@ -759,7 +759,7 @@ public class TransientSessionKeyManager extends SessionKeyManager { buf.append("\n" + "
Session key: ").append(skey.toBase64()).append("
Session key: ").append(skey.toBase64()).append("# Sets: ").append(sets.size()).append("
    "); + "
    "); for (TagSet ts : sets) { int size = ts.getTags().size(); total += size; buf.append("
  • ID: ").append(ts.getID()); long expires = ts.getDate() - now; if (expires > 0) - buf.append(" Expires in: ").append(DataHelper.formatDuration2(expires)).append(" with "); + buf.append(" expires in: ").append(DataHelper.formatDuration2(expires)).append(" with "); else - buf.append(" Expired: ").append(DataHelper.formatDuration2(0 - expires)).append(" ago with "); + buf.append(" expired: ").append(DataHelper.formatDuration2(0 - expires)).append(" ago with "); buf.append(size).append('/').append(ts.getOriginalSize()).append(" tags remaining
  • "); } buf.append("
Total tags: ").append(total).append(" ("); buf.append(DataHelper.formatSize2(32*total)).append("B)
" + - "

Outbound sessions

" + + "

Outbound sessions

" + ""); total = 0; Set outbound = getOutboundSessions(); @@ -767,11 +767,11 @@ public class TransientSessionKeyManager extends SessionKeyManager { OutboundSession sess = iter.next(); Set sets = new TreeSet(new TagSetComparator()); sets.addAll(sess.getTagSets()); - buf.append("" + + "Session key: ").append(sess.getCurrentKey().toBase64()).append("" + "" + "
Target public key: ").append(toString(sess.getTarget())).append("
" + + buf.append("
Target public key: ").append(toString(sess.getTarget())).append("
" + "Established: ").append(DataHelper.formatDuration2(now - sess.getEstablishedDate())).append(" ago
" + "Ack Received? ").append(sess.getAckReceived()).append("
" + "Last Used: ").append(DataHelper.formatDuration2(now - sess.getLastUsedDate())).append(" ago
" + - "Session key: ").append(sess.getCurrentKey().toBase64()).append("
# Sets: ").append(sess.getTagSets().size()).append("
    "); for (Iterator siter = sets.iterator(); siter.hasNext();) { @@ -1162,7 +1162,7 @@ public class TransientSessionKeyManager extends SessionKeyManager { iter.remove(); return first; } - + //public Exception getCreatedBy() { return _createdBy; } /** @@ -1174,7 +1174,7 @@ public class TransientSessionKeyManager extends SessionKeyManager { * For outbound only. */ public boolean getAcked() { return _acked; } - + /****** this will return a dup if two in the same ms, so just use java @Override public int hashCode() { @@ -1184,12 +1184,12 @@ public class TransientSessionKeyManager extends SessionKeyManager { // no need to hashCode the tags, key + date should be enough return (int) rv; } - + @Override public boolean equals(Object o) { if ((o == null) || !(o instanceof TagSet)) return false; TagSet ts = (TagSet) o; - return DataHelper.eq(ts.getAssociatedKey(), _key) + return DataHelper.eq(ts.getAssociatedKey(), _key) //&& DataHelper.eq(ts.getTags(), getTags()) && ts.getDate() == _date; } diff --git a/router/java/src/net/i2p/router/startup/RouterAppManager.java b/router/java/src/net/i2p/router/startup/RouterAppManager.java index 4449b5a6f..27cee8ddc 100644 --- a/router/java/src/net/i2p/router/startup/RouterAppManager.java +++ b/router/java/src/net/i2p/router/startup/RouterAppManager.java @@ -23,7 +23,7 @@ import net.i2p.util.Log; * @since 0.9.4 */ public class RouterAppManager extends ClientAppManagerImpl { - + private final RouterContext _context; private final Log _log; // client to args @@ -127,7 +127,7 @@ public class RouterAppManager extends ClientAppManagerImpl { break; } } - + /** * Register with the manager under the given name, * 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 return super.register(app); } - + /// end ClientAppManager interface /** @@ -187,9 +187,13 @@ public class RouterAppManager extends ClientAppManagerImpl { StringBuilder buf = new StringBuilder(1024); buf.append("

    App Manager

    "); buf.append("

    Tracked

    "); + buf.append("
    "); toString1(buf); + buf.append("
    "); buf.append("

    Registered

    "); + buf.append("
    "); toString2(buf); + buf.append("
    "); out.write(buf.toString()); } @@ -202,7 +206,7 @@ public class RouterAppManager extends ClientAppManagerImpl { for (Map.Entry entry : _clients.entrySet()) { ClientApp key = entry.getKey(); String[] val = entry.getValue(); - list.add("[" + key.getName() + "] = [" + key.getClass().getName() + ' ' + Arrays.toString(val) + "] " + key.getState() + "
    "); + list.add("[" + key.getName() + "] = [" + key.getClass().getName() + ' ' + Arrays.toString(val) + "] " + key.getState() + "
    "); } Collections.sort(list); for (String e : list) { @@ -219,7 +223,7 @@ public class RouterAppManager extends ClientAppManagerImpl { for (Map.Entry entry : _registered.entrySet()) { String key = entry.getKey(); ClientApp val = entry.getValue(); - list.add("[" + key + "] = [" + val.getClass().getName() + "]
    "); + list.add("[" + key + "] = [" + val.getClass().getName() + "]
    "); } Collections.sort(list); for (String e : list) {