Tunnels: Fix build message timestamp check for ECIES records

Log tweaks
This commit is contained in:
zzz
2021-04-04 13:21:07 -04:00
parent 00d3965303
commit de108dbc5e

View File

@@ -518,6 +518,8 @@ class BuildHandler implements Runnable {
_currentLookups.set(1);
if (_log.shouldLog(Log.DEBUG))
_log.debug("Request " + req
+ " From: " + from
+ " ID: " + state.msg.getUniqueId()
+ " handled, lookup next peer " + nextPeer
+ " lookups: " + current + '/' + limit);
_context.netDb().lookupRouterInfo(nextPeer, new HandleReq(_context, state, req, nextPeer),
@@ -525,7 +527,9 @@ class BuildHandler implements Runnable {
} else {
_currentLookups.decrementAndGet();
if (_log.shouldLog(Log.WARN))
_log.warn("Drop next hop lookup, limit " + limit + ": " + req);
_log.warn("Drop next hop lookup, limit " + limit + ": " + req
+ " From: " + from
+ " ID: " + state.msg.getUniqueId());
_context.statManager().addRateData("tunnel.dropLookupThrottle", 1);
if (from != null)
_context.commSystem().mayDisconnect(from);
@@ -536,7 +540,10 @@ class BuildHandler implements Runnable {
handleReq(nextPeerInfo, state, req, nextPeer);
long handleTime = System.currentTimeMillis() - beforeHandle;
if (_log.shouldLog(Log.DEBUG))
_log.debug("Request " + req + " handled and we know the next peer "
_log.debug("Request " + req
+ " From: " + from
+ " ID: " + state.msg.getUniqueId()
+ " handled and we know the next peer "
+ nextPeer + " after " + handleTime
+ "/" + decryptTime + "/" + lookupTime + "/" + timeSinceReceived);
return handleTime;
@@ -610,8 +617,14 @@ class BuildHandler implements Runnable {
_currentLookups.decrementAndGet();
getContext().statManager().addRateData("tunnel.rejectTimeout", 1);
getContext().statManager().addRateData("tunnel.buildLookupSuccess", 0);
if (_log.shouldLog(Log.WARN))
_log.warn("Next hop lookup failure: " + _req);
if (_log.shouldLog(Log.WARN)) {
Hash from = _state.fromHash;
if (from == null && _state.from != null)
from = _state.from.calculateHash();
_log.warn("Next hop lookup failure: " + _req
+ " From: " + from
+ " ID: " + _state.msg.getUniqueId());
}
// ??? should we blame the peer here? getContext().profileManager().tunnelTimedOut(_nextPeer);
getContext().messageHistory().tunnelRejected(_state.fromHash, new TunnelId(_req.readReceiveTunnelId()), _nextPeer,
@@ -741,7 +754,7 @@ class BuildHandler implements Runnable {
timeDiff = roundedNow - time;
maxAge = MAX_REQUEST_AGE;
}
if (timeDiff > MAX_REQUEST_AGE) {
if (timeDiff > maxAge) {
_context.statManager().addRateData("tunnel.rejectTooOld", 1);
if (_log.shouldLog(Log.WARN))
_log.warn("Dropping build request too old... replay attack? " + DataHelper.formatDuration(timeDiff) + ": " + req);
@@ -1056,7 +1069,7 @@ class BuildHandler implements Runnable {
fh = from.calculateHash();
if (fh != null && _requestThrottler.shouldThrottle(fh)) {
if (_log.shouldLog(Log.WARN))
_log.warn("Dropping tunnel request (from throttle), previous hop: " + fh);
_log.warn("Dropping tunnel request (from throttle) id " + reqId + ", previous hop: " + fh);
_context.statManager().addRateData("tunnel.dropReqThrottle", 1);
accept = false;
}