diff --git a/router/java/src/net/i2p/router/tunnel/BatchedPreprocessor.java b/router/java/src/net/i2p/router/tunnel/BatchedPreprocessor.java index 2e49098742a7e5d569870b3c546eb574643e0766..d363d7a3f540cda01e194c7d836aeac93c6d8c5b 100644 --- a/router/java/src/net/i2p/router/tunnel/BatchedPreprocessor.java +++ b/router/java/src/net/i2p/router/tunnel/BatchedPreprocessor.java @@ -48,6 +48,8 @@ class BatchedPreprocessor extends TrivialPreprocessor { private long _pendingSince; private final String _name; + private static final boolean DEBUG = false; + public BatchedPreprocessor(RouterContext ctx, String name) { super(ctx); _name = name; @@ -175,7 +177,8 @@ class BatchedPreprocessor extends TrivialPreprocessor { + " len=" + cur.getData().length + " alloc=" + allocated); if (timingBuf != null) timingBuf.append(" sent " + cur); - notePreprocessing(cur.getMessageId(), cur.getFragmentNumber(), cur.getData().length, cur.getMessageIds(), "flushed allocated"); + if (DEBUG) + notePreprocessing(cur.getMessageId(), cur.getFragmentNumber(), cur.getData().length, cur.getMessageIds(), "flushed allocated"); _context.statManager().addRateData("tunnel.batchFragmentation", cur.getFragmentNumber() + 1); _context.statManager().addRateData("tunnel.writeDelay", cur.getLifetime(), cur.getData().length); } @@ -184,7 +187,8 @@ class BatchedPreprocessor extends TrivialPreprocessor { PendingGatewayMessage cur = pending.remove(0); if (timingBuf != null) timingBuf.append(" sent perfect fit " + cur).append("."); - notePreprocessing(cur.getMessageId(), cur.getFragmentNumber(), msg.getData().length, msg.getMessageIds(), "flushed tail, remaining: " + pending); + if (DEBUG) + notePreprocessing(cur.getMessageId(), cur.getFragmentNumber(), msg.getData().length, msg.getMessageIds(), "flushed tail, remaining: " + pending); _context.statManager().addRateData("tunnel.batchFragmentation", cur.getFragmentNumber() + 1); _context.statManager().addRateData("tunnel.writeDelay", cur.getLifetime(), cur.getData().length); } @@ -234,7 +238,8 @@ class BatchedPreprocessor extends TrivialPreprocessor { if (cur.getOffset() < cur.getData().length) break; pending.remove(0); - notePreprocessing(cur.getMessageId(), cur.getFragmentNumber(), cur.getData().length, cur.getMessageIds(), "flushed remaining"); + if (DEBUG) + notePreprocessing(cur.getMessageId(), cur.getFragmentNumber(), cur.getData().length, cur.getMessageIds(), "flushed remaining"); _context.statManager().addRateData("tunnel.batchFragmentation", cur.getFragmentNumber() + 1); _context.statManager().addRateData("tunnel.writeDelay", cur.getLifetime(), cur.getData().length); } @@ -383,9 +388,12 @@ class BatchedPreprocessor extends TrivialPreprocessor { } long msgId = sender.sendPreprocessed(preprocessed, rec); - for (int i = 0; i < pending.size(); i++) { - PendingGatewayMessage cur = pending.get(i); - cur.addMessageId(msgId); + if (DEBUG) { + // creates a list in PGM + for (int i = 0; i < pending.size(); i++) { + PendingGatewayMessage cur = pending.get(i); + cur.addMessageId(msgId); + } } if (_log.shouldLog(Log.DEBUG)) _log.debug("Sent " + startAt + ":" + sendThrough + " out of " + pending + " in message " + msgId); diff --git a/router/java/src/net/i2p/router/tunnel/BatchedRouterPreprocessor.java b/router/java/src/net/i2p/router/tunnel/BatchedRouterPreprocessor.java index 33f446893f99a5b521dc5486bee641c5cf7ebc69..3d62ded4bd777d320aafc9e2eb876d1829b5ebb8 100644 --- a/router/java/src/net/i2p/router/tunnel/BatchedRouterPreprocessor.java +++ b/router/java/src/net/i2p/router/tunnel/BatchedRouterPreprocessor.java @@ -11,8 +11,8 @@ import net.i2p.router.RouterContext; * */ class BatchedRouterPreprocessor extends BatchedPreprocessor { - private TunnelCreatorConfig _config; - protected HopConfig _hopConfig; + private final TunnelCreatorConfig _config; + protected final HopConfig _hopConfig; private final long _sendDelay; /** @@ -34,12 +34,14 @@ class BatchedRouterPreprocessor extends BatchedPreprocessor { public BatchedRouterPreprocessor(RouterContext ctx, TunnelCreatorConfig cfg) { super(ctx, getName(cfg)); _config = cfg; + _hopConfig = null; _sendDelay = initialSendDelay(); } /** for IBGWs */ public BatchedRouterPreprocessor(RouterContext ctx, HopConfig cfg) { super(ctx, getName(cfg)); + _config = null; _hopConfig = cfg; _sendDelay = initialSendDelay(); } diff --git a/router/java/src/net/i2p/router/tunnel/OutboundSender.java b/router/java/src/net/i2p/router/tunnel/OutboundSender.java index 961c29031f610d2bfe0c9f24fc0fa3d4fb9194ca..6125bf48eda35bde3cb98b8ffe74e172522a4c03 100644 --- a/router/java/src/net/i2p/router/tunnel/OutboundSender.java +++ b/router/java/src/net/i2p/router/tunnel/OutboundSender.java @@ -10,30 +10,30 @@ import net.i2p.util.Log; * */ class OutboundSender implements TunnelGateway.Sender { - private final I2PAppContext _context; - private final Log _log; + //private final I2PAppContext _context; + //private final Log _log; private final TunnelCreatorConfig _config; private final OutboundGatewayProcessor _processor; //static final boolean USE_ENCRYPTION = HopProcessor.USE_ENCRYPTION; public OutboundSender(I2PAppContext ctx, TunnelCreatorConfig config) { - _context = ctx; - _log = ctx.logManager().getLog(OutboundSender.class); + //_context = ctx; + //_log = ctx.logManager().getLog(OutboundSender.class); _config = config; - _processor = new OutboundGatewayProcessor(_context, config); + _processor = new OutboundGatewayProcessor(ctx, config); } public long sendPreprocessed(byte[] preprocessed, TunnelGateway.Receiver receiver) { - if (_log.shouldLog(Log.DEBUG)) - _log.debug("preprocessed data going out " + _config + ": " + Base64.encode(preprocessed)); + //if (_log.shouldLog(Log.DEBUG)) + // _log.debug("preprocessed data going out " + _config + ": " + Base64.encode(preprocessed)); //if (USE_ENCRYPTION) _processor.process(preprocessed, 0, preprocessed.length); - if (_log.shouldLog(Log.DEBUG)) - _log.debug("after wrapping up the preprocessed data on " + _config); + //if (_log.shouldLog(Log.DEBUG)) + // _log.debug("after wrapping up the preprocessed data on " + _config); long rv = receiver.receiveEncrypted(preprocessed); - if (_log.shouldLog(Log.DEBUG)) - _log.debug("after receiving on " + _config + ": receiver = " + receiver); + //if (_log.shouldLog(Log.DEBUG)) + // _log.debug("after receiving on " + _config + ": receiver = " + receiver); return rv; } } diff --git a/router/java/src/net/i2p/router/tunnel/TrivialPreprocessor.java b/router/java/src/net/i2p/router/tunnel/TrivialPreprocessor.java index 0d8475ece717d50a1d1b27540ecf39da39e6e7ac..a371cf306e6833575fca0fa1ca821798efada3bd 100644 --- a/router/java/src/net/i2p/router/tunnel/TrivialPreprocessor.java +++ b/router/java/src/net/i2p/router/tunnel/TrivialPreprocessor.java @@ -18,7 +18,7 @@ import net.i2p.util.SimpleByteCache; * * See FragmentHandler Javadoc for tunnel message fragment format */ -class TrivialPreprocessor implements TunnelGateway.QueuePreprocessor { +abstract class TrivialPreprocessor implements TunnelGateway.QueuePreprocessor { protected final RouterContext _context; protected final Log _log; @@ -48,7 +48,7 @@ class TrivialPreprocessor implements TunnelGateway.QueuePreprocessor { * NOTE: Unused here, see BatchedPreprocessor override, super is not called. */ public boolean preprocessQueue(List<PendingGatewayMessage> pending, TunnelGateway.Sender sender, TunnelGateway.Receiver rec) { - throw new IllegalArgumentException("unused, right?"); + throw new UnsupportedOperationException("unused, right?"); } protected void notePreprocessing(long messageId, int numFragments, int totalLength, List<Long> messageIds, String msg) {} @@ -265,7 +265,7 @@ class TrivialPreprocessor implements TunnelGateway.QueuePreprocessor { * Does NOT include 4 for the message ID if the message will be fragmented; * call getInstructionAugmentationSize() for that. */ - protected int getInstructionsSize(PendingGatewayMessage msg) { + protected static int getInstructionsSize(PendingGatewayMessage msg) { if (msg.getFragmentNumber() > 0) return 7; // control byte @@ -283,7 +283,7 @@ class TrivialPreprocessor implements TunnelGateway.QueuePreprocessor { } /** @return 0 or 4 */ - protected int getInstructionAugmentationSize(PendingGatewayMessage msg, int offset, int instructionsSize) { + protected static int getInstructionAugmentationSize(PendingGatewayMessage msg, int offset, int instructionsSize) { int payloadLength = msg.getData().length - msg.getOffset(); if (offset + payloadLength + instructionsSize + IV_SIZE + 1 + 4 > PREPROCESSED_SIZE) { // requires fragmentation, so include the messageId diff --git a/router/java/src/net/i2p/router/tunnel/TunnelGateway.java b/router/java/src/net/i2p/router/tunnel/TunnelGateway.java index 242b3dc036747b58d7d3bfbd533f33b105f3d07c..eb1632224d6e316d9b1dc6b95ed3edc1d0850166 100644 --- a/router/java/src/net/i2p/router/tunnel/TunnelGateway.java +++ b/router/java/src/net/i2p/router/tunnel/TunnelGateway.java @@ -33,7 +33,7 @@ import net.i2p.util.SimpleTimer2; * * Unused directly - see PumpedTunnelGateway, ThrottledPumpedTunnelGateway, and TunnelGatewayZeroHop overrides. */ -class TunnelGateway { +abstract class TunnelGateway { protected final RouterContext _context; protected final Log _log; protected final List<PendingGatewayMessage> _queue;