Router: GarlicMessage debug logging improvements

This commit is contained in:
zzz
2020-04-23 18:56:03 +00:00
parent a97085ac67
commit da8f49a712
3 changed files with 13 additions and 15 deletions

View File

@ -81,9 +81,10 @@ public class GarlicMessage extends FastI2NPMessageImpl {
@Override
public String toString() {
StringBuilder buf = new StringBuilder();
buf.append("[GarlicMessage: ");
buf.append("Data length: ").append(getData().length).append(" bytes");
buf.append("]");
buf.append("[GarlicMessage " +
"ID: ").append(getUniqueId())
.append(" Data: ").append(_data.length).append(" bytes" +
"]");
return buf.toString();
}
}

View File

@ -238,11 +238,8 @@ public class GarlicMessageBuilder {
log.debug("Building a message expiring in " + timeFromNow + "ms: " + config, new Exception("created by"));
return null;
}
if (log.shouldLog(Log.DEBUG))
log.debug("CloveSet (" + config.getCloveCount() + " cloves) for message " + msg.getUniqueId() + " is " + cloveSet.length
+ " bytes and encrypted message data is " + encData.length + " bytes");
if (log.shouldDebug())
log.debug("Built ElG CloveSet (" + config.getCloveCount() + " cloves " + cloveSet.length + " bytes) in " + msg);
return msg;
}
@ -266,6 +263,9 @@ public class GarlicMessageBuilder {
return null;
msg.setData(encData);
msg.setMessageExpiration(config.getExpiration());
Log log = ctx.logManager().getLog(GarlicMessageBuilder.class);
if (log.shouldDebug())
log.debug("Built ECIES CloveSet (" + config.getCloveCount() + " cloves) in " + msg);
return msg;
}
@ -329,8 +329,7 @@ public class GarlicMessageBuilder {
return null;
}
if (log.shouldDebug())
log.debug("CloveSet (" + config.getCloveCount() + " cloves) for message " + msg.getUniqueId()
+ " encrypted message data is " + encData.length + " bytes");
log.debug("Built ECIES CloveSet (" + config.getCloveCount() + " cloves) in " + msg);
return msg;
}

View File

@ -77,7 +77,7 @@ public class GarlicMessageReceiver {
}
} else {
if (_log.shouldLog(Log.WARN))
_log.warn("Not trying to decrypt a garlic routed message to a disconnected client");
_log.warn("Not decrypting " + message + " for disconnected " + _clientDestination.toBase32());
return;
}
} else {
@ -99,10 +99,8 @@ public class GarlicMessageReceiver {
} else {
if (_log.shouldLog(Log.WARN)) {
String d = (_clientDestination != null) ? _clientDestination.toBase32() : "the router";
_log.warn("CloveMessageParser failed to decrypt the " + message.getData().length +
" byte message [" + message.getUniqueId()
+ "] for " + d + " with key " + decryptionKey.getType(),
new Exception("Decrypt garlic failed"));
String keys = (decryptionKey2 != null) ? "both ElGamal and ECIES keys" : decryptionKey.getType().toString();
_log.warn("Failed to decrypt " + message + " for " + d + " with " + keys);
}
_context.statManager().addRateData("crypto.garlic.decryptFail", 1);
_context.messageHistory().messageProcessingError(message.getUniqueId(),