mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-21 18:15:54 +01:00
Correctly pass velocity native compressor (#11509)
This commit is contained in:
parent
42a1901d3b
commit
fcb6c72bc9
@ -3,6 +3,8 @@ From: Andrew Steinborn <git@steinborn.me>
|
|||||||
Date: Mon, 26 Jul 2021 02:15:17 -0400
|
Date: Mon, 26 Jul 2021 02:15:17 -0400
|
||||||
Subject: [PATCH] Use Velocity compression and cipher natives
|
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
|
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||||
index 25001d6cf4f70bd01ab304625b49ec45f5b1f525..9966576652ed6007d2228237f292c1dc83ede485 100644
|
index 25001d6cf4f70bd01ab304625b49ec45f5b1f525..9966576652ed6007d2228237f292c1dc83ede485 100644
|
||||||
@ -102,18 +104,19 @@ index 0f3d502a9680006bcdcd7d272240a2e5c3b46790..ffa1c48585fbbc1d30826d435043527f
|
|||||||
+ // Paper end - Use Velocity cipher
|
+ // 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
|
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
|
--- a/src/main/java/net/minecraft/network/CompressionDecoder.java
|
||||||
+++ b/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_COMPRESSED_LENGTH = 2097152;
|
||||||
public static final int MAXIMUM_UNCOMPRESSED_LENGTH = 8388608;
|
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 com.velocitypowered.natives.compression.VelocityCompressor compressor; // Paper - Use Velocity cipher
|
||||||
private int threshold;
|
private int threshold;
|
||||||
private boolean validateDecompressed;
|
private boolean validateDecompressed;
|
||||||
|
|
||||||
+ // Paper start - Use Velocity cipher
|
+ // Paper start - Use Velocity cipher
|
||||||
|
+ @io.papermc.paper.annotation.DoNotUse
|
||||||
public CompressionDecoder(int compressionThreshold, boolean rejectsBadPackets) {
|
public CompressionDecoder(int compressionThreshold, boolean rejectsBadPackets) {
|
||||||
+ this(null, compressionThreshold, rejectsBadPackets);
|
+ this(null, compressionThreshold, rejectsBadPackets);
|
||||||
+ }
|
+ }
|
||||||
@ -127,7 +130,7 @@ index 5927c928b27f64bd3973e95d5867b59f67476d41..ba3619b03ea73e4ea55ae2eb79d3b6cd
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List<Object> list) throws Exception {
|
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) {
|
private void setupInflaterInput(ByteBuf buf) {
|
||||||
ByteBuffer byteBuffer;
|
ByteBuffer byteBuffer;
|
||||||
if (buf.nioBufferCount() > 0) {
|
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(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.threshold = compressionThreshold;
|
||||||
this.validateDecompressed = rejectsBadPackets;
|
this.validateDecompressed = rejectsBadPackets;
|
||||||
}
|
}
|
||||||
@ -275,7 +284,7 @@ index 34a80d2f34555663ab1b394972957089214cb337..ec30c291188ac3bba7f1c3bc397576d1
|
|||||||
return this.threshold;
|
return this.threshold;
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
|
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
|
--- a/src/main/java/net/minecraft/network/Connection.java
|
||||||
+++ b/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<?>> {
|
@@ -792,11 +792,28 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
||||||
@ -311,7 +320,7 @@ index 7dc7aeb1d94d26cf54bd4e4ab13972a3a60c1f98..90a2c61c42cba7e38f167eccdd7a951a
|
|||||||
|
|
||||||
public boolean isEncrypted() {
|
public boolean isEncrypted() {
|
||||||
return this.encrypted;
|
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) {
|
public void setupCompression(int compressionThreshold, boolean rejectsBadPackets) {
|
||||||
if (compressionThreshold >= 0) {
|
if (compressionThreshold >= 0) {
|
||||||
@ -324,8 +333,11 @@ index 7dc7aeb1d94d26cf54bd4e4ab13972a3a60c1f98..90a2c61c42cba7e38f167eccdd7a951a
|
|||||||
- packetdecompressor.setThreshold(compressionThreshold, rejectsBadPackets);
|
- packetdecompressor.setThreshold(compressionThreshold, rejectsBadPackets);
|
||||||
+ packetdecompressor.setThreshold(compressor, compressionThreshold, rejectsBadPackets); // Paper - Use Velocity cipher
|
+ packetdecompressor.setThreshold(compressor, compressionThreshold, rejectsBadPackets); // Paper - Use Velocity cipher
|
||||||
} else {
|
} 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<?>> {
|
@@ -845,7 +863,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
||||||
|
|
||||||
packetcompressor.setThreshold(compressionThreshold);
|
packetcompressor.setThreshold(compressionThreshold);
|
||||||
|
Loading…
Reference in New Issue
Block a user