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 =
|
||||
Boolean.getBoolean("velocity.increased-compression-cap")
|
||||
? 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 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 {
|
||||
int claimedUncompressedSize = ProtocolUtils.readVarInt(in);
|
||||
if (claimedUncompressedSize == 0) {
|
||||
int actualUncompressedSize = in.readableBytes();
|
||||
checkFrame(actualUncompressedSize < threshold, "Actual uncompressed size %s is greater than"
|
||||
+ " threshold %s", actualUncompressedSize, threshold);
|
||||
if (!SKIP_COMPRESSION_VALIDATION) {
|
||||
int actualUncompressedSize = in.readableBytes();
|
||||
checkFrame(actualUncompressedSize < threshold, "Actual uncompressed size %s is greater than"
|
||||
+ " threshold %s", actualUncompressedSize, threshold);
|
||||
}
|
||||
// This message is not compressed.
|
||||
out.add(in.retain());
|
||||
return;
|
||||
|
Reference in New Issue
Block a user