diff --git a/router/java/src/net/i2p/router/crypto/ratchet/RatchetSKM.java b/router/java/src/net/i2p/router/crypto/ratchet/RatchetSKM.java index ab336797c3..2e0981ec80 100644 --- a/router/java/src/net/i2p/router/crypto/ratchet/RatchetSKM.java +++ b/router/java/src/net/i2p/router/crypto/ratchet/RatchetSKM.java @@ -752,13 +752,19 @@ public class RatchetSKM extends SessionKeyManager implements SessionTagListener /** * Return a map of PublicKey to a set of inbound RatchetTagSets for that key. * Only for renderStatusHTML() below. + * Does not return expired sets or sets with null keys. */ private Map> getRatchetTagSetsByPublicKey() { Set inbound = getRatchetTagSets(); Map> inboundSets = new HashMap>(inbound.size()); + long now = _context.clock().now(); // Build a map of the inbound tag sets, grouped by PublicKey for (RatchetTagSet ts : inbound) { PublicKey pk = ts.getRemoteKey(); + if (pk == null) + continue; + if (ts.getExpiration() < now) + continue; Set sets = inboundSets.get(pk); if (sets == null) { sets = new HashSet(4); @@ -808,10 +814,7 @@ public class RatchetSKM extends SessionKeyManager implements SessionTagListener //buf.append(" created: ").append(DataHelper.formatTime(ts.getCreated())) // .append(" last use: ").append(DataHelper.formatTime(ts.getDate())); long expires = ts.getExpiration() - now; - if (expires > 0) - buf.append(" expires in: ").append(DataHelper.formatDuration2(expires)).append(" with "); - else - buf.append(" expired: ").append(DataHelper.formatDuration2(0 - expires)).append(" ago with "); + buf.append(" expires in: ").append(DataHelper.formatDuration2(expires)).append(" with "); buf.append(size).append('+').append(ts.remaining() - size).append(" tags remaining"); } } @@ -847,6 +850,9 @@ public class RatchetSKM extends SessionKeyManager implements SessionTagListener "
    "); for (RatchetTagSet ts : sets) { synchronized(ts) { + long expires = ts.getExpiration() - now; + if (expires <= 0) + continue; int size = ts.remaining(); buf.append("
  • ID: "); int id = ts.getID(); @@ -859,11 +865,7 @@ public class RatchetSKM extends SessionKeyManager implements SessionTagListener buf.append(" acked"); buf.append(" created: ").append(DataHelper.formatTime(ts.getCreated())) .append(" last use: ").append(DataHelper.formatTime(ts.getDate())); - long expires = ts.getExpiration() - now; - if (expires > 0) - buf.append(" expires in: ").append(DataHelper.formatDuration2(expires)).append(" with "); - else - buf.append(" expired: ").append(DataHelper.formatDuration2(0 - expires)).append(" ago with "); + buf.append(" expires in: ").append(DataHelper.formatDuration2(expires)).append(" with "); buf.append(size).append(" tags remaining"); if (ts.getNextKey() != null) buf.append(" NK sent");