I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 04509f59 authored by zzz's avatar zzz
Browse files

* Streaming: Enforce a minimum MTU of 512

parent 875dd65d
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment