forked from I2P_Developers/i2p.i2p
* Streaming: Enforce a minimum MTU of 512
This commit is contained in:
@@ -162,6 +162,7 @@ public class ConnectionOptions extends I2PSocketOptionsImpl {
|
||||
*
|
||||
*/
|
||||
public static final int DEFAULT_MAX_MESSAGE_SIZE = 1730;
|
||||
public static final int MIN_MESSAGE_SIZE = 512;
|
||||
|
||||
public ConnectionOptions() {
|
||||
super();
|
||||
@@ -389,7 +390,7 @@ public class ConnectionOptions extends I2PSocketOptionsImpl {
|
||||
* @return Maximum message size (MTU/MRU)
|
||||
*/
|
||||
public int getMaxMessageSize() { return _maxMessageSize; }
|
||||
public void setMaxMessageSize(int bytes) { _maxMessageSize = bytes; }
|
||||
public void setMaxMessageSize(int bytes) { _maxMessageSize = Math.max(bytes, MIN_MESSAGE_SIZE); }
|
||||
|
||||
/**
|
||||
* how long we want to wait before any data is transferred on the
|
||||
|
@@ -67,12 +67,17 @@ public class ConnectionPacketHandler {
|
||||
}
|
||||
|
||||
if (packet.isFlagSet(Packet.FLAG_MAX_PACKET_SIZE_INCLUDED)) {
|
||||
if (packet.getOptionalMaxSize() < con.getOptions().getMaxMessageSize()) {
|
||||
int size = packet.getOptionalMaxSize();
|
||||
if (size < ConnectionOptions.MIN_MESSAGE_SIZE) {
|
||||
// log.error? connection reset?
|
||||
size = ConnectionOptions.MIN_MESSAGE_SIZE;
|
||||
}
|
||||
if (size < con.getOptions().getMaxMessageSize()) {
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("Reducing our max message size to " + packet.getOptionalMaxSize()
|
||||
_log.info("Reducing our max message size to " + size
|
||||
+ " from " + con.getOptions().getMaxMessageSize());
|
||||
con.getOptions().setMaxMessageSize(packet.getOptionalMaxSize());
|
||||
con.getOutputStream().setBufferSize(packet.getOptionalMaxSize());
|
||||
con.getOptions().setMaxMessageSize(size);
|
||||
con.getOutputStream().setBufferSize(size);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user