From baa89c5bbf46e05f2b2cd15f40f5b556c4f62a1a Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Thu, 21 Jun 2012 19:10:14 +0000 Subject: [PATCH] * OCMOSJ, ElG, Streaming: log tweaks --- .../client/streaming/MessageInputStream.java | 6 +-- .../client/streaming/MessageOutputStream.java | 4 +- .../src/net/i2p/crypto/ElGamalAESEngine.java | 4 +- .../src/net/i2p/data/i2np/GarlicMessage.java | 2 +- .../router/message/GarlicMessageBuilder.java | 6 +-- .../router/message/GarlicMessageParser.java | 8 ++-- .../OutboundClientMessageJobHelper.java | 25 ++++++------ .../OutboundClientMessageOneShotJob.java | 38 +++++++++---------- 8 files changed, 45 insertions(+), 48 deletions(-) diff --git a/apps/streaming/java/src/net/i2p/client/streaming/MessageInputStream.java b/apps/streaming/java/src/net/i2p/client/streaming/MessageInputStream.java index 3dc510fd52..956eb9b510 100644 --- a/apps/streaming/java/src/net/i2p/client/streaming/MessageInputStream.java +++ b/apps/streaming/java/src/net/i2p/client/streaming/MessageInputStream.java @@ -157,8 +157,8 @@ class MessageInputStream extends InputStream { */ public int getReadTimeout() { return _readTimeout; } public void setReadTimeout(int timeout) { - if (_log.shouldLog(Log.INFO)) - _log.info("Changing read timeout from " + _readTimeout + " to " + timeout); + if (_log.shouldLog(Log.DEBUG)) + _log.debug("Changing read timeout from " + _readTimeout + " to " + timeout); _readTimeout = timeout; } @@ -373,7 +373,7 @@ class MessageInputStream extends InputStream { } } if (_log.shouldLog(Log.DEBUG)) - _log.debug("available(): " + numBytes + " " + toString()); + _log.debug("available(): " + numBytes); return numBytes; } diff --git a/apps/streaming/java/src/net/i2p/client/streaming/MessageOutputStream.java b/apps/streaming/java/src/net/i2p/client/streaming/MessageOutputStream.java index 96a3ebe557..3a4cd42060 100644 --- a/apps/streaming/java/src/net/i2p/client/streaming/MessageOutputStream.java +++ b/apps/streaming/java/src/net/i2p/client/streaming/MessageOutputStream.java @@ -81,8 +81,8 @@ class MessageOutputStream extends OutputStream { } public void setWriteTimeout(int ms) { - if (_log.shouldLog(Log.INFO)) - _log.info("Changing write timeout from " + _writeTimeout + " to " + ms); + if (_log.shouldLog(Log.DEBUG)) + _log.debug("Changing write timeout from " + _writeTimeout + " to " + ms); _writeTimeout = ms; } diff --git a/core/java/src/net/i2p/crypto/ElGamalAESEngine.java b/core/java/src/net/i2p/crypto/ElGamalAESEngine.java index 755b688a25..c31a204823 100644 --- a/core/java/src/net/i2p/crypto/ElGamalAESEngine.java +++ b/core/java/src/net/i2p/crypto/ElGamalAESEngine.java @@ -100,7 +100,7 @@ public class ElGamalAESEngine { //if (_log.shouldLog(Log.DEBUG)) _log.debug("Key is known for tag " + st); long id = _context.random().nextLong(); if (_log.shouldLog(Log.DEBUG)) - _log.debug(id + ": Decrypting existing session encrypted with tag: " + st.toString() + ": key: " + key.toBase64() + ": " + data.length + " bytes: " + Base64.encode(data, 0, 64)); + _log.debug(id + ": Decrypting existing session encrypted with tag: " + st.toString() + ": key: " + key.toBase64() + ": " + data.length + " bytes " /* + Base64.encode(data, 0, 64) */ ); decrypted = decryptExistingSession(data, key, targetPrivateKey, foundTags, usedKey, foundKey); if (decrypted != null) { @@ -410,7 +410,7 @@ public class ElGamalAESEngine { _context.statManager().updateFrequency("crypto.elGamalAES.encryptExistingSession"); byte rv[] = encryptExistingSession(data, target, key, tagsForDelivery, currentTag, newKey, paddedSize); if (_log.shouldLog(Log.DEBUG)) - _log.debug("Existing session encrypted with tag: " + currentTag.toString() + ": " + rv.length + " bytes and key: " + key.toBase64() + ": " + Base64.encode(rv, 0, 64)); + _log.debug("Existing session encrypted with tag: " + currentTag.toString() + ": " + rv.length + " bytes and key: " + key.toBase64() /* + ": " + Base64.encode(rv, 0, 64) */); return rv; } diff --git a/router/java/src/net/i2p/data/i2np/GarlicMessage.java b/router/java/src/net/i2p/data/i2np/GarlicMessage.java index c4cfd29c9e..07621c462c 100644 --- a/router/java/src/net/i2p/data/i2np/GarlicMessage.java +++ b/router/java/src/net/i2p/data/i2np/GarlicMessage.java @@ -83,7 +83,7 @@ public class GarlicMessage extends FastI2NPMessageImpl { public String toString() { StringBuilder buf = new StringBuilder(); buf.append("[GarlicMessage: "); - buf.append("\n\tData length: ").append(getData().length).append(" bytes"); + buf.append("Data length: ").append(getData().length).append(" bytes"); buf.append("]"); return buf.toString(); } diff --git a/router/java/src/net/i2p/router/message/GarlicMessageBuilder.java b/router/java/src/net/i2p/router/message/GarlicMessageBuilder.java index 0f01d53c62..ad7c63627e 100644 --- a/router/java/src/net/i2p/router/message/GarlicMessageBuilder.java +++ b/router/java/src/net/i2p/router/message/GarlicMessageBuilder.java @@ -233,8 +233,8 @@ public class GarlicMessageBuilder { } if (log.shouldLog(Log.DEBUG)) - log.debug("CloveSet size for message " + msg.getUniqueId() + " is " + cloveSet.length - + " and encrypted message data is " + encData.length); + log.debug("CloveSet (" + config.getCloveCount() + " cloves) for message " + msg.getUniqueId() + " is " + cloveSet.length + + " bytes and encrypted message data is " + encData.length + " bytes"); return msg; } @@ -268,7 +268,7 @@ public class GarlicMessageBuilder { for (int i = 0; i < config.getCloveCount(); i++) { GarlicConfig c = config.getClove(i); if (c instanceof PayloadGarlicConfig) { - log.debug("Subclove IS a payload garlic clove"); + //log.debug("Subclove IS a payload garlic clove"); cloves[i] = buildClove(ctx, (PayloadGarlicConfig)c); } else { log.debug("Subclove IS NOT a payload garlic clove"); diff --git a/router/java/src/net/i2p/router/message/GarlicMessageParser.java b/router/java/src/net/i2p/router/message/GarlicMessageParser.java index 4885d21c11..083ffd8c37 100644 --- a/router/java/src/net/i2p/router/message/GarlicMessageParser.java +++ b/router/java/src/net/i2p/router/message/GarlicMessageParser.java @@ -71,13 +71,13 @@ class GarlicMessageParser { if (_log.shouldLog(Log.DEBUG)) _log.debug("# cloves to read: " + numCloves); for (int i = 0; i < numCloves; i++) { - if (_log.shouldLog(Log.DEBUG)) - _log.debug("Reading clove " + i); + //if (_log.shouldLog(Log.DEBUG)) + // _log.debug("Reading clove " + i); GarlicClove clove = new GarlicClove(_context); offset += clove.readBytes(data, offset); set.addClove(clove); - if (_log.shouldLog(Log.DEBUG)) - _log.debug("After reading clove " + i); + //if (_log.shouldLog(Log.DEBUG)) + // _log.debug("After reading clove " + i); } //Certificate cert = new Certificate(); //offset += cert.readBytes(data, offset); diff --git a/router/java/src/net/i2p/router/message/OutboundClientMessageJobHelper.java b/router/java/src/net/i2p/router/message/OutboundClientMessageJobHelper.java index cf8a0dfc9e..7941616f5f 100644 --- a/router/java/src/net/i2p/router/message/OutboundClientMessageJobHelper.java +++ b/router/java/src/net/i2p/router/message/OutboundClientMessageJobHelper.java @@ -88,7 +88,7 @@ class OutboundClientMessageJobHelper { PayloadGarlicConfig dataClove, Hash from, Destination dest, TunnelInfo replyTunnel, boolean requireAck, LeaseSet bundledReplyLeaseSet) { Log log = ctx.logManager().getLog(OutboundClientMessageJobHelper.class); - if (log.shouldLog(Log.DEBUG)) + if (replyToken >= 0 && log.shouldLog(Log.DEBUG)) log.debug("Reply token: " + replyToken); GarlicConfig config = new GarlicConfig(); @@ -136,20 +136,17 @@ class OutboundClientMessageJobHelper { Log log = ctx.logManager().getLog(OutboundClientMessageJobHelper.class); PayloadGarlicConfig ackClove = new PayloadGarlicConfig(); - Hash replyToTunnelRouter = null; // inbound tunnel gateway - TunnelId replyToTunnelId = null; // tunnel id on that gateway - if (replyToTunnel == null) { if (log.shouldLog(Log.WARN)) log.warn("Unable to send client message from " + from.toBase64() + ", as there are no inbound tunnels available"); return null; } - replyToTunnelId = replyToTunnel.getReceiveTunnelId(0); - replyToTunnelRouter = replyToTunnel.getPeer(0); + TunnelId replyToTunnelId = replyToTunnel.getReceiveTunnelId(0); // tunnel id on that gateway + Hash replyToTunnelRouter = replyToTunnel.getPeer(0); // inbound tunnel gateway if (log.shouldLog(Log.DEBUG)) log.debug("Ack for the data message will come back along tunnel " + replyToTunnelId - + ":\n" + replyToTunnel); + + ": " + replyToTunnel); DeliveryInstructions ackInstructions = new DeliveryInstructions(); ackInstructions.setDeliveryMode(DeliveryInstructions.DELIVERY_MODE_TUNNEL); @@ -163,8 +160,8 @@ class OutboundClientMessageJobHelper { DeliveryStatusMessage msg = new DeliveryStatusMessage(ctx); msg.setArrival(ctx.clock().now()); msg.setMessageId(replyToken); - if (log.shouldLog(Log.DEBUG)) - log.debug("Delivery status message key: " + replyToken + " arrival: " + msg.getArrival()); + //if (log.shouldLog(Log.DEBUG)) + // log.debug("Delivery status message key: " + replyToken + " arrival: " + msg.getArrival()); ackClove.setCertificate(Certificate.NULL_CERT); ackClove.setDeliveryInstructions(ackInstructions); @@ -175,11 +172,11 @@ class OutboundClientMessageJobHelper { // defaults //ackClove.setRequestAck(false); - if (log.shouldLog(Log.DEBUG)) - log.debug("Delivery status message is targetting us [" - + ackClove.getRecipient().getIdentity().getHash().toBase64() - + "] via tunnel " + replyToTunnelId.getTunnelId() + " on " - + replyToTunnelRouter.toBase64()); + //if (log.shouldLog(Log.DEBUG)) + // log.debug("Delivery status message is targetting us [" + // + ackClove.getRecipient().getIdentity().getHash().toBase64() + // + "] via tunnel " + replyToTunnelId.getTunnelId() + " on " + // + replyToTunnelRouter.toBase64()); return ackClove; } diff --git a/router/java/src/net/i2p/router/message/OutboundClientMessageOneShotJob.java b/router/java/src/net/i2p/router/message/OutboundClientMessageOneShotJob.java index 4896e57d46..ea0664ec61 100644 --- a/router/java/src/net/i2p/router/message/OutboundClientMessageOneShotJob.java +++ b/router/java/src/net/i2p/router/message/OutboundClientMessageOneShotJob.java @@ -150,8 +150,8 @@ public class OutboundClientMessageOneShotJob extends JobImpl { } } overallExpiration = timeoutMs + _start; - if (_log.shouldLog(Log.INFO)) - _log.info(getJobId() + " Default Expiration (ms): " + timeoutMs); + if (_log.shouldLog(Log.DEBUG)) + _log.debug(getJobId() + " Default Expiration (ms): " + timeoutMs); } _overallExpiration = overallExpiration; } @@ -182,9 +182,9 @@ public class OutboundClientMessageOneShotJob extends JobImpl { dieFatal(); return; } - if (_log.shouldLog(Log.DEBUG)) - _log.debug(getJobId() + ": Send outbound client message job beginning" + - ": preparing to search for the leaseSet for " + _toString); + //if (_log.shouldLog(Log.DEBUG)) + // _log.debug(getJobId() + ": Send outbound client message job beginning" + + // ": preparing to search for the leaseSet for " + _toString); long timeoutMs = _overallExpiration - now; Hash key = _to.calculateHash(); SendJob success = new SendJob(getContext()); @@ -474,8 +474,8 @@ public class OutboundClientMessageOneShotJob extends JobImpl { dieFatal(); return; } - if (_log.shouldLog(Log.DEBUG)) - _log.debug(getJobId() + ": Clove built to " + _toString); + //if (_log.shouldLog(Log.DEBUG)) + // _log.debug(getJobId() + ": Clove built to " + _toString); long msgExpiration = _overallExpiration; // getContext().clock().now() + OVERALL_TIMEOUT_MS_DEFAULT; GarlicMessage msg = OutboundClientMessageJobHelper.createGarlicMessage(getContext(), token, msgExpiration, key, @@ -494,8 +494,8 @@ public class OutboundClientMessageOneShotJob extends JobImpl { return; } - if (_log.shouldLog(Log.DEBUG)) - _log.debug(getJobId() + ": send() - token expected " + token + " to " + _toString); + //if (_log.shouldLog(Log.DEBUG)) + // _log.debug(getJobId() + ": send() - token expected " + token + " to " + _toString); SendSuccessJob onReply = null; SendTimeoutJob onFail = null; @@ -515,14 +515,14 @@ public class OutboundClientMessageOneShotJob extends JobImpl { } if (_log.shouldLog(Log.DEBUG)) - _log.debug(getJobId() + ": Placing GarlicMessage into the new tunnel message bound for " + _log.debug(getJobId() + ": GarlicMessage in new tunnel msg for " + _toString + " at " + _lease.getTunnelId() + " on " + _lease.getGateway()); if (_outTunnel != null) { if (_log.shouldLog(Log.DEBUG)) - _log.debug(getJobId() + ": Sending tunnel message out " + _outTunnel.getSendTunnelId(0) + " to " + _log.debug(getJobId() + ": Sending msg out " + _outTunnel.getSendTunnelId(0) + " to " + _toString + " at " + _lease.getTunnelId() + " on " + _lease.getGateway()); @@ -571,9 +571,9 @@ public class OutboundClientMessageOneShotJob extends JobImpl { long before = getContext().clock().now(); getContext().tunnelDispatcher().dispatchOutbound(_msg, _outTunnel.getSendTunnelId(0), _lease.getTunnelId(), _lease.getGateway()); long dispatchSendTime = getContext().clock().now() - before; - if (_log.shouldLog(Log.INFO)) - _log.info(OutboundClientMessageOneShotJob.this.getJobId() + - ": Dispatching message to " + _toString + " complete"); + //if (_log.shouldLog(Log.INFO)) + // _log.info(OutboundClientMessageOneShotJob.this.getJobId() + + // ": Dispatching message to " + _toString + " complete"); getContext().statManager().addRateData("client.dispatchTime", getContext().clock().now() - _start, 0); getContext().statManager().addRateData("client.dispatchSendTime", dispatchSendTime, 0); } @@ -728,8 +728,8 @@ public class OutboundClientMessageOneShotJob extends JobImpl { _clove = clove; _cloveId = _clove.getId(); - if (_log.shouldLog(Log.DEBUG)) - _log.debug(getJobId() + ": Built payload clove with id " + clove.getId()); + //if (_log.shouldLog(Log.DEBUG)) + // _log.debug(getJobId() + ": Built payload clove with id " + clove.getId()); return true; } @@ -858,9 +858,9 @@ public class OutboundClientMessageOneShotJob extends JobImpl { public String getName() { return "Outbound client message send timeout"; } public void runJob() { - if (_log.shouldLog(Log.INFO)) - _log.info(OutboundClientMessageOneShotJob.this.getJobId() - + ": Soft timeout through the lease " + _lease); + //if (_log.shouldLog(Log.INFO)) + // _log.info(OutboundClientMessageOneShotJob.this.getJobId() + // + ": Soft timeout through the lease " + _lease); // unused //_lease.setNumFailure(_lease.getNumFailure()+1); -- GitLab