diff --git a/router/java/src/net/i2p/router/transport/ntcp/NTCPConnection.java b/router/java/src/net/i2p/router/transport/ntcp/NTCPConnection.java index 5610d62e1..070caae84 100644 --- a/router/java/src/net/i2p/router/transport/ntcp/NTCPConnection.java +++ b/router/java/src/net/i2p/router/transport/ntcp/NTCPConnection.java @@ -104,6 +104,15 @@ public class NTCPConnection implements FIFOBandwidthLimiter.CompleteListener { private static final int META_FREQUENCY = 10*60*1000; private static final int INFO_FREQUENCY = 6*60*60*1000; + /** + * Why this is 16K, and where it is documented, good question? + * We claim we can do 32K datagrams so this is a problem. + * Needs to be fixed. But SSU can handle it? + * In the meantime, don't let the transport bid on big messages. + */ + public static final int BUFFER_SIZE = 16*1024; + /** 2 bytes for length and 4 for CRC */ + public static final int MAX_MSG_SIZE = BUFFER_SIZE - (2 + 4); /** * Create an inbound connected (though not established) NTCP connection diff --git a/router/java/src/net/i2p/router/transport/ntcp/NTCPTransport.java b/router/java/src/net/i2p/router/transport/ntcp/NTCPTransport.java index 103b46b15..a9208e9a6 100644 --- a/router/java/src/net/i2p/router/transport/ntcp/NTCPTransport.java +++ b/router/java/src/net/i2p/router/transport/ntcp/NTCPTransport.java @@ -105,6 +105,7 @@ public class NTCPTransport extends TransportImpl { _context.statManager().createRateStat("ntcp.outboundEstablishFailed", "", "ntcp", new long[] { 60*1000, 10*60*1000 }); _context.statManager().createRateStat("ntcp.outboundFailedIOEImmediate", "", "ntcp", new long[] { 60*1000, 10*60*1000 }); _context.statManager().createRateStat("ntcp.invalidOutboundSkew", "", "ntcp", new long[] { 60*1000, 10*60*1000 }); + _context.statManager().createRateStat("ntcp.noBidTooLargeI2NP", "send size", "ntcp", new long[] { 60*60*1000 }); _context.statManager().createRateStat("ntcp.prepBufCache", "", "ntcp", new long[] { 60*1000, 10*60*1000 }); _context.statManager().createRateStat("ntcp.queuedRecv", "", "ntcp", new long[] { 60*1000, 10*60*1000 }); _context.statManager().createRateStat("ntcp.read", "", "ntcp", new long[] { 60*1000, 10*60*1000 }); @@ -243,6 +244,11 @@ public class NTCPTransport extends TransportImpl { public TransportBid bid(RouterInfo toAddress, long dataSize) { if (!isAlive()) return null; + if (dataSize > NTCPConnection.MAX_MSG_SIZE) { + // let SSU deal with it + _context.statManager().addRateData("ntcp.noBidTooLargeI2NP", dataSize, 0); + return null; + } Hash peer = toAddress.getIdentity().calculateHash(); if (_context.shitlist().isShitlisted(peer, STYLE)) { // we aren't shitlisted in general (since we are trying to get a bid), but we have