forked from I2P_Developers/i2p.i2p
Don't let NTCP bid on msgs too big to handle
This commit is contained in:
@@ -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
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user