13
0
geforkt von Mirrors/Paper

Fixed large packet handling (#9147)

Co-authored-by: Shane Freeder <theboyetronic@gmail.com>
Dieser Commit ist enthalten in:
Lukas Alt 2023-04-27 20:50:14 +02:00
Ursprung 3ef136dfd7
Commit f5bae877ea

Datei anzeigen

@ -15,8 +15,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public void exceptionCaught(ChannelHandlerContext channelhandlercontext, Throwable throwable) {
+ // Paper start
+ if (throwable instanceof io.netty.handler.codec.EncoderException && throwable.getCause() instanceof PacketEncoder.PacketTooLargeException) {
+ if (((PacketEncoder.PacketTooLargeException) throwable.getCause()).getPacket().packetTooLarge(this)) {
+ if (throwable instanceof io.netty.handler.codec.EncoderException && throwable.getCause() instanceof PacketEncoder.PacketTooLargeException packetTooLargeException) {
+ if (packetTooLargeException.getPacket().packetTooLarge(this)) {
+ return;
+ } else if (packetTooLargeException.getPacket().isSkippable()) {
+ Connection.LOGGER.debug("Skipping packet due to errors", throwable.getCause());
+ return;
+ } else {
+ throwable = throwable.getCause();
@ -30,6 +33,15 @@ diff --git a/src/main/java/net/minecraft/network/PacketEncoder.java b/src/main/j
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/network/PacketEncoder.java
+++ b/src/main/java/net/minecraft/network/PacketEncoder.java
@@ -0,0 +0,0 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
int j = friendlyByteBuf.writerIndex();
packet.write(friendlyByteBuf);
int k = friendlyByteBuf.writerIndex() - j;
- if (k > 8388608) {
+ if (false && k > 8388608) { // Paper - disable
throw new IllegalArgumentException("Packet too big (is " + k + ", should be less than 8388608): " + packet);
} else {
int l = channelHandlerContext.channel().attr(Connection.ATTRIBUTE_PROTOCOL).get().getId();
@@ -0,0 +0,0 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
throw var10;
}
@ -46,7 +58,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
+
+ // Paper start
+ private static int MAX_PACKET_SIZE = 2097152;
+ private static int MAX_PACKET_SIZE = 8388608;
+
+ public static class PacketTooLargeException extends RuntimeException {
+ private final Packet<?> packet;