diff --git a/Waterfall-Proxy-Patches/0010-Close-connections-Don-t-flush-if-not-necessary.patch b/Waterfall-Proxy-Patches/0008-Close-connections-Don-t-flush-if-not-necessary.patch similarity index 76% rename from Waterfall-Proxy-Patches/0010-Close-connections-Don-t-flush-if-not-necessary.patch rename to Waterfall-Proxy-Patches/0008-Close-connections-Don-t-flush-if-not-necessary.patch index d8c35ab..fb6e394 100644 --- a/Waterfall-Proxy-Patches/0010-Close-connections-Don-t-flush-if-not-necessary.patch +++ b/Waterfall-Proxy-Patches/0008-Close-connections-Don-t-flush-if-not-necessary.patch @@ -1,14 +1,14 @@ -From cdf91cda29d5b69410c130012de20dba5d7da506 Mon Sep 17 00:00:00 2001 +From f1b1c7e6c185bc7a13cf6125dc2672b9a53e12e1 Mon Sep 17 00:00:00 2001 From: foss-mc <69294560+foss-mc@users.noreply.github.com> Date: Wed, 16 Dec 2020 18:06:17 +0800 Subject: [PATCH] Close connections & Don't flush if not necessary diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java -index 5407c20a..e9937428 100644 +index 49ba34db..6e148782 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java -@@ -194,6 +194,13 @@ public class InitialHandler extends PacketHandler implements PendingConnection +@@ -192,6 +192,13 @@ public class InitialHandler extends PacketHandler implements PendingConnection } ServerPing legacy = result.getResponse(); @@ -22,11 +22,10 @@ index 5407c20a..e9937428 100644 String kickMessage; if ( v1_5 ) -@@ -264,6 +271,16 @@ public class InitialHandler extends PacketHandler implements PendingConnection - { - bungee.getConnectionThrottle().unthrottle( getSocketAddress() ); - } -+ +@@ -257,6 +264,15 @@ public class InitialHandler extends PacketHandler implements PendingConnection + @Override + public void done(ProxyPingEvent pingResult, Throwable error) + { + // FlameCord - Close if response is null + // FlameCord - Return if connection is closed + if (pingResult.getResponse() == null) { @@ -36,10 +35,10 @@ index 5407c20a..e9937428 100644 + return; + } + - // FlameCord start - if ( ProtocolConstants.isBeforeOrEq( handshake.getProtocolVersion() , ProtocolConstants.MINECRAFT_1_8 ) ) - { -@@ -304,11 +321,11 @@ public class InitialHandler extends PacketHandler implements PendingConnection + Gson gson = BungeeCord.getInstance().gson; + unsafe.sendPacket( new StatusResponse( gson.toJson( pingResult.getResponse() ) ) ); + if ( bungee.getConnectionThrottle() != null ) +@@ -286,11 +302,13 @@ public class InitialHandler extends PacketHandler implements PendingConnection @Override public void handle(PingPacket ping) throws Exception { @@ -47,15 +46,17 @@ index 5407c20a..e9937428 100644 - Preconditions.checkState(thisState == State.PING, "Not expecting PING"); - } + // FlameCord - Never accept invalid packets -+ Preconditions.checkState(thisState == State.PING, "Not expecting PING"); ++ Preconditions.checkState( thisState == State.PING, "Not expecting PING" ); ++ unsafe.sendPacket( ping ); - disconnect( "" ); ++ + // FlameCord - Close instead of disconnect + ch.close(); } @Override -@@ -624,7 +641,8 @@ public class InitialHandler extends PacketHandler implements PendingConnection +@@ -606,7 +624,8 @@ public class InitialHandler extends PacketHandler implements PendingConnection { if ( canSendKickMessage() ) { @@ -117,34 +118,8 @@ index 6dc5633f..5c05f2b9 100644 ch.pipeline().addBefore( baseName, name, handler ); } -diff --git a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java -index 270545f2..b0825e51 100644 ---- a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java -+++ b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java -@@ -56,7 +56,8 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter - { - if ( handler != null ) - { -- channel.markClosed(); -+ // FlameCord - close instead of markClosed -+ channel.close(); - handler.disconnected( channel ); - - if ( !( handler instanceof InitialHandler || handler instanceof PingHandler ) ) -@@ -186,8 +187,9 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter - ProxyServer.getInstance().getLogger().log( Level.SEVERE, handler + " - exception processing exception", ex ); - } - } -- -- ctx.close(); - } -+ -+ // FlameCord - Close even if the channel isn't active -+ ctx.close(); - } - } diff --git a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java -index 96704d5e..4996a7b4 100644 +index 96704d5e..654203ab 100644 --- a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java +++ b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java @@ -5,6 +5,7 @@ import io.github.waterfallmc.waterfall.event.ConnectionInitEvent; @@ -170,6 +145,20 @@ index 96704d5e..4996a7b4 100644 }; public static final Base BASE = new Base(); private static final KickStringWriter legacyKicker = new KickStringWriter(); +@@ -196,5 +205,13 @@ public class PipelineUtils + + ch.pipeline().addLast( BOSS_HANDLER, new HandlerBoss() ); + } ++ ++ // FlameCord - Close on exception caught ++ @Override ++ public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) throws Exception { ++ cause.printStackTrace(); ++ ++ ctx.close(); ++ } + } + } diff --git a/query/src/main/java/net/md_5/bungee/query/QueryHandler.java b/query/src/main/java/net/md_5/bungee/query/QueryHandler.java index 0c1ecfb8..b3bdfd05 100644 --- a/query/src/main/java/net/md_5/bungee/query/QueryHandler.java @@ -184,5 +173,5 @@ index 0c1ecfb8..b3bdfd05 100644 } -- -2.31.1 +2.31.1.windows.1 diff --git a/Waterfall-Proxy-Patches/0012-Packet-Checks.patch b/Waterfall-Proxy-Patches/0009-Packet-Checks.patch similarity index 90% rename from Waterfall-Proxy-Patches/0012-Packet-Checks.patch rename to Waterfall-Proxy-Patches/0009-Packet-Checks.patch index 8f1ae03..1fa6617 100644 --- a/Waterfall-Proxy-Patches/0012-Packet-Checks.patch +++ b/Waterfall-Proxy-Patches/0009-Packet-Checks.patch @@ -1,11 +1,11 @@ -From 8ead27c615cb3fcc53cabf3399c65347d4fd6994 Mon Sep 17 00:00:00 2001 +From f61307367e3fb2e33ef946df1b28973645f3eba8 Mon Sep 17 00:00:00 2001 From: foss-mc <69294560+foss-mc@users.noreply.github.com> Date: Wed, 16 Dec 2020 18:10:30 +0800 Subject: [PATCH] Packet Checks diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java -index 2caadfed..d4729244 100644 +index 01d35f41..ec07ae6f 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java @@ -38,6 +38,19 @@ public class MinecraftDecoder extends MessageToMessageDecoder @@ -29,10 +29,10 @@ index 2caadfed..d4729244 100644 Object packetTypeInfo = null; diff --git a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java -index 1351d5d5..d68cc2ce 100644 +index 270545f2..3bbc1510 100644 --- a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java +++ b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java -@@ -79,6 +79,11 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter +@@ -78,6 +78,11 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { @@ -45,5 +45,5 @@ index 1351d5d5..d68cc2ce 100644 { HAProxyMessage proxy = (HAProxyMessage) msg; -- -2.20.1 +2.31.1.windows.1 diff --git a/Waterfall-Proxy-Patches/0014-Default-timeout-to-10000.patch b/Waterfall-Proxy-Patches/0010-Default-timeout-to-10000.patch similarity index 86% rename from Waterfall-Proxy-Patches/0014-Default-timeout-to-10000.patch rename to Waterfall-Proxy-Patches/0010-Default-timeout-to-10000.patch index 2c9182c..cc794ed 100644 --- a/Waterfall-Proxy-Patches/0014-Default-timeout-to-10000.patch +++ b/Waterfall-Proxy-Patches/0010-Default-timeout-to-10000.patch @@ -1,11 +1,11 @@ -From b8e427d68694e1af04e005b78f4c58e161c8ee35 Mon Sep 17 00:00:00 2001 +From 7ecd3743ff93e43b827419fd1705b75aa9cf2e8c Mon Sep 17 00:00:00 2001 From: foss-mc <69294560+foss-mc@users.noreply.github.com> Date: Wed, 16 Dec 2020 18:14:02 +0800 Subject: [PATCH] Default timeout to 10000 diff --git a/proxy/src/main/java/net/md_5/bungee/conf/Configuration.java b/proxy/src/main/java/net/md_5/bungee/conf/Configuration.java -index 85d2197a..1294495d 100644 +index 85d2197a..c41930ae 100644 --- a/proxy/src/main/java/net/md_5/bungee/conf/Configuration.java +++ b/proxy/src/main/java/net/md_5/bungee/conf/Configuration.java @@ -35,7 +35,8 @@ public abstract class Configuration implements ProxyConfig @@ -19,5 +19,5 @@ index 85d2197a..1294495d 100644 * UUID used for metrics. */ -- -2.20.1 +2.31.1.windows.1 diff --git a/Waterfall-Proxy-Patches/0016-Change-state-to-encrypt-only-if-onlineMode-is-true.patch b/Waterfall-Proxy-Patches/0011-Change-state-to-encrypt-only-if-onlineMode-is-true.patch similarity index 84% rename from Waterfall-Proxy-Patches/0016-Change-state-to-encrypt-only-if-onlineMode-is-true.patch rename to Waterfall-Proxy-Patches/0011-Change-state-to-encrypt-only-if-onlineMode-is-true.patch index 0182585..c921f25 100644 --- a/Waterfall-Proxy-Patches/0016-Change-state-to-encrypt-only-if-onlineMode-is-true.patch +++ b/Waterfall-Proxy-Patches/0011-Change-state-to-encrypt-only-if-onlineMode-is-true.patch @@ -1,14 +1,14 @@ -From 501c340474b980137994535738a1ac736b6d0e6a Mon Sep 17 00:00:00 2001 +From 19fd8591a6237ca960a1533236c4fd352a621a9d Mon Sep 17 00:00:00 2001 From: foss-mc <69294560+foss-mc@users.noreply.github.com> Date: Wed, 16 Dec 2020 18:25:03 +0800 Subject: [PATCH] Change state to encrypt only if onlineMode is true diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java -index e9937428..037a305b 100644 +index 6e148782..e23cf604 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java -@@ -449,11 +449,12 @@ public class InitialHandler extends PacketHandler implements PendingConnection +@@ -432,11 +432,12 @@ public class InitialHandler extends PacketHandler implements PendingConnection if ( onlineMode ) { unsafe().sendPacket( request = EncryptionUtil.encryptRequest() ); @@ -23,5 +23,5 @@ index e9937428..037a305b 100644 }; -- -2.20.1 +2.31.1.windows.1 diff --git a/Waterfall-Proxy-Patches/0011-Use-elseIfs.patch b/Waterfall-Proxy-Patches/0011-Use-elseIfs.patch deleted file mode 100644 index 0a2757a..0000000 --- a/Waterfall-Proxy-Patches/0011-Use-elseIfs.patch +++ /dev/null @@ -1,157 +0,0 @@ -From 8483549f243a6d8aad3574fc2d6235c3326e2740 Mon Sep 17 00:00:00 2001 -From: foss-mc <69294560+foss-mc@users.noreply.github.com> -Date: Wed, 16 Dec 2020 18:07:26 +0800 -Subject: [PATCH] Use elseIfs - - -diff --git a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java -index d54d8539..0dd2884d 100644 ---- a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java -+++ b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java -@@ -285,6 +285,7 @@ public class DownstreamBridge extends PacketHandler - throw CancelSendSignal.INSTANCE; - } - -+ // FlameCord - Use elseIfs - if ( pluginMessage.getTag().equals( con.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand" ) ) - { - // FlameCord start -@@ -313,8 +314,7 @@ public class DownstreamBridge extends PacketHandler - con.unsafe().sendPacket( pluginMessage ); - throw CancelSendSignal.INSTANCE; - } -- -- if ( pluginMessage.getTag().equals( "BungeeCord" ) ) -+ else if ( pluginMessage.getTag().equals( "BungeeCord" ) ) - { - DataInput in = pluginMessage.getStream(); - ByteArrayDataOutput out = ByteStreams.newDataOutput(); -@@ -343,7 +343,7 @@ public class DownstreamBridge extends PacketHandler - // Null out stream, important as we don't want to send to ourselves - out = null; - } -- if ( subChannel.equals( "Forward" ) ) -+ else if ( subChannel.equals( "Forward" ) ) - { - // Read data from server - String target = in.readUTF(); -@@ -388,7 +388,7 @@ public class DownstreamBridge extends PacketHandler - } - } - } -- if ( subChannel.equals( "Connect" ) ) -+ else if ( subChannel.equals( "Connect" ) ) - { - ServerInfo server = bungee.getServerInfo( in.readUTF() ); - if ( server != null ) -@@ -396,7 +396,7 @@ public class DownstreamBridge extends PacketHandler - con.connect( server, ServerConnectEvent.Reason.PLUGIN_MESSAGE ); - } - } -- if ( subChannel.equals( "ConnectOther" ) ) -+ else if ( subChannel.equals( "ConnectOther" ) ) - { - ProxiedPlayer player = bungee.getPlayer( in.readUTF() ); - if ( player != null ) -@@ -408,7 +408,7 @@ public class DownstreamBridge extends PacketHandler - } - } - } -- if ( subChannel.equals( "IP" ) ) -+ else if ( subChannel.equals( "IP" ) ) - { - out.writeUTF( "IP" ); - if ( con.getSocketAddress() instanceof InetSocketAddress ) -@@ -421,7 +421,7 @@ public class DownstreamBridge extends PacketHandler - out.writeInt( 0 ); - } - } -- if ( subChannel.equals( "IPOther" ) ) -+ else if ( subChannel.equals( "IPOther" ) ) - { - ProxiedPlayer player = bungee.getPlayer( in.readUTF() ); - if ( player != null ) -@@ -440,7 +440,7 @@ public class DownstreamBridge extends PacketHandler - } - } - } -- if ( subChannel.equals( "PlayerCount" ) ) -+ else if ( subChannel.equals( "PlayerCount" ) ) - { - String target = in.readUTF(); - out.writeUTF( "PlayerCount" ); -@@ -458,7 +458,7 @@ public class DownstreamBridge extends PacketHandler - } - } - } -- if ( subChannel.equals( "PlayerList" ) ) -+ else if ( subChannel.equals( "PlayerList" ) ) - { - String target = in.readUTF(); - out.writeUTF( "PlayerList" ); -@@ -476,12 +476,12 @@ public class DownstreamBridge extends PacketHandler - } - } - } -- if ( subChannel.equals( "GetServers" ) ) -+ else if ( subChannel.equals( "GetServers" ) ) - { - out.writeUTF( "GetServers" ); - out.writeUTF( Util.csv( bungee.getServers().keySet() ) ); - } -- if ( subChannel.equals( "Message" ) ) -+ else if ( subChannel.equals( "Message" ) ) - { - String target = in.readUTF(); - String message = in.readUTF(); -@@ -500,7 +500,7 @@ public class DownstreamBridge extends PacketHandler - } - } - } -- if ( subChannel.equals( "MessageRaw" ) ) -+ else if ( subChannel.equals( "MessageRaw" ) ) - { - String target = in.readUTF(); - BaseComponent[] message = ComponentSerializer.parse( in.readUTF() ); -@@ -519,17 +519,17 @@ public class DownstreamBridge extends PacketHandler - } - } - } -- if ( subChannel.equals( "GetServer" ) ) -+ else if ( subChannel.equals( "GetServer" ) ) - { - out.writeUTF( "GetServer" ); - out.writeUTF( server.getInfo().getName() ); - } -- if ( subChannel.equals( "UUID" ) ) -+ else if ( subChannel.equals( "UUID" ) ) - { - out.writeUTF( "UUID" ); - out.writeUTF( con.getUUID() ); - } -- if ( subChannel.equals( "UUIDOther" ) ) -+ else if ( subChannel.equals( "UUIDOther" ) ) - { - ProxiedPlayer player = bungee.getPlayer( in.readUTF() ); - if ( player != null ) -@@ -539,7 +539,7 @@ public class DownstreamBridge extends PacketHandler - out.writeUTF( player.getUUID() ); - } - } -- if ( subChannel.equals( "ServerIP" ) ) -+ else if ( subChannel.equals( "ServerIP" ) ) - { - ServerInfo info = bungee.getServerInfo( in.readUTF() ); - if ( info != null && !info.getAddress().isUnresolved() ) -@@ -550,7 +550,7 @@ public class DownstreamBridge extends PacketHandler - out.writeShort( info.getAddress().getPort() ); - } - } -- if ( subChannel.equals( "KickPlayer" ) ) -+ else if ( subChannel.equals( "KickPlayer" ) ) - { - ProxiedPlayer player = bungee.getPlayer( in.readUTF() ); - if ( player != null ) --- -2.20.1 - diff --git a/Waterfall-Proxy-Patches/0017-Don-t-allow-name-containing-dot.patch b/Waterfall-Proxy-Patches/0012-Don-t-allow-name-containing-dot.patch similarity index 85% rename from Waterfall-Proxy-Patches/0017-Don-t-allow-name-containing-dot.patch rename to Waterfall-Proxy-Patches/0012-Don-t-allow-name-containing-dot.patch index f6eb912..2415968 100644 --- a/Waterfall-Proxy-Patches/0017-Don-t-allow-name-containing-dot.patch +++ b/Waterfall-Proxy-Patches/0012-Don-t-allow-name-containing-dot.patch @@ -1,14 +1,14 @@ -From 355853706ca50aba3dc231b6adee5f5e8bd58548 Mon Sep 17 00:00:00 2001 +From e6b04ac9bcc7a544cf3291b159c9498f94cc9029 Mon Sep 17 00:00:00 2001 From: foss-mc <69294560+foss-mc@users.noreply.github.com> Date: Wed, 16 Dec 2020 18:25:51 +0800 Subject: [PATCH] Don't allow name containing dot diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java -index 037a305b..c6dfa00f 100644 +index e23cf604..b4067b1e 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java -@@ -404,13 +404,16 @@ public class InitialHandler extends PacketHandler implements PendingConnection +@@ -387,13 +387,16 @@ public class InitialHandler extends PacketHandler implements PendingConnection Preconditions.checkState( thisState == State.USERNAME, "Not expecting USERNAME" ); this.loginRequest = loginRequest; @@ -28,5 +28,5 @@ index 037a305b..c6dfa00f 100644 disconnect( bungee.getTranslation( "name_too_long" ) ); return; -- -2.20.1 +2.31.1.windows.1 diff --git a/Waterfall-Proxy-Patches/0018-Use-pipeline-to-reduce-redundancy.patch b/Waterfall-Proxy-Patches/0013-Use-pipeline-to-reduce-redundancy.patch similarity index 97% rename from Waterfall-Proxy-Patches/0018-Use-pipeline-to-reduce-redundancy.patch rename to Waterfall-Proxy-Patches/0013-Use-pipeline-to-reduce-redundancy.patch index c8cfdf2..625a300 100644 --- a/Waterfall-Proxy-Patches/0018-Use-pipeline-to-reduce-redundancy.patch +++ b/Waterfall-Proxy-Patches/0013-Use-pipeline-to-reduce-redundancy.patch @@ -1,4 +1,4 @@ -From 9c45d17f7e322b01c8a5a55d21b7cb1d65345056 Mon Sep 17 00:00:00 2001 +From 77d2ccf13e5f767020d6dac546bdbaf275afc8a3 Mon Sep 17 00:00:00 2001 From: foss-mc <69294560+foss-mc@users.noreply.github.com> Date: Wed, 16 Dec 2020 18:30:07 +0800 Subject: [PATCH] Use pipeline to reduce redundancy @@ -74,5 +74,5 @@ index 5c05f2b9..606866a5 100644 } } -- -2.20.1 +2.31.1.windows.1 diff --git a/Waterfall-Proxy-Patches/0019-Allow-custom-uuids-even-if-onlineMode-is-true.patch b/Waterfall-Proxy-Patches/0014-Allow-custom-uuids-even-if-onlineMode-is-true.patch similarity index 83% rename from Waterfall-Proxy-Patches/0019-Allow-custom-uuids-even-if-onlineMode-is-true.patch rename to Waterfall-Proxy-Patches/0014-Allow-custom-uuids-even-if-onlineMode-is-true.patch index 697736e..fb39b88 100644 --- a/Waterfall-Proxy-Patches/0019-Allow-custom-uuids-even-if-onlineMode-is-true.patch +++ b/Waterfall-Proxy-Patches/0014-Allow-custom-uuids-even-if-onlineMode-is-true.patch @@ -1,14 +1,14 @@ -From 461651e8a304ff9f57adac8d9c975b2a7e6ce1ea Mon Sep 17 00:00:00 2001 +From b5157be241a3611c3fefc0a4bc297325e83951de Mon Sep 17 00:00:00 2001 From: foss-mc <69294560+foss-mc@users.noreply.github.com> Date: Wed, 16 Dec 2020 18:35:33 +0800 Subject: [PATCH] Allow custom uuids even if onlineMode is true diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java -index c6dfa00f..3c67494f 100644 +index b4067b1e..3120abdb 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java -@@ -703,7 +703,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection +@@ -686,7 +686,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection public void setUniqueId(UUID uuid) { Preconditions.checkState( thisState == State.USERNAME, "Can only set uuid while state is username" ); @@ -18,5 +18,5 @@ index c6dfa00f..3c67494f 100644 } -- -2.20.1 +2.31.1.windows.1 diff --git a/Waterfall-Proxy-Patches/0020-Finish-early-to-avoid-multiple-incoming-packets.patch b/Waterfall-Proxy-Patches/0015-Finish-early-to-avoid-multiple-incoming-packets.patch similarity index 82% rename from Waterfall-Proxy-Patches/0020-Finish-early-to-avoid-multiple-incoming-packets.patch rename to Waterfall-Proxy-Patches/0015-Finish-early-to-avoid-multiple-incoming-packets.patch index 0cbf604..e28741b 100644 --- a/Waterfall-Proxy-Patches/0020-Finish-early-to-avoid-multiple-incoming-packets.patch +++ b/Waterfall-Proxy-Patches/0015-Finish-early-to-avoid-multiple-incoming-packets.patch @@ -1,14 +1,14 @@ -From e57213dfb0ed9e6ebb122cb95d08a2e7592c4c60 Mon Sep 17 00:00:00 2001 +From 53f0affe159b7b18210d1927bd4991dd27b3b1d3 Mon Sep 17 00:00:00 2001 From: foss-mc <69294560+foss-mc@users.noreply.github.com> Date: Wed, 16 Dec 2020 18:36:08 +0800 Subject: [PATCH] Finish early to avoid multiple incoming packets diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java -index 3c67494f..f7ed1f46 100644 +index 3120abdb..4a17a117 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java -@@ -470,6 +470,8 @@ public class InitialHandler extends PacketHandler implements PendingConnection +@@ -453,6 +453,8 @@ public class InitialHandler extends PacketHandler implements PendingConnection { Preconditions.checkState( thisState == State.ENCRYPT, "Not expecting ENCRYPT" ); @@ -17,7 +17,7 @@ index 3c67494f..f7ed1f46 100644 SecretKey sharedKey = EncryptionUtil.getSecret( encryptResponse, request ); // Waterfall start if (sharedKey instanceof SecretKeySpec) { -@@ -529,6 +531,9 @@ public class InitialHandler extends PacketHandler implements PendingConnection +@@ -512,6 +514,9 @@ public class InitialHandler extends PacketHandler implements PendingConnection private void finish() { @@ -27,7 +27,7 @@ index 3c67494f..f7ed1f46 100644 if ( isOnlineMode() ) { // Check for multiple connections -@@ -610,8 +615,6 @@ public class InitialHandler extends PacketHandler implements PendingConnection +@@ -593,8 +598,6 @@ public class InitialHandler extends PacketHandler implements PendingConnection } userCon.connect( server, null, true, ServerConnectEvent.Reason.JOIN_PROXY ); @@ -37,5 +37,5 @@ index 3c67494f..f7ed1f46 100644 } } ); -- -2.20.1 +2.31.1.windows.1 diff --git a/Waterfall-Proxy-Patches/0015-use-address-getHostString.patch b/Waterfall-Proxy-Patches/0015-use-address-getHostString.patch deleted file mode 100644 index ec2fe06..0000000 --- a/Waterfall-Proxy-Patches/0015-use-address-getHostString.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 7fc05a47e12839eb256a9141ab122886ca788522 Mon Sep 17 00:00:00 2001 -From: foss-mc <69294560+foss-mc@users.noreply.github.com> -Date: Wed, 16 Dec 2020 18:24:42 +0800 -Subject: [PATCH] use address & getHostString - - -diff --git a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java -index 0dd2884d..474551d3 100644 ---- a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java -+++ b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java -@@ -542,12 +542,15 @@ public class DownstreamBridge extends PacketHandler - else if ( subChannel.equals( "ServerIP" ) ) - { - ServerInfo info = bungee.getServerInfo( in.readUTF() ); -- if ( info != null && !info.getAddress().isUnresolved() ) -+ // FlameCord use address -+ InetSocketAddress address = info.getAddress(); -+ if ( info != null && !address.isUnresolved() ) - { - out.writeUTF( "ServerIP" ); - out.writeUTF( info.getName() ); -- out.writeUTF( info.getAddress().getAddress().getHostAddress() ); -- out.writeShort( info.getAddress().getPort() ); -+ // FlameCord - Use getHostString -+ out.writeUTF( address.getHostString() ); -+ out.writeShort( address.getPort() ); - } - } - else if ( subChannel.equals( "KickPlayer" ) ) --- -2.20.1 - diff --git a/Waterfall-Proxy-Patches/0021-Change-IllegalStateException-to-QuietException-and-e.patch b/Waterfall-Proxy-Patches/0016-Change-IllegalStateException-to-QuietException-and-e.patch similarity index 83% rename from Waterfall-Proxy-Patches/0021-Change-IllegalStateException-to-QuietException-and-e.patch rename to Waterfall-Proxy-Patches/0016-Change-IllegalStateException-to-QuietException-and-e.patch index dec9964..0de5057 100644 --- a/Waterfall-Proxy-Patches/0021-Change-IllegalStateException-to-QuietException-and-e.patch +++ b/Waterfall-Proxy-Patches/0016-Change-IllegalStateException-to-QuietException-and-e.patch @@ -1,4 +1,4 @@ -From d17df93a12dd7fc3bdda514ccfdd96041f8a9e88 Mon Sep 17 00:00:00 2001 +From 97c51221a89d054229919124c1f345d563406a46 Mon Sep 17 00:00:00 2001 From: foss-mc <69294560+foss-mc@users.noreply.github.com> Date: Wed, 16 Dec 2020 18:40:55 +0800 Subject: [PATCH] Change IllegalStateException to QuietException and explain @@ -6,10 +6,10 @@ Subject: [PATCH] Change IllegalStateException to QuietException and explain diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java -index fc1798fb..db3d9c86 100644 +index 01075a85..fb065ccd 100644 --- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java -@@ -310,7 +310,8 @@ public final class UserConnection implements ProxiedPlayer +@@ -309,7 +309,8 @@ public final class UserConnection implements ProxiedPlayer if ( getServer() == null && !ch.isClosing() ) { @@ -20,5 +20,5 @@ index fc1798fb..db3d9c86 100644 return; } -- -2.31.1 +2.31.1.windows.1 diff --git a/Waterfall-Proxy-Patches/0022-Don-t-declare-uuid-unless-it-s-null.patch b/Waterfall-Proxy-Patches/0017-Don-t-declare-uuid-unless-it-s-null.patch similarity index 84% rename from Waterfall-Proxy-Patches/0022-Don-t-declare-uuid-unless-it-s-null.patch rename to Waterfall-Proxy-Patches/0017-Don-t-declare-uuid-unless-it-s-null.patch index a732d6f..1ffac04 100644 --- a/Waterfall-Proxy-Patches/0022-Don-t-declare-uuid-unless-it-s-null.patch +++ b/Waterfall-Proxy-Patches/0017-Don-t-declare-uuid-unless-it-s-null.patch @@ -1,14 +1,14 @@ -From 1d113c7643f8d333cd70d8e6ddd64e78c1ab73be Mon Sep 17 00:00:00 2001 +From faa24f10ba4bb69ed99cdf3fafc42680b7dadd55 Mon Sep 17 00:00:00 2001 From: foss-mc <69294560+foss-mc@users.noreply.github.com> Date: Wed, 16 Dec 2020 18:43:17 +0800 Subject: [PATCH] Don't declare uuid unless it's null diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java -index f7ed1f46..e7542b1c 100644 +index 4a17a117..95a6f40c 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java -@@ -513,7 +513,10 @@ public class InitialHandler extends PacketHandler implements PendingConnection +@@ -496,7 +496,10 @@ public class InitialHandler extends PacketHandler implements PendingConnection { loginProfile = obj; name = obj.getName(); @@ -21,5 +21,5 @@ index f7ed1f46..e7542b1c 100644 return; } -- -2.20.1 +2.31.1.windows.1 diff --git a/Waterfall-Proxy-Patches/0023-FlameCord-General-Patch.patch b/Waterfall-Proxy-Patches/0018-FlameCord-General-Patch.patch similarity index 95% rename from Waterfall-Proxy-Patches/0023-FlameCord-General-Patch.patch rename to Waterfall-Proxy-Patches/0018-FlameCord-General-Patch.patch index fa5fa30..72cf074 100644 --- a/Waterfall-Proxy-Patches/0023-FlameCord-General-Patch.patch +++ b/Waterfall-Proxy-Patches/0018-FlameCord-General-Patch.patch @@ -1,4 +1,4 @@ -From 05af8ef64d93e186b1568e60596935c70b260259 Mon Sep 17 00:00:00 2001 +From ec1abfc008553e30879c286fcd39d87844eabdb8 Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata Date: Mon, 12 Oct 2020 15:40:53 -0300 Subject: [PATCH] FlameCord General Patch @@ -116,7 +116,7 @@ index 00000000..81ded224 + } +} diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java -index bb39d31b..28edad1a 100644 +index ec07ae6f..91da8ab6 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java @@ -1,5 +1,6 @@ @@ -191,7 +191,7 @@ index 00000000..a323598e + } +} diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java -index 41d752a5..61c2e52a 100644 +index 4c7e0fdc..4527c2da 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java @@ -9,6 +9,9 @@ import com.google.common.collect.Sets; @@ -217,7 +217,7 @@ index 41d752a5..61c2e52a 100644 import net.md_5.bungee.netty.PipelineUtils; import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.ProtocolConstants; -@@ -233,11 +242,12 @@ public class BungeeCord extends ProxyServer +@@ -225,11 +234,12 @@ public class BungeeCord extends ProxyServer // Waterfall end pluginManager = new PluginManager( this ); @@ -235,7 +235,7 @@ index 41d752a5..61c2e52a 100644 if ( !Boolean.getBoolean( "net.md_5.bungee.native.disable" ) ) { -@@ -286,6 +296,15 @@ public class BungeeCord extends ProxyServer +@@ -278,6 +288,15 @@ public class BungeeCord extends ProxyServer pluginManager.loadPlugins(); config.load(); @@ -251,7 +251,7 @@ index 41d752a5..61c2e52a 100644 if ( config.isForgeSupport() ) { registerChannel( ForgeConstants.FML_TAG ); -@@ -577,9 +596,7 @@ public class BungeeCord extends ProxyServer +@@ -569,9 +588,7 @@ public class BungeeCord extends ProxyServer String translation = ""; try { @@ -263,7 +263,7 @@ index 41d752a5..61c2e52a 100644 { } diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java -index 7b99c466..522bd93d 100644 +index af73283e..e3e4ac9f 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java @@ -1,6 +1,8 @@ @@ -275,7 +275,7 @@ index 7b99c466..522bd93d 100644 import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufAllocator; import java.net.InetSocketAddress; -@@ -163,7 +165,7 @@ public class ServerConnector extends PacketHandler +@@ -162,7 +164,7 @@ public class ServerConnector extends PacketHandler { if ( packet.packet == null ) { @@ -285,7 +285,7 @@ index 7b99c466..522bd93d 100644 } diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java -index db3d9c86..bc365e8b 100644 +index fb065ccd..3d18dbf9 100644 --- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java @@ -35,6 +35,7 @@ import net.md_5.bungee.api.SkinConfiguration; @@ -304,7 +304,7 @@ index db3d9c86..bc365e8b 100644 @RequiredArgsConstructor public final class UserConnection implements ProxiedPlayer -@@ -390,9 +392,11 @@ public final class UserConnection implements ProxiedPlayer +@@ -389,9 +391,11 @@ public final class UserConnection implements ProxiedPlayer .option( ChannelOption.CONNECT_TIMEOUT_MILLIS, request.getConnectTimeout() ) .remoteAddress( target.getAddress() ); // Windows is bugged, multi homed users will just have to live with random connecting IPs @@ -319,10 +319,10 @@ index db3d9c86..bc365e8b 100644 b.connect().addListener( listener ); } diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java -index e7542b1c..deee607d 100644 +index 95a6f40c..82e23314 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java -@@ -16,6 +16,8 @@ import java.util.logging.Level; +@@ -14,6 +14,8 @@ import java.util.logging.Level; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; @@ -331,7 +331,7 @@ index e7542b1c..deee607d 100644 import lombok.Getter; import lombok.RequiredArgsConstructor; import net.md_5.bungee.BungeeCord; -@@ -152,7 +154,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection +@@ -150,7 +152,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection { if ( packet.packet == null ) { @@ -341,7 +341,7 @@ index e7542b1c..deee607d 100644 } diff --git a/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java -index 6cd71071..423af854 100644 +index 6df3f3dd..264c22e8 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java @@ -1,6 +1,7 @@ @@ -353,7 +353,7 @@ index 6cd71071..423af854 100644 import lombok.RequiredArgsConstructor; import net.md_5.bungee.BungeeCord; diff --git a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java -index b8e50855..7f18b564 100644 +index 3bbc1510..4c53e02c 100644 --- a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java +++ b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java @@ -1,6 +1,8 @@ @@ -366,7 +366,7 @@ index b8e50855..7f18b564 100644 import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.handler.codec.CorruptedFrameException; diff --git a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java -index 4996a7b4..1d86aa63 100644 +index 654203ab..a840bc70 100644 --- a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java +++ b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java @@ -1,6 +1,8 @@ @@ -379,5 +379,5 @@ index 4996a7b4..1d86aa63 100644 import io.netty.buffer.PooledByteBufAllocator; import io.netty.channel.Channel; -- -2.31.1 +2.31.1.windows.1 diff --git a/Waterfall-Proxy-Patches/0024-FlameCord-module-system.patch b/Waterfall-Proxy-Patches/0019-FlameCord-module-system.patch similarity index 96% rename from Waterfall-Proxy-Patches/0024-FlameCord-module-system.patch rename to Waterfall-Proxy-Patches/0019-FlameCord-module-system.patch index 7df216b..68cc283 100644 --- a/Waterfall-Proxy-Patches/0024-FlameCord-module-system.patch +++ b/Waterfall-Proxy-Patches/0019-FlameCord-module-system.patch @@ -1,4 +1,4 @@ -From 2b17b5973a9618e4f4939c801d47e34a43c26477 Mon Sep 17 00:00:00 2001 +From 983a88969c8f9a151ad81f3e0b77c664d065217f Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Sat, 1 May 2021 14:17:48 -0300 Subject: [PATCH] FlameCord module system @@ -134,7 +134,7 @@ index 00000000..e82c4844 + } +} diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java -index 61c2e52a..a862f0a2 100644 +index 4527c2da..8111f40d 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java @@ -12,6 +12,7 @@ import com.google.gson.GsonBuilder; @@ -145,7 +145,7 @@ index 61c2e52a..a862f0a2 100644 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import io.github.waterfallmc.waterfall.conf.WaterfallConfiguration; import io.github.waterfallmc.waterfall.event.ProxyExceptionEvent; -@@ -286,9 +287,10 @@ public class BungeeCord extends ProxyServer +@@ -278,9 +279,10 @@ public class BungeeCord extends ProxyServer bossEventLoopGroup = PipelineUtils.newEventLoopGroup( 0, new ThreadFactoryBuilder().setNameFormat( "Netty Boss IO Thread #%1$d" ).build() ); workerEventLoopGroup = PipelineUtils.newEventLoopGroup( 0, new ThreadFactoryBuilder().setNameFormat( "Netty Worker IO Thread #%1$d" ).build() ); @@ -158,7 +158,7 @@ index 61c2e52a..a862f0a2 100644 pluginsFolder.mkdir(); pluginManager.detectPlugins( pluginsFolder ); -@@ -304,6 +306,7 @@ public class BungeeCord extends ProxyServer +@@ -296,6 +298,7 @@ public class BungeeCord extends ProxyServer } FlameCord.renew(logger, whitelistedAddresses); @@ -166,7 +166,7 @@ index 61c2e52a..a862f0a2 100644 if ( config.isForgeSupport() ) { -@@ -833,4 +836,56 @@ public class BungeeCord extends ProxyServer +@@ -825,4 +828,56 @@ public class BungeeCord extends ProxyServer { return new BungeeTitle(); } @@ -224,5 +224,5 @@ index 61c2e52a..a862f0a2 100644 + } } -- -2.31.1 +2.31.1.windows.1 diff --git a/Waterfall-Proxy-Patches/0025-FlameCord-message-configuration.patch b/Waterfall-Proxy-Patches/0020-FlameCord-message-configuration.patch similarity index 98% rename from Waterfall-Proxy-Patches/0025-FlameCord-message-configuration.patch rename to Waterfall-Proxy-Patches/0020-FlameCord-message-configuration.patch index f15c027..96c0ae1 100644 --- a/Waterfall-Proxy-Patches/0025-FlameCord-message-configuration.patch +++ b/Waterfall-Proxy-Patches/0020-FlameCord-message-configuration.patch @@ -1,4 +1,4 @@ -From b2c9244be507307e1f490b2dfb53f8021d81fd85 Mon Sep 17 00:00:00 2001 +From b5571b07773efbc291f87e7b85ff1b4d25ba3192 Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Sat, 1 May 2021 13:40:39 -0300 Subject: [PATCH] FlameCord message configuration @@ -209,10 +209,10 @@ index a323598e..bf6f8538 100644 } } diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java -index a862f0a2..fb19d5dc 100644 +index 8111f40d..483884a4 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java -@@ -596,14 +596,8 @@ public class BungeeCord extends ProxyServer +@@ -588,14 +588,8 @@ public class BungeeCord extends ProxyServer @Override public String getTranslation(String name, Object... args) { @@ -230,5 +230,5 @@ index a862f0a2..fb19d5dc 100644 @Override -- -2.31.1 +2.31.1.windows.1 diff --git a/Waterfall-Proxy-Patches/0021-Fix-ByteBuf-memory-leaks.patch b/Waterfall-Proxy-Patches/0021-Fix-ByteBuf-memory-leaks.patch new file mode 100644 index 0000000..50dd6c2 --- /dev/null +++ b/Waterfall-Proxy-Patches/0021-Fix-ByteBuf-memory-leaks.patch @@ -0,0 +1,127 @@ +From 88219f64895f1a90ecb7448c38e409f13981eaa9 Mon Sep 17 00:00:00 2001 +From: linsaftw +Date: Sat, 20 Mar 2021 12:36:25 -0300 +Subject: [PATCH] Fix ByteBuf memory leaks + + +diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java +index e3e4ac9f..c8089afc 100644 +--- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java ++++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java +@@ -274,9 +274,15 @@ public class ServerConnector extends PacketHandler + } else + { + ByteBuf brand = ByteBufAllocator.DEFAULT.heapBuffer(); +- DefinedPacket.writeString( bungee.getName() + " (" + bungee.getVersion() + ")", brand ); +- user.unsafe().sendPacket( new PluginMessage( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand", brand, handshakeHandler.isServerForge() ) ); +- brand.release(); ++ ++ try ++ { ++ DefinedPacket.writeString( bungee.getName() + " (" + bungee.getVersion() + ")", brand ); ++ user.unsafe().sendPacket( new PluginMessage( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand", brand, handshakeHandler.isServerForge() ) ); ++ } finally ++ { ++ brand.release(); ++ } + } + + user.setDimension( login.getDimension() ); +diff --git a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java +index 9e180c30..40c016d6 100644 +--- a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java ++++ b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java +@@ -287,15 +287,24 @@ public class DownstreamBridge extends PacketHandler + if ( pluginMessage.getTag().equals( con.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand" ) ) + { + ByteBuf brand = Unpooled.wrappedBuffer( pluginMessage.getData() ); +- String serverBrand = DefinedPacket.readString( brand ); +- brand.release(); + +- Preconditions.checkState( !serverBrand.contains( bungee.getName() ), "Cannot connect proxy to itself!" ); ++ try { ++ String serverBrand; + +- brand = ByteBufAllocator.DEFAULT.heapBuffer(); +- DefinedPacket.writeString( bungee.getName() + " <- " + serverBrand, brand ); // Waterfall +- pluginMessage.setData( brand ); +- brand.release(); ++ try { ++ serverBrand = DefinedPacket.readString( brand ); ++ } finally { ++ brand.release(); ++ } ++ ++ Preconditions.checkState( !serverBrand.contains( bungee.getName() ), "Cannot connect proxy to itself!" ); ++ ++ brand = ByteBufAllocator.DEFAULT.heapBuffer(); ++ DefinedPacket.writeString( bungee.getName() + " <- " + serverBrand, brand ); // Waterfall ++ pluginMessage.setData( brand ); ++ } finally { ++ brand.release(); ++ } + // changes in the packet are ignored so we need to send it manually + con.unsafe().sendPacket( pluginMessage ); + throw CancelSendSignal.INSTANCE; +diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java +index 13456b34..6d4b96cd 100644 +--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java ++++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java +@@ -141,11 +141,15 @@ public abstract class EntityMap + if ( readId == oldId || readId == newId ) + { + ByteBuf data = packet.copy(); +- packet.readerIndex( offset ); +- packet.writerIndex( offset ); +- DefinedPacket.writeVarInt( readId == oldId ? newId : oldId, packet ); +- packet.writeBytes( data ); +- data.release(); ++ ++ try { ++ packet.readerIndex( offset ); ++ packet.writerIndex( offset ); ++ DefinedPacket.writeVarInt( readId == oldId ? newId : oldId, packet ); ++ packet.writeBytes( data ); ++ } finally { ++ data.release(); ++ } + } + } + +diff --git a/proxy/src/main/java/net/md_5/bungee/forge/ForgeUtils.java b/proxy/src/main/java/net/md_5/bungee/forge/ForgeUtils.java +index cefa0206..8d4439ab 100644 +--- a/proxy/src/main/java/net/md_5/bungee/forge/ForgeUtils.java ++++ b/proxy/src/main/java/net/md_5/bungee/forge/ForgeUtils.java +@@ -38,16 +38,22 @@ public class ForgeUtils + { + Map modTags = new HashMap<>(); + ByteBuf payload = Unpooled.wrappedBuffer( pluginMessage.getData() ); +- byte discriminator = payload.readByte(); +- if ( discriminator == 2 ) // ModList +- { +- ByteBuf buffer = payload.slice(); +- int modCount = DefinedPacket.readVarInt( buffer, 2 ); +- for ( int i = 0; i < modCount; i++ ) ++ ++ try { ++ byte discriminator = payload.readByte(); ++ if ( discriminator == 2 ) // ModList + { +- modTags.put( DefinedPacket.readString( buffer ), DefinedPacket.readString( buffer ) ); ++ ByteBuf buffer = payload.slice(); ++ int modCount = DefinedPacket.readVarInt( buffer, 2 ); ++ for ( int i = 0; i < modCount; i++ ) ++ { ++ modTags.put( DefinedPacket.readString( buffer ), DefinedPacket.readString( buffer ) ); ++ } + } ++ } finally { ++ payload.release(); + } ++ + return modTags; + } + +-- +2.31.1.windows.1 + diff --git a/Waterfall-Proxy-Patches/0027-Check-if-packetID-is-invalid.patch b/Waterfall-Proxy-Patches/0022-Check-if-packetID-is-invalid.patch similarity index 91% rename from Waterfall-Proxy-Patches/0027-Check-if-packetID-is-invalid.patch rename to Waterfall-Proxy-Patches/0022-Check-if-packetID-is-invalid.patch index 27c57e6..1b26d35 100644 --- a/Waterfall-Proxy-Patches/0027-Check-if-packetID-is-invalid.patch +++ b/Waterfall-Proxy-Patches/0022-Check-if-packetID-is-invalid.patch @@ -1,11 +1,11 @@ -From eea04c872972cf457d2ffc61fda629c4ad7c21d0 Mon Sep 17 00:00:00 2001 +From b0a0b07a690aa1a78ed90f2318dd269145497e4d Mon Sep 17 00:00:00 2001 From: PermisosDev <55111245+PermisosDev@users.noreply.github.com> Date: Thu, 15 Apr 2021 08:34:57 -0300 Subject: [PATCH] Check if packetID is invalid. diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java -index 28edad1a..f0761a4f 100644 +index 91da8ab6..c03e1b51 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java @@ -65,7 +65,12 @@ public class MinecraftDecoder extends MessageToMessageDecoder @@ -23,5 +23,5 @@ index 28edad1a..f0761a4f 100644 if ( packet != null ) { -- -2.31.1 +2.31.1.windows.1 diff --git a/Waterfall-Proxy-Patches/0028-Firewall-System.patch b/Waterfall-Proxy-Patches/0023-Firewall-System.patch similarity index 97% rename from Waterfall-Proxy-Patches/0028-Firewall-System.patch rename to Waterfall-Proxy-Patches/0023-Firewall-System.patch index a588199..a7b7303 100644 --- a/Waterfall-Proxy-Patches/0028-Firewall-System.patch +++ b/Waterfall-Proxy-Patches/0023-Firewall-System.patch @@ -1,4 +1,4 @@ -From d1d73f437bc7e61be80eed98c4d8485f53b38a02 Mon Sep 17 00:00:00 2001 +From f3e4276fb66c18b3c78975e452d1d4b6c78939dc Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Fri, 30 Apr 2021 22:54:44 -0300 Subject: [PATCH] Firewall System @@ -246,7 +246,7 @@ index 00000000..dfb5c6d3 +} \ No newline at end of file diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java -index f0761a4f..31873afc 100644 +index c03e1b51..7f4b5b45 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java @@ -46,8 +46,14 @@ public class MinecraftDecoder extends MessageToMessageDecoder @@ -303,10 +303,10 @@ index bf6f8538..fa0b59c2 100644 // FlameCord - Collect ips from servers final Collection whitelistedAddresses = new HashSet<>(); diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java -index 494375cd..aedfece3 100644 +index c8089afc..2b2a12d8 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java -@@ -165,6 +165,9 @@ public class ServerConnector extends PacketHandler +@@ -164,6 +164,9 @@ public class ServerConnector extends PacketHandler { if ( packet.packet == null ) { @@ -317,10 +317,10 @@ index 494375cd..aedfece3 100644 } } diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java -index deee607d..3720825a 100644 +index 82e23314..8e1749a4 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java -@@ -154,6 +154,9 @@ public class InitialHandler extends PacketHandler implements PendingConnection +@@ -152,6 +152,9 @@ public class InitialHandler extends PacketHandler implements PendingConnection { if ( packet.packet == null ) { @@ -330,7 +330,7 @@ index deee607d..3720825a 100644 throw new QuietException( "Unexpected packet received during server login process!\n" + BufUtil.dump(packet.buf, 16) ); } } -@@ -396,6 +399,9 @@ public class InitialHandler extends PacketHandler implements PendingConnection +@@ -379,6 +382,9 @@ public class InitialHandler extends PacketHandler implements PendingConnection } break; default: @@ -341,7 +341,7 @@ index deee607d..3720825a 100644 } } diff --git a/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java -index 423af854..70917b0b 100644 +index 264c22e8..2101cbc4 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java @@ -2,6 +2,7 @@ package net.md_5.bungee.connection; @@ -352,7 +352,7 @@ index 423af854..70917b0b 100644 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import lombok.RequiredArgsConstructor; import net.md_5.bungee.BungeeCord; -@@ -59,6 +60,9 @@ public class PingHandler extends PacketHandler +@@ -58,6 +59,9 @@ public class PingHandler extends PacketHandler { if ( packet.packet == null ) { @@ -363,7 +363,7 @@ index 423af854..70917b0b 100644 } } diff --git a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java -index 7f18b564..616651ba 100644 +index 4c53e02c..376daee9 100644 --- a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java +++ b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java @@ -11,6 +11,7 @@ import io.netty.handler.codec.haproxy.HAProxyMessage; @@ -375,7 +375,7 @@ index 7f18b564..616651ba 100644 import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.connection.CancelSendSignal; diff --git a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java -index 1d86aa63..915c162f 100644 +index a840bc70..4e23c996 100644 --- a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java +++ b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java @@ -63,6 +63,13 @@ public class PipelineUtils @@ -426,5 +426,5 @@ index b3bdfd05..49d53f17 100644 throw new IllegalStateException( "Invalid data request packet" ); } -- -2.31.1 +2.31.1.windows.1 diff --git a/Waterfall-Proxy-Patches/0029-FlameCord-logger-options.patch b/Waterfall-Proxy-Patches/0024-FlameCord-logger-options.patch similarity index 83% rename from Waterfall-Proxy-Patches/0029-FlameCord-logger-options.patch rename to Waterfall-Proxy-Patches/0024-FlameCord-logger-options.patch index e84d6b8..29115df 100644 --- a/Waterfall-Proxy-Patches/0029-FlameCord-logger-options.patch +++ b/Waterfall-Proxy-Patches/0024-FlameCord-logger-options.patch @@ -1,11 +1,11 @@ -From 59dcb230fde16df56f6a30ea041a4c20fb2d2794 Mon Sep 17 00:00:00 2001 +From 9f407b33ffcaf789e7c58bcd2455bbbc6b7b8c32 Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Fri, 30 Apr 2021 23:51:51 -0300 Subject: [PATCH] FlameCord logger options diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java -index 8bb61ac1..8822c6d3 100644 +index 8bb61ac1..056dcb81 100644 --- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java +++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java @@ -12,6 +12,15 @@ import net.md_5.bungee.config.Configuration; @@ -24,24 +24,23 @@ index 8bb61ac1..8822c6d3 100644 @Getter private boolean firewallNotify = true; @Getter -@@ -34,6 +43,12 @@ public class FlameCordConfiguration { +@@ -34,6 +43,11 @@ public class FlameCordConfiguration { configuration = configurationProvider.load(configurationFile); } -+ this.loggerInitialhandler = setIfUnexistant("logger.initialhandler", this.loggerInitialhandler, -+ configuration); ++ this.loggerInitialhandler = setIfUnexistant("logger.initialhandler", this.loggerInitialhandler, configuration); + this.loggerExceptions = setIfUnexistant("logger.exceptions", this.loggerExceptions, configuration); + this.loggerDump = setIfUnexistant("logger.dump", this.loggerDump, configuration); -+ this.loggerHaProxy = setIfUnexistant("logger.haproxy", this.loggerHaProxy, configuration); -+ ++ this.loggerHaProxy = setIfUnexistant("logger.haproxy", this.loggerHaProxy, configuration); ++ this.firewallEnabled = setIfUnexistant("firewall.enabled", this.firewallEnabled, configuration); this.firewallNotify = setIfUnexistant("firewall.notify", this.firewallNotify, configuration); this.firewallSeconds = setIfUnexistant("firewall.seconds", this.firewallSeconds, configuration); diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java -index 3720825a..03c5aa07 100644 +index 8e1749a4..4767edb6 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java -@@ -370,7 +370,8 @@ public class InitialHandler extends PacketHandler implements PendingConnection +@@ -353,7 +353,8 @@ public class InitialHandler extends PacketHandler implements PendingConnection { case 1: // Ping @@ -51,7 +50,7 @@ index 3720825a..03c5aa07 100644 { bungee.getLogger().log( Level.INFO, "{0} has pinged", this ); } -@@ -379,7 +380,8 @@ public class InitialHandler extends PacketHandler implements PendingConnection +@@ -362,7 +363,8 @@ public class InitialHandler extends PacketHandler implements PendingConnection break; case 2: // Login @@ -62,7 +61,7 @@ index 3720825a..03c5aa07 100644 bungee.getLogger().log( Level.INFO, "{0} has connected", this ); } diff --git a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java -index 616651ba..7bf30b23 100644 +index 376daee9..62895541 100644 --- a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java +++ b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java @@ -47,7 +47,8 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter @@ -75,8 +74,8 @@ index 616651ba..7bf30b23 100644 { ProxyServer.getInstance().getLogger().log( Level.INFO, "{0} has connected", handler ); } -@@ -63,7 +64,8 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter - channel.close(); +@@ -62,7 +63,8 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter + channel.markClosed(); handler.disconnected( channel ); - if ( !( handler instanceof InitialHandler || handler instanceof PingHandler ) ) @@ -85,7 +84,7 @@ index 616651ba..7bf30b23 100644 { ProxyServer.getInstance().getLogger().log( Level.INFO, "{0} has disconnected", handler ); } -@@ -94,10 +96,13 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter +@@ -93,10 +95,12 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter { InetSocketAddress newAddress = new InetSocketAddress( proxy.sourceAddress(), proxy.sourcePort() ); @@ -94,16 +93,15 @@ index 616651ba..7bf30b23 100644 - channel.getRemoteAddress(), newAddress - } ); + // FlameCord - Option to log haproxy -+ if ( FlameCord.getInstance().getFlameCordConfiguration().isLoggerHaProxy() ) { ++ if ( FlameCord.getInstance().getFlameCordConfiguration().isLoggerHaProxy() ) + ProxyServer.getInstance().getLogger().log( Level.FINE, "Set remote address via PROXY {0} -> {1}", new Object[] + { + channel.getRemoteAddress(), newAddress + } ); -+ } channel.setRemoteAddress( newAddress ); } finally -@@ -141,6 +146,9 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter +@@ -140,6 +144,9 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter { boolean logExceptions = !( handler instanceof PingHandler ); @@ -114,7 +112,7 @@ index 616651ba..7bf30b23 100644 { if ( cause instanceof ReadTimeoutException ) diff --git a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java -index 915c162f..a6722b41 100644 +index 4e23c996..7fb1e70f 100644 --- a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java +++ b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java @@ -116,7 +116,10 @@ public class PipelineUtils @@ -125,10 +123,22 @@ index 915c162f..a6722b41 100644 + // FlameCord - Option to log exceptions + if (FlameCord.getInstance().getFlameCordConfiguration().isLoggerExceptions()) { + cause.printStackTrace(); ++ } + + ctx.close(); + } +@@ -218,7 +221,10 @@ public class PipelineUtils + // FlameCord - Close on exception caught + @Override + public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) throws Exception { +- cause.printStackTrace(); ++ // FlameCord - Option to log exceptions ++ if (FlameCord.getInstance().getFlameCordConfiguration().isLoggerExceptions()) { ++ cause.printStackTrace(); + } ctx.close(); } -- -2.31.1 +2.31.1.windows.1 diff --git a/Waterfall-Proxy-Patches/0030-Always-release-packet.patch b/Waterfall-Proxy-Patches/0025-Always-release-packet.patch similarity index 83% rename from Waterfall-Proxy-Patches/0030-Always-release-packet.patch rename to Waterfall-Proxy-Patches/0025-Always-release-packet.patch index a10c5ac..74cb390 100644 --- a/Waterfall-Proxy-Patches/0030-Always-release-packet.patch +++ b/Waterfall-Proxy-Patches/0025-Always-release-packet.patch @@ -1,14 +1,14 @@ -From e00ed4d4e69f192d801c294b96a5bac11c21a344 Mon Sep 17 00:00:00 2001 +From 8b821ba664dec9f72eae84e445cd6b973550de9d Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Sat, 1 May 2021 23:28:19 -0300 Subject: [PATCH] Always release packet diff --git a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java -index 7bf30b23..21bd5a17 100644 +index 62895541..7316dc7a 100644 --- a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java +++ b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java -@@ -112,12 +112,14 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter +@@ -110,12 +110,14 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter return; } @@ -27,7 +27,7 @@ index 7bf30b23..21bd5a17 100644 if ( sendPacket && packet.packet != null ) { try -@@ -132,10 +134,10 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter +@@ -130,10 +132,10 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter { handler.handle( packet ); } @@ -42,5 +42,5 @@ index 7bf30b23..21bd5a17 100644 } -- -2.31.1 +2.31.1.windows.1 diff --git a/Waterfall-Proxy-Patches/0031-Added-an-api-method-to-unload-Plugins.patch b/Waterfall-Proxy-Patches/0026-Added-an-api-method-to-unload-Plugins.patch similarity index 97% rename from Waterfall-Proxy-Patches/0031-Added-an-api-method-to-unload-Plugins.patch rename to Waterfall-Proxy-Patches/0026-Added-an-api-method-to-unload-Plugins.patch index 5a12408..69b7729 100644 --- a/Waterfall-Proxy-Patches/0031-Added-an-api-method-to-unload-Plugins.patch +++ b/Waterfall-Proxy-Patches/0026-Added-an-api-method-to-unload-Plugins.patch @@ -1,4 +1,4 @@ -From 14c353d7490b306ac6b9caee45b8d8eec824c128 Mon Sep 17 00:00:00 2001 +From 4490a84ec88d2ee52c4333eb6f5fe1b2433a50d8 Mon Sep 17 00:00:00 2001 From: abhiram Date: Thu, 13 May 2021 01:05:03 +0530 Subject: [PATCH] Added an api method to unload Plugins @@ -82,5 +82,5 @@ index 90031156..a190dfae 100644 ProxyServer.getInstance().getLogger().log( Level.INFO, "Loaded plugin {0} version {1} by {2}", new Object[] { -- -2.26.2.windows.1 +2.31.1.windows.1 diff --git a/Waterfall-Proxy-Patches/0026-Fix-ByteBuf-memory-leaks.patch b/Waterfall-Proxy-Patches/0026-Fix-ByteBuf-memory-leaks.patch deleted file mode 100644 index ca12aa0..0000000 --- a/Waterfall-Proxy-Patches/0026-Fix-ByteBuf-memory-leaks.patch +++ /dev/null @@ -1,167 +0,0 @@ -From 70d54b4ecbdca409826513d00c0a4d53d6603a11 Mon Sep 17 00:00:00 2001 -From: linsaftw -Date: Sat, 20 Mar 2021 12:36:25 -0300 -Subject: [PATCH] Fix ByteBuf memory leaks - - -diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java -index 522bd93d..494375cd 100644 ---- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java -+++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java -@@ -284,9 +284,15 @@ public class ServerConnector extends PacketHandler - } else - { - ByteBuf brand = ByteBufAllocator.DEFAULT.heapBuffer(); -- DefinedPacket.writeString(brandString, brand); -- user.unsafe().sendPacket( new PluginMessage( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand", brand, handshakeHandler.isServerForge() ) ); -- brand.release(); -+ -+ try -+ { -+ DefinedPacket.writeString(brandString, brand); -+ user.unsafe().sendPacket( new PluginMessage( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand", brand, handshakeHandler.isServerForge() ) ); -+ } finally -+ { -+ brand.release(); -+ } - } - // FlameCord end - } -diff --git a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java -index 474551d3..8716d0c8 100644 ---- a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java -+++ b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java -@@ -294,12 +294,21 @@ public class DownstreamBridge extends PacketHandler - try - { - ByteBuf brand = Unpooled.wrappedBuffer(pluginMessage.getData()); -- String serverBrand = DefinedPacket.readString(brand); -- brand.release(); -- brand = ByteBufAllocator.DEFAULT.heapBuffer(); -- DefinedPacket.writeString(bungee.getName() + " <- " + serverBrand, brand ); // Waterfall -- pluginMessage.setData(brand); -- brand.release(); -+ String serverBrand = null; -+ -+ try { -+ serverBrand = DefinedPacket.readString(brand); -+ } finally { -+ brand.release(); -+ } -+ -+ try { -+ brand = ByteBufAllocator.DEFAULT.heapBuffer(); -+ DefinedPacket.writeString(bungee.getName() + " <- " + serverBrand, brand ); // Waterfall -+ pluginMessage.setData(brand); -+ } finally { -+ brand.release(); -+ } - } catch (Exception ProtocolHacksSuck) - { - return; -diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java -index 44066317..e4b97490 100644 ---- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java -+++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java -@@ -145,11 +145,17 @@ public abstract class EntityMap - if ( readId == oldId || readId == newId ) - { - ByteBuf data = packet.copy(); -- packet.readerIndex( offset ); -- packet.writerIndex( offset ); -- DefinedPacket.writeVarInt( readId == oldId ? newId : oldId, packet ); -- packet.writeBytes( data ); -- data.release(); -+ -+ try -+ { -+ packet.readerIndex( offset ); -+ packet.writerIndex( offset ); -+ DefinedPacket.writeVarInt( readId == oldId ? newId : oldId, packet ); -+ packet.writeBytes( data ); -+ } finally -+ { -+ data.release(); -+ } - } - } - -diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_6.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_6.java -index 6755fe84..21871d14 100644 ---- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_6.java -+++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_6.java -@@ -39,19 +39,27 @@ class EntityMap_1_7_6 extends EntityMap_1_7_2 - && profile.getProperties().length >= 1 ) - { - ByteBuf rest = packet.copy(); -- packet.readerIndex( readerIndex ); -- packet.writerIndex( readerIndex + packetIdLength + idLength ); -- DefinedPacket.writeString( player.getUniqueId().toString(), packet ); -- DefinedPacket.writeString( username, packet ); -- DefinedPacket.writeVarInt( profile.getProperties().length, packet ); -- for ( LoginResult.Property property : profile.getProperties() ) -+ -+ try -+ { -+ packet.readerIndex( readerIndex ); -+ packet.writerIndex( readerIndex + packetIdLength + idLength ); -+ DefinedPacket.writeString( player.getUniqueId().toString(), packet ); -+ DefinedPacket.writeString( username, packet ); -+ DefinedPacket.writeVarInt( profile.getProperties().length, packet ); -+ -+ for ( LoginResult.Property property : profile.getProperties() ) -+ { -+ DefinedPacket.writeString( property.getName(), packet ); -+ DefinedPacket.writeString( property.getValue(), packet ); -+ DefinedPacket.writeString( property.getSignature(), packet ); -+ } -+ -+ packet.writeBytes( rest ); -+ } finally - { -- DefinedPacket.writeString( property.getName(), packet ); -- DefinedPacket.writeString( property.getValue(), packet ); -- DefinedPacket.writeString( property.getSignature(), packet ); -+ rest.release(); - } -- packet.writeBytes( rest ); -- rest.release(); - } - } - } -diff --git a/proxy/src/main/java/net/md_5/bungee/forge/ForgeUtils.java b/proxy/src/main/java/net/md_5/bungee/forge/ForgeUtils.java -index cefa0206..cede3994 100644 ---- a/proxy/src/main/java/net/md_5/bungee/forge/ForgeUtils.java -+++ b/proxy/src/main/java/net/md_5/bungee/forge/ForgeUtils.java -@@ -38,15 +38,22 @@ public class ForgeUtils - { - Map modTags = new HashMap<>(); - ByteBuf payload = Unpooled.wrappedBuffer( pluginMessage.getData() ); -- byte discriminator = payload.readByte(); -- if ( discriminator == 2 ) // ModList -+ -+ try - { -- ByteBuf buffer = payload.slice(); -- int modCount = DefinedPacket.readVarInt( buffer, 2 ); -- for ( int i = 0; i < modCount; i++ ) -+ byte discriminator = payload.readByte(); -+ if ( discriminator == 2 ) // ModList - { -- modTags.put( DefinedPacket.readString( buffer ), DefinedPacket.readString( buffer ) ); -+ ByteBuf buffer = payload.slice(); -+ -+ int modCount = DefinedPacket.readVarInt( buffer, 2 ); -+ for ( int i = 0; i < modCount; i++ ) -+ { -+ modTags.put( DefinedPacket.readString( buffer ), DefinedPacket.readString( buffer ) ); -+ } - } -+ } finally { -+ payload.release(); - } - return modTags; - } --- -2.31.1 - diff --git a/Waterfall-Proxy-Patches/0032-Apply-buffer-limits.patch b/Waterfall-Proxy-Patches/0027-Apply-buffer-limits.patch similarity index 94% rename from Waterfall-Proxy-Patches/0032-Apply-buffer-limits.patch rename to Waterfall-Proxy-Patches/0027-Apply-buffer-limits.patch index c74af6a..7911fef 100644 --- a/Waterfall-Proxy-Patches/0032-Apply-buffer-limits.patch +++ b/Waterfall-Proxy-Patches/0027-Apply-buffer-limits.patch @@ -1,14 +1,14 @@ -From 9b03768079f2ac841fa87e3e10d3808b7bc3cae3 Mon Sep 17 00:00:00 2001 +From 3dc90158a5898f0546df38b2b55c49e949d78177 Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Wed, 19 May 2021 12:56:29 -0300 Subject: [PATCH] Apply buffer limits diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java -index fb19d5dc..7c5af95b 100644 +index 483884a4..ab9e2ab5 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java -@@ -378,6 +378,9 @@ public class BungeeCord extends ProxyServer +@@ -370,6 +370,9 @@ public class BungeeCord extends ProxyServer } } }; @@ -18,7 +18,7 @@ index fb19d5dc..7c5af95b 100644 new ServerBootstrap() .channel( PipelineUtils.getServerChannel( info.getSocketAddress() ) ) .option( ChannelOption.SO_REUSEADDR, true ) // TODO: Move this elsewhere! -@@ -385,6 +388,8 @@ public class BungeeCord extends ProxyServer +@@ -377,6 +380,8 @@ public class BungeeCord extends ProxyServer .childHandler( PipelineUtils.SERVER_CHILD ) .group( bossEventLoopGroup, workerEventLoopGroup ) .localAddress( info.getSocketAddress() ) @@ -52,7 +52,7 @@ index 37657c4c..ba31471e 100644 if ( ssl ) { diff --git a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java -index a6722b41..5de2e6ef 100644 +index 7fb1e70f..c7038164 100644 --- a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java +++ b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java @@ -207,6 +207,11 @@ public class PipelineUtils @@ -95,5 +95,5 @@ index 8becc26a..8304685c 100644 } } -- -2.31.1 +2.31.1.windows.1 diff --git a/Waterfall-Proxy-Patches/0033-Limit-String-read.patch b/Waterfall-Proxy-Patches/0028-Limit-String-read.patch similarity index 89% rename from Waterfall-Proxy-Patches/0033-Limit-String-read.patch rename to Waterfall-Proxy-Patches/0028-Limit-String-read.patch index 7b72321..fcbfd36 100644 --- a/Waterfall-Proxy-Patches/0033-Limit-String-read.patch +++ b/Waterfall-Proxy-Patches/0028-Limit-String-read.patch @@ -1,11 +1,11 @@ -From 01ec864075a0abd0084167e9e72e632f254de58f Mon Sep 17 00:00:00 2001 +From a6622a844340dc2983b7d8da50037a4a509a038f Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Wed, 19 May 2021 15:40:41 -0300 Subject: [PATCH] Limit String read diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/DefinedPacket.java b/protocol/src/main/java/net/md_5/bungee/protocol/DefinedPacket.java -index 93d17f6b..dd663e1d 100644 +index 31a95495..01484bcc 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/DefinedPacket.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/DefinedPacket.java @@ -36,12 +36,13 @@ public abstract class DefinedPacket @@ -24,5 +24,5 @@ index 93d17f6b..dd663e1d 100644 { if(!MinecraftDecoder.DEBUG) throw STRING_TOO_MANY_BYTES_EXCEPTION; // Waterfall start: Additional DoS mitigations -- -2.31.1 +2.31.1.windows.1