Add system property to skip packet compression threshold validation
This commit is contained in:
@@ -39,6 +39,7 @@ public class MinecraftCompressDecoder extends MessageToMessageDecoder<ByteBuf> {
|
|||||||
private static final int UNCOMPRESSED_CAP =
|
private static final int UNCOMPRESSED_CAP =
|
||||||
Boolean.getBoolean("velocity.increased-compression-cap")
|
Boolean.getBoolean("velocity.increased-compression-cap")
|
||||||
? HARD_MAXIMUM_UNCOMPRESSED_SIZE : VANILLA_MAXIMUM_UNCOMPRESSED_SIZE;
|
? HARD_MAXIMUM_UNCOMPRESSED_SIZE : VANILLA_MAXIMUM_UNCOMPRESSED_SIZE;
|
||||||
|
private static final boolean SKIP_COMPRESSION_VALIDATION = Boolean.getBoolean("velocity.skip-uncompressed-packet-size-validation");
|
||||||
|
|
||||||
private int threshold;
|
private int threshold;
|
||||||
private final VelocityCompressor compressor;
|
private final VelocityCompressor compressor;
|
||||||
@@ -52,9 +53,11 @@ public class MinecraftCompressDecoder extends MessageToMessageDecoder<ByteBuf> {
|
|||||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
||||||
int claimedUncompressedSize = ProtocolUtils.readVarInt(in);
|
int claimedUncompressedSize = ProtocolUtils.readVarInt(in);
|
||||||
if (claimedUncompressedSize == 0) {
|
if (claimedUncompressedSize == 0) {
|
||||||
int actualUncompressedSize = in.readableBytes();
|
if (!SKIP_COMPRESSION_VALIDATION) {
|
||||||
checkFrame(actualUncompressedSize < threshold, "Actual uncompressed size %s is greater than"
|
int actualUncompressedSize = in.readableBytes();
|
||||||
+ " threshold %s", actualUncompressedSize, threshold);
|
checkFrame(actualUncompressedSize < threshold, "Actual uncompressed size %s is greater than"
|
||||||
|
+ " threshold %s", actualUncompressedSize, threshold);
|
||||||
|
}
|
||||||
// This message is not compressed.
|
// This message is not compressed.
|
||||||
out.add(in.retain());
|
out.add(in.retain());
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user