From b17d32150363fb86cb90953ce6cb0b3d965088bd Mon Sep 17 00:00:00 2001 From: zzz <zzz@i2pmail.org> Date: Sun, 17 Jan 2021 09:47:04 -0500 Subject: [PATCH] Ratchet: log tweaks --- .../i2p/router/crypto/ratchet/RatchetSKM.java | 16 +++++++++++----- .../i2p/router/crypto/ratchet/RatchetTagSet.java | 11 +++++++++-- 2 files changed, 20 insertions(+), 7 deletions(-) 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 6e52c6a61a..81f048d8f0 100644 --- a/router/java/src/net/i2p/router/crypto/ratchet/RatchetSKM.java +++ b/router/java/src/net/i2p/router/crypto/ratchet/RatchetSKM.java @@ -864,7 +864,7 @@ public class RatchetSKM extends SessionKeyManager implements SessionTagListener if (ts.getAcked()) buf.append(" acked"); buf.append(" created:</b> ").append(DataHelper.formatTime(ts.getCreated())) - .append(" <b>last use:</b> ").append(DataHelper.formatTime(ts.getDate())); + .append(" <b>last used:</b> ").append(DataHelper.formatTime(ts.getDate())); buf.append(" <b>expires in:</b> ").append(DataHelper.formatDuration2(expires)).append(" with "); buf.append(size).append(" tags remaining"); if (ts.getNextKey() != null) @@ -1178,8 +1178,11 @@ public class RatchetSKM extends SessionKeyManager implements SessionTagListener _context.clock().now(), newtsID, _myOBKeyID); _tagSet = ts; _currentOBTagSetID = newtsID; - if (_log.shouldDebug()) - _log.debug("Got nextkey " + key + "\nratchet to new OB ES TS:\n" + ts); + if (_log.shouldWarn()) + _log.warn("Got nextkey " + key + + "from " + (_destination != null ? _destination.toBase32() : "???") + + "\nold OB TS:\n" + oldts + + "\nratchet to new OB ES TS:\n" + ts); } else { // this is about my inbound tag set if (key.equals(_hisOBKey)) { @@ -1273,8 +1276,11 @@ public class RatchetSKM extends SessionKeyManager implements SessionTagListener _context.clock().now(), newtsID, _myIBKeyID, MAX_RCV_WINDOW_ES, MAX_RCV_WINDOW_ES); _nextIBRootKey = ts.getNextRootKey(); - if (_log.shouldDebug()) - _log.debug("Got nextkey " + key + "\nratchet to new IB ES TS:\n" + ts); + if (_log.shouldWarn()) + _log.warn("Got nextkey " + key + + "from " + (_destination != null ? _destination.toBase32() : "???") + + "\nold IB TS ID #" + oldtsID + + "\nratchet to new IB ES TS:\n" + ts); } } } diff --git a/router/java/src/net/i2p/router/crypto/ratchet/RatchetTagSet.java b/router/java/src/net/i2p/router/crypto/ratchet/RatchetTagSet.java index cab7c0cffa..26a4022cd5 100644 --- a/router/java/src/net/i2p/router/crypto/ratchet/RatchetTagSet.java +++ b/router/java/src/net/i2p/router/crypto/ratchet/RatchetTagSet.java @@ -81,6 +81,7 @@ class RatchetTagSet implements TagSetHandle { private static final byte[] ZEROLEN = new byte[0]; private static final int TAGLEN = RatchetSessionTag.LENGTH; private static final int MAX = 65535; + private static final boolean DEBUG = false; private static final boolean TEST_RATCHET = false; // 4 * max streaming window private static final int LOW = TEST_RATCHET ? (MAX - 512) : (MAX - 4096); @@ -572,10 +573,16 @@ class RatchetTagSet implements TagSetHandle { buf.append("\n ").append(n).append('\t').append(tag.toBase64()); if (_sessionKeys != null) { byte[] key = _sessionKeys.get(n); - if (key != null) + if (key != null) { buf.append('\t').append(Base64.encode(key)); - else + } else { buf.append("\tTBD"); + // set DEBUG if you want to see them all + if (!DEBUG) { + buf.append(" (" + (sz - (i +1)) + " more)"); + break; + } + } } } } -- GitLab