From 22ac7d68179511e2b7d418eb988353bf71d35db8 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Mon, 25 Jul 2022 16:13:09 +0200 Subject: [PATCH] Add internal netty pipeline events --- ...Add-Channel-initialization-listeners.patch | 36 +++++++++++++++++++ .../0650-Add-Unix-domain-socket-support.patch | 4 +-- ...ocity-compression-and-cipher-natives.patch | 4 +-- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/patches/server/0632-Add-Channel-initialization-listeners.patch b/patches/server/0632-Add-Channel-initialization-listeners.patch index 57ff48345..bbef1c092 100644 --- a/patches/server/0632-Add-Channel-initialization-listeners.patch +++ b/patches/server/0632-Add-Channel-initialization-listeners.patch @@ -105,6 +105,42 @@ index 0000000000000000000000000000000000000000..30e62719e0a83525daa33cf41cb61df3 + } + } +} +diff --git a/src/main/java/io/papermc/paper/network/ConnectionEvent.java b/src/main/java/io/papermc/paper/network/ConnectionEvent.java +new file mode 100644 +index 0000000000000000000000000000000000000000..0d7e7db9e37ef0183c32b217bd944fb4f41ab83a +--- /dev/null ++++ b/src/main/java/io/papermc/paper/network/ConnectionEvent.java +@@ -0,0 +1,10 @@ ++package io.papermc.paper.network; ++ ++/** ++ * Internal connection pipeline events. ++ */ ++public enum ConnectionEvent { ++ ++ COMPRESSION_THRESHOLD_SET, ++ COMPRESSION_DISABLED ++} +diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java +index 91556b52edaa1d5c4dc73a825c77b9a66b002c61..91cf0a6b5061bf4731731fdd69beb80fb30c6b51 100644 +--- a/src/main/java/net/minecraft/network/Connection.java ++++ b/src/main/java/net/minecraft/network/Connection.java +@@ -555,6 +555,7 @@ public class Connection extends SimpleChannelInboundHandler> { + } else { + this.channel.pipeline().addBefore("encoder", "compress", new CompressionEncoder(compressionThreshold)); + } ++ this.channel.pipeline().fireUserEventTriggered(io.papermc.paper.network.ConnectionEvent.COMPRESSION_THRESHOLD_SET); // Paper + } else { + if (this.channel.pipeline().get("decompress") instanceof CompressionDecoder) { + this.channel.pipeline().remove("decompress"); +@@ -563,6 +564,7 @@ public class Connection extends SimpleChannelInboundHandler> { + if (this.channel.pipeline().get("compress") instanceof CompressionEncoder) { + this.channel.pipeline().remove("compress"); + } ++ this.channel.pipeline().fireUserEventTriggered(io.papermc.paper.network.ConnectionEvent.COMPRESSION_DISABLED); // Paper + } + + } diff --git a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java index 72fbc58f7d003b7af3c35e5fc504010307c7086b..076c1d5fb69a4a30b3e412e85b17db09fd9a1def 100644 --- a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java diff --git a/patches/server/0650-Add-Unix-domain-socket-support.patch b/patches/server/0650-Add-Unix-domain-socket-support.patch index 69e33b5fc..cd56cfe1a 100644 --- a/patches/server/0650-Add-Unix-domain-socket-support.patch +++ b/patches/server/0650-Add-Unix-domain-socket-support.patch @@ -11,10 +11,10 @@ Tested-by: Mariell Hoversholm Reviewed-by: Mariell Hoversholm diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index 91556b52edaa1d5c4dc73a825c77b9a66b002c61..00abdd5bba02b7cdf8dbdc423594f0fde890dd84 100644 +index 91cf0a6b5061bf4731731fdd69beb80fb30c6b51..45598a94524519257c5ffb03800f0b081f4d7a78 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java -@@ -627,6 +627,11 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -629,6 +629,11 @@ public class Connection extends SimpleChannelInboundHandler> { // Spigot Start public SocketAddress getRawAddress() { diff --git a/patches/server/0763-Use-Velocity-compression-and-cipher-natives.patch b/patches/server/0763-Use-Velocity-compression-and-cipher-natives.patch index a8bd119ae..64a5cad49 100644 --- a/patches/server/0763-Use-Velocity-compression-and-cipher-natives.patch +++ b/patches/server/0763-Use-Velocity-compression-and-cipher-natives.patch @@ -268,7 +268,7 @@ index 792883afe53d2b7989c25a81c2f9a639d5e21d20..c04379ca8a4db0f4de46ad2b3b338431 return this.threshold; } diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index 7e2256ac88e874b34b6a0c638bfced368ba29be2..9549e8ed4b245176b340ab2f22f4bdefdbe28a9e 100644 +index e0a29625d17d315b2f614c65a0a82c6d1a82676d..f018d07cbea3785876a547da158cf60eb831a5fb 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java @@ -641,11 +641,28 @@ public class Connection extends SimpleChannelInboundHandler> { @@ -322,8 +322,8 @@ index 7e2256ac88e874b34b6a0c638bfced368ba29be2..9549e8ed4b245176b340ab2f22f4bdef - this.channel.pipeline().addBefore("encoder", "compress", new CompressionEncoder(compressionThreshold)); + this.channel.pipeline().addBefore("encoder", "compress", new CompressionEncoder(compressor, compressionThreshold)); // Paper } + this.channel.pipeline().fireUserEventTriggered(io.papermc.paper.network.ConnectionEvent.COMPRESSION_THRESHOLD_SET); // Paper } else { - if (this.channel.pipeline().get("decompress") instanceof CompressionDecoder) { diff --git a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java index 9e7154c9df96d5a0577886d43a98a73626a8f189..af3e70920221b6bd127bb3aed7f1e0a7e9e4c322 100644 --- a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java