diff options
author | Bjarne Koll <[email protected]> | 2024-11-06 11:00:10 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2024-11-06 11:00:10 +0100 |
commit | fcb6c72bc95ff62b9cd78dec457f485dafcc70a4 (patch) | |
tree | b32b74ad0e0007f1b35f7f264385d6a0094c202e | |
parent | 42a1901d3b318d276b625555831970a7813c39bc (diff) | |
download | Paper-fcb6c72bc95ff62b9cd78dec457f485dafcc70a4.tar.gz Paper-fcb6c72bc95ff62b9cd78dec457f485dafcc70a4.zip |
Correctly pass velocity native compressor (#11509)
-rw-r--r-- | patches/server/0980-Use-Velocity-compression-and-cipher-natives.patch | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/patches/server/0980-Use-Velocity-compression-and-cipher-natives.patch b/patches/server/0980-Use-Velocity-compression-and-cipher-natives.patch index a57ddf2e84..d8e15233f3 100644 --- a/patches/server/0980-Use-Velocity-compression-and-cipher-natives.patch +++ b/patches/server/0980-Use-Velocity-compression-and-cipher-natives.patch @@ -3,6 +3,8 @@ From: Andrew Steinborn <[email protected]> Date: Mon, 26 Jul 2021 02:15:17 -0400 Subject: [PATCH] Use Velocity compression and cipher natives +== AT == +private-f net.minecraft.network.CompressionDecoder inflater diff --git a/build.gradle.kts b/build.gradle.kts index 25001d6cf4f70bd01ab304625b49ec45f5b1f525..9966576652ed6007d2228237f292c1dc83ede485 100644 @@ -102,18 +104,19 @@ index 0f3d502a9680006bcdcd7d272240a2e5c3b46790..ffa1c48585fbbc1d30826d435043527f + // Paper end - Use Velocity cipher } diff --git a/src/main/java/net/minecraft/network/CompressionDecoder.java b/src/main/java/net/minecraft/network/CompressionDecoder.java -index 5927c928b27f64bd3973e95d5867b59f67476d41..ba3619b03ea73e4ea55ae2eb79d3b6cd1f48a191 100644 +index a57e8516b3fafd7060dc1b30550164e74e17fc84..3a853d7401a8275b1a3d525bbda8095de12d0038 100644 --- a/src/main/java/net/minecraft/network/CompressionDecoder.java +++ b/src/main/java/net/minecraft/network/CompressionDecoder.java -@@ -13,13 +13,20 @@ public class CompressionDecoder extends ByteToMessageDecoder { +@@ -13,13 +13,21 @@ public class CompressionDecoder extends ByteToMessageDecoder { public static final int MAXIMUM_COMPRESSED_LENGTH = 2097152; public static final int MAXIMUM_UNCOMPRESSED_LENGTH = 8388608; - private final Inflater inflater; + private Inflater inflater; + private com.velocitypowered.natives.compression.VelocityCompressor compressor; // Paper - Use Velocity cipher private int threshold; private boolean validateDecompressed; + // Paper start - Use Velocity cipher ++ @io.papermc.paper.annotation.DoNotUse public CompressionDecoder(int compressionThreshold, boolean rejectsBadPackets) { + this(null, compressionThreshold, rejectsBadPackets); + } @@ -127,7 +130,7 @@ index 5927c928b27f64bd3973e95d5867b59f67476d41..ba3619b03ea73e4ea55ae2eb79d3b6cd } protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List<Object> list) throws Exception { -@@ -38,14 +45,42 @@ public class CompressionDecoder extends ByteToMessageDecoder { +@@ -38,14 +46,42 @@ public class CompressionDecoder extends ByteToMessageDecoder { } } @@ -170,12 +173,18 @@ index 5927c928b27f64bd3973e95d5867b59f67476d41..ba3619b03ea73e4ea55ae2eb79d3b6cd private void setupInflaterInput(ByteBuf buf) { ByteBuffer byteBuffer; if (buf.nioBufferCount() > 0) { -@@ -82,7 +117,7 @@ public class CompressionDecoder extends ByteToMessageDecoder { +@@ -82,7 +118,13 @@ public class CompressionDecoder extends ByteToMessageDecoder { } } - public void setThreshold(int compressionThreshold, boolean rejectsBadPackets) { -+ public void setThreshold(com.velocitypowered.natives.compression.VelocityCompressor compressor, int compressionThreshold, boolean rejectsBadPackets) { // Paper - Use Velocity cipher ++ // Paper start - Use Velocity cipher ++ public void setThreshold(com.velocitypowered.natives.compression.VelocityCompressor compressor, int compressionThreshold, boolean rejectsBadPackets) { ++ if (this.compressor == null && compressor != null) { // Only re-configure once. Re-reconfiguring would require closing the native compressor. ++ this.compressor = compressor; ++ this.inflater = null; ++ } ++ // Paper end - Use Velocity cipher this.threshold = compressionThreshold; this.validateDecompressed = rejectsBadPackets; } @@ -275,7 +284,7 @@ index 34a80d2f34555663ab1b394972957089214cb337..ec30c291188ac3bba7f1c3bc397576d1 return this.threshold; } diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index 7dc7aeb1d94d26cf54bd4e4ab13972a3a60c1f98..90a2c61c42cba7e38f167eccdd7a951a947963c4 100644 +index 7dc7aeb1d94d26cf54bd4e4ab13972a3a60c1f98..36624d3dc7e3f2a64f88b01c5e906018fcee0015 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java @@ -792,11 +792,28 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -311,7 +320,7 @@ index 7dc7aeb1d94d26cf54bd4e4ab13972a3a60c1f98..90a2c61c42cba7e38f167eccdd7a951a public boolean isEncrypted() { return this.encrypted; -@@ -829,12 +846,13 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { +@@ -829,14 +846,15 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { public void setupCompression(int compressionThreshold, boolean rejectsBadPackets) { if (compressionThreshold >= 0) { @@ -324,8 +333,11 @@ index 7dc7aeb1d94d26cf54bd4e4ab13972a3a60c1f98..90a2c61c42cba7e38f167eccdd7a951a - packetdecompressor.setThreshold(compressionThreshold, rejectsBadPackets); + packetdecompressor.setThreshold(compressor, compressionThreshold, rejectsBadPackets); // Paper - Use Velocity cipher } else { - this.channel.pipeline().addAfter("splitter", "decompress", new CompressionDecoder(compressionThreshold, rejectsBadPackets)); +- this.channel.pipeline().addAfter("splitter", "decompress", new CompressionDecoder(compressionThreshold, rejectsBadPackets)); ++ this.channel.pipeline().addAfter("splitter", "decompress", new CompressionDecoder(compressor, compressionThreshold, rejectsBadPackets)); // Paper - Use Velocity cipher } + + channelhandler = this.channel.pipeline().get("compress"); @@ -845,7 +863,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { packetcompressor.setThreshold(compressionThreshold); |