Antibot Packets Check

This commit is contained in:
LinsaFTW 2022-12-21 21:56:04 -03:00
parent 872275f9d6
commit 937faefdc1
24 changed files with 549 additions and 405 deletions

View File

@ -1,24 +1,23 @@
From 8c2a775eba07694db8fb29e65ddd210638ad5335 Mon Sep 17 00:00:00 2001
From 510085f25ef21678828f5b3026662f51a94c1137 Mon Sep 17 00:00:00 2001
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Wed, 9 Mar 2022 14:36:43 -0300
Subject: [PATCH] Duplicate buf instead of Copy
Date: Wed, 21 Dec 2022 21:43:05 -0300
Subject: [PATCH] Use duplicate() for MinecraftDecoder
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 3992f521..074d2437 100644
index ac83e3253..c31ec1ce7 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
@@ -52,7 +52,8 @@ public class MinecraftDecoder extends MessageToMessageDecoder<ByteBuf>
}
@@ -38,7 +38,7 @@ public class MinecraftDecoder extends MessageToMessageDecoder<ByteBuf>
}
Protocol.DirectionData prot = ( server ) ? protocol.TO_SERVER : protocol.TO_CLIENT;
- ByteBuf slice = in.copy(); // Can't slice this one due to EntityMap :(
+ // FlameCord - Duplicate buf instead of Copy
+ ByteBuf slice = in.duplicate(); // Can't slice this one due to EntityMap :(
+ ByteBuf slice = in.duplicate(); // FlameCord - Duplicate buf instead of Copy
Object packetTypeInfo = null;
try
@@ -92,7 +93,8 @@ public class MinecraftDecoder extends MessageToMessageDecoder<ByteBuf>
@@ -73,7 +73,8 @@ public class MinecraftDecoder extends MessageToMessageDecoder<ByteBuf>
in.skipBytes( in.readableBytes() );
}

View File

@ -1,4 +1,4 @@
From b70bd30b4f028db1e399d9650cc049859d1f56bb Mon Sep 17 00:00:00 2001
From f3902b5c785041c3c029ed0d12d7eece40eca40b 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

View File

@ -1,18 +1,18 @@
From 772e70bce0c9626cb3c724b7c30c4802f7311e63 Mon Sep 17 00:00:00 2001
From cf87130274644325adbf7fabb7b95d95e976ee57 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 ac83e325..4b9b80b9 100644
index c31ec1ce7..640f0ea26 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<ByteBuf>
}
Protocol.DirectionData prot = ( server ) ? protocol.TO_SERVER : protocol.TO_CLIENT;
+
+
+ // FlameCord - Check size before decoding
+ if (prot == protocol.TO_SERVER) {
+ final int readableBytes = in.readableBytes();
@ -25,11 +25,11 @@ index ac83e325..4b9b80b9 100644
+ }
+ }
+
ByteBuf slice = in.copy(); // Can't slice this one due to EntityMap :(
ByteBuf slice = in.duplicate(); // FlameCord - Duplicate buf instead of Copy
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 f8d6becd..33605007 100644
index 29cf4b4fc..4820267b3 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
@@ -78,6 +78,15 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
@ -49,5 +49,5 @@ index f8d6becd..33605007 100644
{
HAProxyMessage proxy = (HAProxyMessage) msg;
--
2.32.0
2.37.3.windows.1

View File

@ -1,11 +1,11 @@
From 36e054d017b32104a878faed79fb18b5d8b5c9df Mon Sep 17 00:00:00 2001
From f790d57423c57a21d642db20b6de9d3515fd3e93 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] Change default timeout
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..3b5ce41e 100644
index 8911bee85..b67195ec8 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..3b5ce41e 100644
* UUID used for metrics.
*/
--
2.32.0
2.37.3.windows.1

View File

@ -1,11 +1,11 @@
From 1110d8e2d16633d02c7839b38f800ee5cedc0a84 Mon Sep 17 00:00:00 2001
From cbec17576f5c5472cf0037f9962ca5c806133200 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/util/AllowedCharacters.java b/proxy/src/main/java/net/md_5/bungee/util/AllowedCharacters.java
index d1cd1090..44cb1ce6 100644
index 1a4242a2e..d947fad7d 100644
--- a/proxy/src/main/java/net/md_5/bungee/util/AllowedCharacters.java
+++ b/proxy/src/main/java/net/md_5/bungee/util/AllowedCharacters.java
@@ -21,7 +21,8 @@ public final class AllowedCharacters
@ -19,5 +19,5 @@ index d1cd1090..44cb1ce6 100644
}
--
2.32.0
2.37.3.windows.1

View File

@ -1,11 +1,11 @@
From 290e7f633bb2ecffad78a8a2518ea9efdf890767 Mon Sep 17 00:00:00 2001
From 64097a804bbce407306eca64329053a0105a7c8f 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
diff --git a/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java b/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java
index 5c05f2b9..606866a5 100644
index 5c05f2b94..606866a52 100644
--- a/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java
+++ b/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java
@@ -5,6 +5,8 @@ import io.netty.channel.Channel;
@ -74,5 +74,5 @@ index 5c05f2b9..606866a5 100644
}
}
--
2.32.0
2.37.3.windows.1

View File

@ -1,4 +1,4 @@
From 3ae73e4c7fbb142045ee09281fdd5c6916d91967 Mon Sep 17 00:00:00 2001
From 407344a066199a42e7fa17a2d1b3fc4be2d095bf 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

View File

@ -1,4 +1,4 @@
From 6545a44d71d2e9d6f08bf4f93306c12c34673b7a Mon Sep 17 00:00:00 2001
From 0f07c38f3d16849626c28ae710616788f30b00fc 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,7 +6,7 @@ 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 f4f67b35..5293552d 100644
index 2d72e26ea..94702434d 100644
--- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java
+++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
@@ -313,7 +313,8 @@ public final class UserConnection implements ProxiedPlayer
@ -20,5 +20,5 @@ index f4f67b35..5293552d 100644
return;
}
--
2.34.1
2.37.3.windows.1

View File

@ -1,4 +1,4 @@
From 00f2e39b27c03173abb7025317b6e2e2ec48b50e Mon Sep 17 00:00:00 2001
From ac09d06618510ed85aadc83a5a6bb812bf109218 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

View File

@ -1,4 +1,4 @@
From 7f109bd269421da64f19fc2f393a829b7fbe6057 Mon Sep 17 00:00:00 2001
From 20e7630ff3f3f16d5f1b45c4fbe81037795088d8 Mon Sep 17 00:00:00 2001
From: Juan Cruz Linsalata <LinsaFTW@users.noreply.github.com>
Date: Mon, 12 Oct 2020 15:40:53 -0300
Subject: [PATCH] FlameCord General Patch
@ -48,10 +48,10 @@ index 000000000..8e69160d0
\ No newline at end of file
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameConfig.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameConfig.java
new file mode 100644
index 000000000..cfbd55c39
index 000000000..5589ce1b7
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameConfig.java
@@ -0,0 +1,38 @@
@@ -0,0 +1,42 @@
+package dev._2lstudios.flamecord.configuration;
+
+import java.util.ArrayList;
@ -61,6 +61,10 @@ index 000000000..cfbd55c39
+import net.md_5.bungee.config.Configuration;
+
+public class FlameConfig {
+ double setIfUnexistant(final String arg1, final double arg2, final Configuration configuration) {
+ return (double) setIfUnexistant(arg1, (Object) arg2, configuration);
+ }
+
+ int setIfUnexistant(final String arg1, final int arg2, final Configuration configuration) {
+ return (int) setIfUnexistant(arg1, (Object) arg2, configuration);
+ }
@ -130,7 +134,7 @@ index 000000000..c8148e902
+ }
+}
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 4b9b80b9d..aa35f870b 100644
index 640f0ea26..70a1192e7 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 @@
@ -205,7 +209,7 @@ index 000000000..91d60bfb3
+ }
+}
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 9f41970ea..0c04ec55d 100644
index e11e30402..8861da39d 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,8 @@ import com.google.common.collect.Sets;

View File

@ -1,4 +1,4 @@
From 87acee89e371ebceb65cf6fa7d1557dff12b26b5 Mon Sep 17 00:00:00 2001
From 598c8a3786b32bb1128ac3ab1ae1bfea6909f2cb 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
@ -87,7 +87,7 @@ index 000000000..6c5bb9617
+ }
+}
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 0c04ec55d..d753563af 100644
index 8861da39d..88ac66bab 100644
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
@@ -11,6 +11,8 @@ import com.google.gson.Gson;

View File

@ -1,4 +1,4 @@
From 2505fb3b13bcd83e87befef695fa5c4636149bef Mon Sep 17 00:00:00 2001
From dae4aa8593ae097fcc2961539dd2fc7787e8d63e 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
@ -201,7 +201,7 @@ index 91d60bfb3..cc76325b2 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 d753563af..c30b75c4f 100644
index 88ac66bab..501aacfa0 100644
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
@@ -626,8 +626,8 @@ public class BungeeCord extends ProxyServer

View File

@ -1,4 +1,4 @@
From 8f77c4e0ca063a83214f236a87d727716197692c Mon Sep 17 00:00:00 2001
From 4121bc5ef2215f0621d449c5cf2073c47ed93947 Mon Sep 17 00:00:00 2001
From: linsaftw <linsaftw@users.noreply.github.com>
Date: Sat, 20 Mar 2021 12:36:25 -0300
Subject: [PATCH] Fix ByteBuf memory leaks

View File

@ -1,11 +1,11 @@
From c727441bc5d674eface4fa65b416aceca4477406 Mon Sep 17 00:00:00 2001
From 7e20c899237e194fbda629aa6be4444fbe293b7d 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 aa35f870..3992f521 100644
index 70a1192e7..6316143f7 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<ByteBuf>
@ -23,5 +23,5 @@ index aa35f870..3992f521 100644
if ( packet != null )
{
--
2.32.0
2.37.3.windows.1

View File

@ -1,4 +1,4 @@
From 234c19a225886b0a27283fde38097e074537ba8f Mon Sep 17 00:00:00 2001
From 8edec45c116023de25620c7697ce1f887ea267ce 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

View File

@ -1,4 +1,4 @@
From c3d43897657dc6636189621bd60f9cb86b6ac2d0 Mon Sep 17 00:00:00 2001
From 664f35c5a6155c5e41aa10d1cd15cf590cc011a0 Mon Sep 17 00:00:00 2001
From: abhiram <abhithegamer2019@gmail.com>
Date: Thu, 13 May 2021 01:05:03 +0530
Subject: [PATCH] Added an api method to unload Plugins
@ -6,7 +6,7 @@ Subject: [PATCH] Added an api method to unload Plugins
Format Code to Bungee's code style
diff --git a/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java b/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java
index 90031156..a190dfae 100644
index 90031156f..a190dfae8 100644
--- a/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java
+++ b/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java
@@ -25,6 +25,7 @@ import java.util.Set;

View File

@ -1,11 +1,11 @@
From 5bddd07166fdd36bf8f174ded2841903aca46153 Mon Sep 17 00:00:00 2001
From 2caae71d8c0bdc5a325610ef1c77775f9ba4ee69 Mon Sep 17 00:00:00 2001
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Thu, 10 Jun 2021 11:30:19 -0300
Subject: [PATCH] Apply packet limits
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionRequest.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionRequest.java
index 86182cdd..b28f4081 100644
index e78519964..222285cc1 100644
--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionRequest.java
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionRequest.java
@@ -61,4 +61,14 @@ public class EncryptionRequest extends DefinedPacket
@ -24,7 +24,7 @@ index 86182cdd..b28f4081 100644
+ }
}
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Handshake.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Handshake.java
index 7dbbfd3c..b7842055 100644
index 7dbbfd3cd..b78420556 100644
--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Handshake.java
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Handshake.java
@@ -7,6 +7,7 @@ import lombok.EqualsAndHashCode;
@ -51,7 +51,7 @@ index 7dbbfd3c..b7842055 100644
+ }
}
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginRequest.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginRequest.java
index 682c8784..22a5b993 100644
index 3224b0d2b..763d34c2f 100644
--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginRequest.java
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginRequest.java
@@ -70,7 +70,8 @@ public class LoginRequest extends DefinedPacket

View File

@ -1,14 +1,14 @@
From b406218a681d715b932c80458b4164e4d4cd6db5 Mon Sep 17 00:00:00 2001
From 617ad8e4f511a78c2151d9f92e06c34bd3f3b680 Mon Sep 17 00:00:00 2001
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Thu, 7 Oct 2021 21:37:24 -0300
Subject: [PATCH] Custom motd system
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameConfig.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameConfig.java
index cfbd55c3..360305b9 100644
index 5589ce1b7..1e928197c 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameConfig.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameConfig.java
@@ -11,6 +11,10 @@ public class FlameConfig {
@@ -15,6 +15,10 @@ public class FlameConfig {
return (int) setIfUnexistant(arg1, (Object) arg2, configuration);
}
@ -20,7 +20,7 @@ index cfbd55c3..360305b9 100644
return (boolean) setIfUnexistant(arg1, (Object) arg2, configuration);
}
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 c327841a..de2cc947 100644
index aac41c8b2..7937af051 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
@@ -3,15 +3,80 @@ package dev._2lstudios.flamecord.configuration;
@ -125,7 +125,7 @@ index c327841a..de2cc947 100644
this.loggerExceptions = setIfUnexistant("logger.exceptions", this.loggerExceptions, configuration);
this.loggerDump = setIfUnexistant("logger.dump", this.loggerDump, 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 198086e0..d99cb5d0 100644
index 8fb36e37d..b340c7a55 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
@@ -23,6 +23,8 @@ import javax.crypto.spec.SecretKeySpec;

View File

@ -1,11 +1,11 @@
From 03547260d8d2d4445a56e83fd7e63fe0a836904b Mon Sep 17 00:00:00 2001
From 7001800c9141f42b15bd9adee24319f1837a8183 Mon Sep 17 00:00:00 2001
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Thu, 24 Feb 2022 23:41:57 -0300
Subject: [PATCH] TCP Fast Open
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 de2cc947..5d92c20c 100644
index 7937af051..a1d23f74d 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
@@ -16,6 +16,10 @@ import net.md_5.bungee.config.Configuration;
@ -28,7 +28,7 @@ index de2cc947..5d92c20c 100644
this.loggerInitialhandler = setIfUnexistant("logger.initialhandler", this.loggerInitialhandler, configuration);
this.loggerExceptions = setIfUnexistant("logger.exceptions", this.loggerExceptions, configuration);
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 a4c3bd71..ffea1599 100644
index a4c3bd710..ffea15992 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
@@ -194,6 +194,8 @@ public class PipelineUtils

View File

@ -1,4 +1,4 @@
From 1e5fa27a03247139aee723add5280ba00dfc901d Mon Sep 17 00:00:00 2001
From a19efbabc81d28c8529c2c92fd351c71393bd710 Mon Sep 17 00:00:00 2001
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Fri, 25 Feb 2022 12:28:31 -0300
Subject: [PATCH] InitialHandler Processing State

View File

@ -1,14 +1,14 @@
From b4ba3f3f68b4bfd4e8af4249fa30cc59ccfdde83 Mon Sep 17 00:00:00 2001
From b8c85934f332d737bf4c5d0fd3d19f9ecdfffe6b Mon Sep 17 00:00:00 2001
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Fri, 4 Mar 2022 13:35:53 -0300
Subject: [PATCH] Antibot System
diff --git a/flamecord/pom.xml b/flamecord/pom.xml
index 20edd9001..5978bec60 100644
index 20edd9001..f48f1e60b 100644
--- a/flamecord/pom.xml
+++ b/flamecord/pom.xml
@@ -30,6 +30,11 @@
@@ -30,6 +30,17 @@
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
@ -16,17 +16,74 @@ index 20edd9001..5978bec60 100644
+ <groupId>com.maxmind.db</groupId>
+ <artifactId>maxmind-db</artifactId>
+ <version>2.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-handler</artifactId>
+ <version>${netty.version}</version>
+ <scope>compile</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/flamecord/src/main/java/dev/_2lstudios/antibot/AccountsCheck.java b/flamecord/src/main/java/dev/_2lstudios/antibot/AccountsCheck.java
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java
index c78ab3a7c..ec880c07d 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java
@@ -3,6 +3,8 @@ package dev._2lstudios.flamecord;
import java.util.Collection;
import java.util.logging.Logger;
+import dev._2lstudios.flamecord.antibot.AddressDataManager;
+import dev._2lstudios.flamecord.antibot.CheckManager;
import dev._2lstudios.flamecord.configuration.FlameCordConfiguration;
import dev._2lstudios.flamecord.configuration.MessagesConfiguration;
import dev._2lstudios.flamecord.configuration.ModulesConfiguration;
@@ -18,26 +20,31 @@ public class FlameCord {
if (FlameCord.instance != null) {
instance.reload(logger);
} else {
- FlameCord.instance = new FlameCord(logger, whitelistedAddresses);
+ FlameCord.instance = new FlameCord();
+ instance.reload(logger);
}
}
@Getter
private FlameCordConfiguration flameCordConfiguration;
@Getter
+ private AddressDataManager addressDataManager;
+ @Getter
+ private CheckManager checkManager;
+ @Getter
private ModulesConfiguration modulesConfiguration;
@Getter
private MessagesConfiguration messagesConfiguration;
private void reload(final Logger logger) {
final ConfigurationProvider configurationProvider = ConfigurationProvider.getProvider(YamlConfiguration.class);
+
+ if (checkManager != null) checkManager.unload();
this.flameCordConfiguration = new FlameCordConfiguration(configurationProvider);
this.modulesConfiguration = new ModulesConfiguration(configurationProvider);
this.messagesConfiguration = new MessagesConfiguration(logger, configurationProvider);
- }
-
- private FlameCord(final Logger logger, final Collection<String> whitelistedAddresses) {
- reload(logger);
+ this.addressDataManager = new AddressDataManager();
+ this.checkManager = new CheckManager(addressDataManager, flameCordConfiguration);
}
}
\ No newline at end of file
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/AccountsCheck.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/AccountsCheck.java
new file mode 100644
index 000000000..da52c8924
index 000000000..5e7fa6bfb
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/antibot/AccountsCheck.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/AccountsCheck.java
@@ -0,0 +1,36 @@
+package dev._2lstudios.antibot;
+package dev._2lstudios.flamecord.antibot;
+
+import java.net.SocketAddress;
+import java.util.Collection;
@ -62,13 +119,13 @@ index 000000000..da52c8924
+ return false;
+ }
+}
diff --git a/flamecord/src/main/java/dev/_2lstudios/antibot/AddressData.java b/flamecord/src/main/java/dev/_2lstudios/antibot/AddressData.java
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/AddressData.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/AddressData.java
new file mode 100644
index 000000000..b37f114a0
index 000000000..b8448bdf2
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/antibot/AddressData.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/AddressData.java
@@ -0,0 +1,154 @@
+package dev._2lstudios.antibot;
+package dev._2lstudios.flamecord.antibot;
+
+import java.util.Collection;
+import java.util.HashSet;
@ -222,13 +279,13 @@ index 000000000..b37f114a0
+ return nicknames.contains(nickname);
+ }
+}
diff --git a/flamecord/src/main/java/dev/_2lstudios/antibot/AddressDataManager.java b/flamecord/src/main/java/dev/_2lstudios/antibot/AddressDataManager.java
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/AddressDataManager.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/AddressDataManager.java
new file mode 100644
index 000000000..6c7b300c2
index 000000000..46798dee0
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/antibot/AddressDataManager.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/AddressDataManager.java
@@ -0,0 +1,31 @@
+package dev._2lstudios.antibot;
+package dev._2lstudios.flamecord.antibot;
+
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
@ -259,13 +316,13 @@ index 000000000..6c7b300c2
+ return getAddressData(addressString);
+ }
+}
diff --git a/flamecord/src/main/java/dev/_2lstudios/antibot/CheckManager.java b/flamecord/src/main/java/dev/_2lstudios/antibot/CheckManager.java
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/CheckManager.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/CheckManager.java
new file mode 100644
index 000000000..0676f897f
index 000000000..1503ac954
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/antibot/CheckManager.java
@@ -0,0 +1,37 @@
+package dev._2lstudios.antibot;
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/CheckManager.java
@@ -0,0 +1,40 @@
+package dev._2lstudios.flamecord.antibot;
+
+import dev._2lstudios.flamecord.configuration.FlameCordConfiguration;
+import lombok.Getter;
@ -285,6 +342,8 @@ index 000000000..0676f897f
+ private final RatelimitCheck ratelimitCheck;
+ @Getter
+ private final ReconnectCheck reconnectCheck;
+ @Getter
+ private final PacketsCheck packetsCheck;
+
+ public CheckManager(final AddressDataManager addressDataManager, final FlameCordConfiguration flameCordConfiguration) {
+ this.accountsCheck = new AccountsCheck(addressDataManager);
@ -294,6 +353,7 @@ index 000000000..0676f897f
+ this.passwordCheck = new PasswordCheck(addressDataManager);
+ this.ratelimitCheck = new RatelimitCheck(addressDataManager);
+ this.reconnectCheck = new ReconnectCheck(addressDataManager);
+ this.packetsCheck = new PacketsCheck();
+
+ this.countryCheck.load();
+ }
@ -302,13 +362,13 @@ index 000000000..0676f897f
+ this.countryCheck.unload();
+ }
+}
diff --git a/flamecord/src/main/java/dev/_2lstudios/antibot/CountryCheck.java b/flamecord/src/main/java/dev/_2lstudios/antibot/CountryCheck.java
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/CountryCheck.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/CountryCheck.java
new file mode 100644
index 000000000..e2410468d
index 000000000..018aacd2c
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/antibot/CountryCheck.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/CountryCheck.java
@@ -0,0 +1,140 @@
+package dev._2lstudios.antibot;
+package dev._2lstudios.flamecord.antibot;
+
+import java.io.File;
+import java.io.IOException;
@ -448,13 +508,13 @@ index 000000000..e2410468d
+ return false;
+ }
+}
diff --git a/flamecord/src/main/java/dev/_2lstudios/antibot/FastChatCheck.java b/flamecord/src/main/java/dev/_2lstudios/antibot/FastChatCheck.java
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/FastChatCheck.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/FastChatCheck.java
new file mode 100644
index 000000000..197636935
index 000000000..682e1c314
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/antibot/FastChatCheck.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/FastChatCheck.java
@@ -0,0 +1,32 @@
+package dev._2lstudios.antibot;
+package dev._2lstudios.flamecord.antibot;
+
+import java.net.SocketAddress;
+
@ -486,13 +546,13 @@ index 000000000..197636935
+ return false;
+ }
+}
diff --git a/flamecord/src/main/java/dev/_2lstudios/antibot/NicknameCheck.java b/flamecord/src/main/java/dev/_2lstudios/antibot/NicknameCheck.java
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/NicknameCheck.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/NicknameCheck.java
new file mode 100644
index 000000000..222aba31f
index 000000000..165963629
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/antibot/NicknameCheck.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/NicknameCheck.java
@@ -0,0 +1,45 @@
+package dev._2lstudios.antibot;
+package dev._2lstudios.flamecord.antibot;
+
+import java.net.SocketAddress;
+
@ -537,13 +597,194 @@ index 000000000..222aba31f
+ return false;
+ }
+}
diff --git a/flamecord/src/main/java/dev/_2lstudios/antibot/PasswordCheck.java b/flamecord/src/main/java/dev/_2lstudios/antibot/PasswordCheck.java
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/PacketsCheck.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/PacketsCheck.java
new file mode 100644
index 000000000..bdc024f58
index 000000000..0de670b3f
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/antibot/PasswordCheck.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/PacketsCheck.java
@@ -0,0 +1,67 @@
+package dev._2lstudios.flamecord.antibot;
+
+import java.net.SocketAddress;
+import java.util.HashMap;
+import java.util.Map;
+
+import dev._2lstudios.flamecord.FlameCord;
+import dev._2lstudios.flamecord.configuration.FlameCordConfiguration;
+import dev._2lstudios.flamecord.enums.PacketsCheckResult;
+import dev._2lstudios.flamecord.enums.PacketsViolationReason;
+import dev._2lstudios.flamecord.utils.ProtocolUtil;
+import io.netty.buffer.ByteBuf;
+
+public class PacketsCheck {
+ private Map<String, PacketsData> packetsData = new HashMap<>();
+ private long lastCalculation = System.currentTimeMillis();
+
+ public PacketsData getData(SocketAddress address) {
+ String ip = address.toString();
+
+ if (System.currentTimeMillis() - lastCalculation >= 60000) {
+ packetsData.clear();
+ this.lastCalculation = System.currentTimeMillis();
+ }
+
+ PacketsData data;
+
+ if (packetsData.containsKey(ip)) {
+ data = packetsData.get(ip);
+ } else {
+ data = new PacketsData(address);
+ packetsData.put(ip, data);
+ }
+
+ return data;
+ }
+
+ public PacketsCheckResult check(SocketAddress socketAddress, ByteBuf byteBuf) {
+ PacketsData addressData = getData(socketAddress);
+ FlameCordConfiguration config = FlameCord.getInstance().getFlameCordConfiguration();
+ int length = byteBuf.readableBytes();
+ int index = byteBuf.readerIndex();
+ int packetId = ProtocolUtil.readVarInt(byteBuf);
+ byteBuf.readerIndex(index);
+
+ addressData.addVls(length * config.getAntibotPacketsVlsPerByte(), PacketsViolationReason.SIZE, packetId);
+ addressData.addVls(config.getAntibotPacketsVlsPerPacket(), PacketsViolationReason.RATE, packetId);
+
+ double vls = addressData.getPacketsVls();
+
+ if (vls >= config.getAntibotPacketsVlsToKick()) {
+ return PacketsCheckResult.KICK;
+ } else if (vls >= config.getAntibotPacketsVlsToCancel()) {
+ if (addressData.isCancelled()) {
+ return PacketsCheckResult.CANCEL;
+ } else {
+ addressData.setCancelled(true);
+ return PacketsCheckResult.FIRST_CANCEL;
+ }
+ } else {
+ return PacketsCheckResult.NONE;
+ }
+ }
+
+ public void printPackets(SocketAddress remoteAddress) {
+ }
+}
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/PacketsData.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/PacketsData.java
new file mode 100644
index 000000000..db1997d63
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/PacketsData.java
@@ -0,0 +1,102 @@
+package dev._2lstudios.flamecord.antibot;
+
+import java.net.SocketAddress;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import dev._2lstudios.flamecord.FlameCord;
+import dev._2lstudios.flamecord.enums.PacketsViolationReason;
+
+public class PacketsData {
+ // The address related to this data
+ private SocketAddress address;
+
+ // The vls of the current address
+ private double packetsVls = 0;
+
+ // The vls of the current address because of size
+ private double packetsVlsSize = 0;
+
+ // The vls of the current address because of rate
+ private double packetsVlsRate = 0;
+
+ // If this was cancelled in the last second
+ private boolean cancelled = false;
+
+ // The last time vls was calculated
+ private long lastVlsCalculated = System.currentTimeMillis();
+
+ private Map<Integer, Double> vlsByPacketId = new HashMap<>();
+
+ public PacketsData(SocketAddress address) {
+ this.address = address;
+ }
+
+ public double simplify(double number) {
+ return (double) (int) (number * 1000) / 1000;
+ }
+
+ public void printPackets() {
+ if (FlameCord.getInstance().getFlameCordConfiguration().isAntibotPacketsDebug() && this.packetsVls > 0) {
+ System.out
+ .println("[FlameCord] [" + address
+ + "] debug is enabled, showing stats (Total: " + simplify(packetsVls) + "vls Size: "
+ + simplify(packetsVlsSize) + "vls Rate: " + simplify(packetsVlsRate) + "vls)");
+ for (Entry<Integer, Double> entry : this.vlsByPacketId.entrySet()) {
+ System.out.print(entry.getKey() + "-" + simplify(entry.getValue()) + "vls, ");
+ }
+ System.out.println("");
+ }
+ }
+
+ public double getPacketsVls() {
+ if (System.currentTimeMillis() - lastVlsCalculated >= 1000) {
+ printPackets();
+
+ this.packetsVls = 0;
+ this.packetsVlsSize = 0;
+ this.packetsVlsRate = 0;
+ this.vlsByPacketId.clear();
+ this.cancelled = false;
+ this.lastVlsCalculated = System.currentTimeMillis();
+ }
+
+ return packetsVls;
+ }
+
+ public void addVls(double packetsVls, PacketsViolationReason reason, int packetId) {
+ this.packetsVls += packetsVls;
+ this.vlsByPacketId.put(packetId, this.vlsByPacketId.getOrDefault(packetId, 0.0) + packetsVls);
+
+ switch (reason) {
+ case SIZE: {
+ this.packetsVlsSize += packetsVls;
+ break;
+ }
+ case RATE: {
+ this.packetsVlsRate += packetsVls;
+ break;
+ }
+ default: {
+ break;
+ }
+ }
+ }
+
+ public boolean isCancelled() {
+ return cancelled;
+ }
+
+ public void setCancelled(boolean cancelled) {
+ this.cancelled = cancelled;
+ }
+
+ public double getPacketsVlsSize() {
+ return packetsVlsSize;
+ }
+
+ public double getPacketsVlsRate() {
+ return packetsVlsRate;
+ }
+}
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/PasswordCheck.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/PasswordCheck.java
new file mode 100644
index 000000000..82401d240
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/PasswordCheck.java
@@ -0,0 +1,62 @@
+package dev._2lstudios.antibot;
+package dev._2lstudios.flamecord.antibot;
+
+import java.net.SocketAddress;
+
@ -605,13 +846,13 @@ index 000000000..bdc024f58
+ return repeatCount;
+ }
+}
diff --git a/flamecord/src/main/java/dev/_2lstudios/antibot/RatelimitCheck.java b/flamecord/src/main/java/dev/_2lstudios/antibot/RatelimitCheck.java
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/RatelimitCheck.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/RatelimitCheck.java
new file mode 100644
index 000000000..b55b4bb17
index 000000000..0165d1bf8
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/antibot/RatelimitCheck.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/RatelimitCheck.java
@@ -0,0 +1,33 @@
+package dev._2lstudios.antibot;
+package dev._2lstudios.flamecord.antibot;
+
+import java.net.SocketAddress;
+
@ -644,13 +885,13 @@ index 000000000..b55b4bb17
+ return false;
+ }
+}
diff --git a/flamecord/src/main/java/dev/_2lstudios/antibot/ReconnectCheck.java b/flamecord/src/main/java/dev/_2lstudios/antibot/ReconnectCheck.java
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/ReconnectCheck.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/ReconnectCheck.java
new file mode 100644
index 000000000..efd8d2cac
index 000000000..68cc4c217
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/antibot/ReconnectCheck.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/ReconnectCheck.java
@@ -0,0 +1,46 @@
+package dev._2lstudios.antibot;
+package dev._2lstudios.flamecord.antibot;
+
+import java.net.SocketAddress;
+
@ -696,62 +937,11 @@ index 000000000..efd8d2cac
+ return false;
+ }
+}
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java
index c78ab3a7c..8591a7918 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java
@@ -3,6 +3,8 @@ package dev._2lstudios.flamecord;
import java.util.Collection;
import java.util.logging.Logger;
+import dev._2lstudios.antibot.AddressDataManager;
+import dev._2lstudios.antibot.CheckManager;
import dev._2lstudios.flamecord.configuration.FlameCordConfiguration;
import dev._2lstudios.flamecord.configuration.MessagesConfiguration;
import dev._2lstudios.flamecord.configuration.ModulesConfiguration;
@@ -18,26 +20,31 @@ public class FlameCord {
if (FlameCord.instance != null) {
instance.reload(logger);
} else {
- FlameCord.instance = new FlameCord(logger, whitelistedAddresses);
+ FlameCord.instance = new FlameCord();
+ instance.reload(logger);
}
}
@Getter
private FlameCordConfiguration flameCordConfiguration;
@Getter
+ private AddressDataManager addressDataManager;
+ @Getter
+ private CheckManager checkManager;
+ @Getter
private ModulesConfiguration modulesConfiguration;
@Getter
private MessagesConfiguration messagesConfiguration;
private void reload(final Logger logger) {
final ConfigurationProvider configurationProvider = ConfigurationProvider.getProvider(YamlConfiguration.class);
+
+ if (checkManager != null) checkManager.unload();
this.flameCordConfiguration = new FlameCordConfiguration(configurationProvider);
this.modulesConfiguration = new ModulesConfiguration(configurationProvider);
this.messagesConfiguration = new MessagesConfiguration(logger, configurationProvider);
- }
-
- private FlameCord(final Logger logger, final Collection<String> whitelistedAddresses) {
- reload(logger);
+ this.addressDataManager = new AddressDataManager();
+ this.checkManager = new CheckManager(addressDataManager, flameCordConfiguration);
}
}
\ No newline at end of file
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 a1d23f74d..76c35626d 100644
index a1d23f74d..1bd6b2164 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
@@ -16,6 +16,120 @@ import net.md_5.bungee.config.Configuration;
@@ -16,6 +16,157 @@ import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
public class FlameCordConfiguration extends FlameConfig {
@ -829,36 +1019,65 @@ index a1d23f74d..76c35626d 100644
+ @Getter
+ private boolean antibotReconnectLog = true;
+
+ // Antibot packets
+ @Getter
+ private boolean antibotPacketsEnabled = true;
+ @Getter
+ private boolean antibotPacketsLog = true;
+ @Getter
+ private double antibotPacketsVlsPerByte = 0.00001;
+ @Getter
+ private double antibotPacketsVlsPerPacket = 0.01;
+ @Getter
+ private double antibotPacketsVlsToKick = 100;
+ @Getter
+ private double antibotPacketsVlsToCancel = 25;
+
+ public void loadAntibot(final Configuration config) {
+ // Antibot accounts
+ this.antibotAccountsEnabled = setIfUnexistant("antibot.accounts.enabled", this.antibotAccountsEnabled, config);
+ this.antibotAccountsFirewall = setIfUnexistant("antibot.accounts.firewall", this.antibotAccountsFirewall, config);
+ this.antibotAccountsLimit = setIfUnexistant("antibot.accounts.limit", this.antibotAccountsLimit, config);
+ this.antibotAccountsLog = setIfUnexistant("antibot.accounts.log", this.antibotAccountsLog, config);
+
+ // Antibot country
+ this.antibotCountryEnabled = setIfUnexistant("antibot.country.enabled", this.antibotCountryEnabled, config);
+ this.antibotCountryFirewall = setIfUnexistant("antibot.country.firewall", this.antibotCountryFirewall, config);
+ this.antibotCountryBlacklist = setIfUnexistant("antibot.country.blacklist", this.antibotCountryBlacklist, config);
+ this.antibotCountryLog = setIfUnexistant("antibot.country.log", this.antibotCountryLog, config);
+
+ // Antibot fastchat
+ this.antibotFastChatEnabled = setIfUnexistant("antibot.fastchat.enabled", this.antibotFastChatEnabled, config);
+ this.antibotFastChatFirewall = setIfUnexistant("antibot.fastchat.firewall", this.antibotFastChatFirewall, config);
+ this.antibotFastChatTime = setIfUnexistant("antibot.fastchat.time", this.antibotFastChatTime, config);
+ this.antibotFastChatLog = setIfUnexistant("antibot.fastchat.log", this.antibotFastChatLog, config);
+
+ // Antibot firewall
+ this.antibotFirewallEnabled = setIfUnexistant("antibot.firewall.enabled", this.antibotFirewallEnabled, config);
+ this.antibotFirewalledExceptions = setIfUnexistant("antibot.firewall.exceptions", this.antibotFirewalledExceptions, config);
+ this.antibotFirewallExpire = setIfUnexistant("antibot.firewall.time", this.antibotFirewallExpire, config);
+ this.antibotFirewallLog = setIfUnexistant("antibot.firewall.log", this.antibotFirewallLog, config);
+
+ // Antibot nickname
+ this.antibotNicknameEnabled = setIfUnexistant("antibot.nickname.enabled", this.antibotNicknameEnabled, config);
+ this.antibotNicknameFirewall = setIfUnexistant("antibot.nickname.firewall", this.antibotNicknameFirewall, config);
+ this.antibotNicknameBlacklist = setIfUnexistant("antibot.nickname.blacklist", this.antibotNicknameBlacklist, config);
+ this.antibotNicknameLog = setIfUnexistant("antibot.nickname.log", this.antibotNicknameLog, config);
+
+ // Antibot password
+ this.antibotPasswordEnabled = setIfUnexistant("antibot.password.enabled", this.antibotPasswordEnabled, config);
+ this.antibotPasswordFirewall = setIfUnexistant("antibot.password.firewall", this.antibotPasswordFirewall, config);
+ this.antibotPasswordLimit = setIfUnexistant("antibot.password.limit", this.antibotPasswordLimit, config);
+ this.antibotPasswordLog = setIfUnexistant("antibot.password.log", this.antibotPasswordLog, config);
+
+ // Antibot ratelimit
+ this.antibotRatelimitEnabled = setIfUnexistant("antibot.ratelimit.enabled", this.antibotRatelimitEnabled, config);
+ this.antibotRatelimitFirewall = setIfUnexistant("antibot.ratelimit.firewall", this.antibotRatelimitFirewall, config);
+ this.antibotRatelimitConnectionsPerSecond = setIfUnexistant("antibot.ratelimit.connections-per-second", this.antibotRatelimitConnectionsPerSecond, config);
+ this.antibotRatelimitPingsPerSecond = setIfUnexistant("antibot.ratelimit.pings-per-second", this.antibotRatelimitPingsPerSecond, config);
+ this.antibotRatelimitLog = setIfUnexistant("antibot.ratelimit.log", this.antibotRatelimitLog, config);
+
+ // Antibot reconnect
+ this.antibotReconnectEnabled = setIfUnexistant("antibot.reconnect.enabled", this.antibotReconnectEnabled, config);
+ this.antibotReconnectAttempts = setIfUnexistant("antibot.reconnect.attempts", this.antibotReconnectAttempts, config);
+ this.antibotReconnectPings = setIfUnexistant("antibot.reconnect.pings", this.antibotReconnectPings, config);
@ -866,13 +1085,21 @@ index a1d23f74d..76c35626d 100644
+ this.antibotReconnectConnectionThreshold = setIfUnexistant("antibot.reconnect.connection-threshold", this.antibotReconnectConnectionThreshold, config);
+ this.antibotReconnectConnectionThresholdLimit = setIfUnexistant("antibot.reconnect.connection-threshold-limit", this.antibotReconnectConnectionThresholdLimit, config);
+ this.antibotReconnectLog = setIfUnexistant("antibot.reconnect.log", this.antibotReconnectLog, config);
+
+ // Antibot packets
+ this.antibotPacketsEnabled = setIfUnexistant("antibot.packets.enabled", this.antibotPacketsEnabled, config);
+ this.antibotPacketsLog = setIfUnexistant("antibot.packets.log", this.antibotPacketsLog, config);
+ this.antibotPacketsVlsPerByte = setIfUnexistant("antibot.packets.vls-per-byte", this.antibotPacketsVlsPerByte, config);
+ this.antibotPacketsVlsPerPacket = setIfUnexistant("antibot.packets.vls-per-packet", this.antibotPacketsVlsPerPacket, config);
+ this.antibotPacketsVlsToKick = setIfUnexistant("antibot.packets.vls-to-kick", this.antibotPacketsVlsToKick, config);
+ this.antibotPacketsVlsToCancel = setIfUnexistant("antibot.packets.vls-to-cancel", this.antibotPacketsVlsToCancel, config);
+ }
+ // FlameCord end - Antibot System
+
// FlameCord - TCP Fast Open
@Getter
private int tcpFastOpen = 3;
@@ -117,6 +231,8 @@ public class FlameCordConfiguration extends FlameConfig {
@@ -117,6 +268,8 @@ public class FlameCordConfiguration extends FlameConfig {
this.fakePlayersEnabled = setIfUnexistant("custom-motd.fakeplayers.enabled", this.fakePlayersEnabled, configuration);
this.fakePlayersAmount = setIfUnexistant("custom-motd.fakeplayers.amount", this.fakePlayersAmount, configuration);
this.fakePlayersMode = setIfUnexistant("custom-motd.fakeplayers.mode", this.fakePlayersMode, configuration);
@ -913,18 +1140,155 @@ index 4f306660e..5faab6166 100644
configurationProvider.save(configuration, configurationFile);
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/enums/PacketsCheckResult.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/enums/PacketsCheckResult.java
new file mode 100644
index 000000000..53f1648ab
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/enums/PacketsCheckResult.java
@@ -0,0 +1,5 @@
+package dev._2lstudios.flamecord.enums;
+
+public enum PacketsCheckResult {
+ KICK, FIRST_CANCEL, CANCEL, NONE
+}
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/enums/PacketsViolationReason.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/enums/PacketsViolationReason.java
new file mode 100644
index 000000000..c19c4965d
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/enums/PacketsViolationReason.java
@@ -0,0 +1,5 @@
+package dev._2lstudios.flamecord.enums;
+
+public enum PacketsViolationReason {
+ SIZE, RATE
+}
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/ProtocolUtil.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/ProtocolUtil.java
new file mode 100644
index 000000000..7f26e7a0d
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/ProtocolUtil.java
@@ -0,0 +1,27 @@
+package dev._2lstudios.flamecord.utils;
+
+import io.netty.buffer.ByteBuf;
+
+public class ProtocolUtil {
+ private static int SEGMENT_BITS = 0x7F;
+ private static int CONTINUE_BIT = 0x80;
+
+ public static int readVarInt(ByteBuf byteBuf) {
+ int value = 0;
+ int position = 0;
+ byte currentByte;
+
+ while (byteBuf.isReadable()) {
+ currentByte = byteBuf.readByte();
+ value |= (currentByte & SEGMENT_BITS) << position;
+
+ if ((currentByte & CONTINUE_BIT) == 0) break;
+
+ position += 7;
+
+ if (position >= 32) throw new RuntimeException("VarInt is too big");
+ }
+
+ return value;
+ }
+}
\ 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 6316143f7..209e4f143 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
@@ -51,12 +51,46 @@ public class MinecraftDecoder extends MessageToMessageDecoder<ByteBuf>
throw new FastDecoderException("Error decoding packet with too big capacity: " + capacity);
}
}
+
+ // FlameCord start - Antibot Packet Check
+ if (prot == protocol.TO_SERVER) {
+ dev._2lstudios.flamecord.enums.PacketsCheckResult result = FlameCord.getInstance().getCheckManager().getPacketsCheck()
+ .check(ctx.channel().remoteAddress(), in);
+
+ switch (result) {
+ case KICK:
+ if (FlameCord.getInstance().getFlameCordConfiguration().isAntibotPacketsLog()) {
+ System.out
+ .println("[FlameCord] [" + ctx.channel().remoteAddress()
+ + "] was kicked because of too many packets");
+ }
+
+ in.skipBytes(in.readableBytes());
+ ctx.close();
+ return;
+ case CANCEL:
+ if (FlameCord.getInstance().getFlameCordConfiguration().isAntibotPacketsLog()) {
+ System.out
+ .println("[FlameCord] [" + ctx.channel().remoteAddress()
+ + "] was cancelled because of too many packets");
+ }
+
+ in.skipBytes(in.readableBytes());
+ return;
+ default:
+ break;
+ }
+ }
+ // FlameCord end - Antibot Packet Check
ByteBuf slice = in.duplicate(); // FlameCord - Duplicate buf instead of Copy
Object packetTypeInfo = null;
try
{
+ // FlameCord - Duplicate buf instead of Copy
+ slice = in.duplicate(); // Can't slice this one due to EntityMap :(
+
// Waterfall start
if (in.readableBytes() == 0 && !server) {
return;
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java b/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java
index c9e45b915..022f94b2d 100644
--- a/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java
@@ -723,4 +723,8 @@ public enum Protocol
// Waterfall end
}
}
+
+ public DirectionData getToServer() {
+ return TO_SERVER;
+ }
}
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/Varint21FrameDecoder.java b/protocol/src/main/java/net/md_5/bungee/protocol/Varint21FrameDecoder.java
index c0d371426..403ccba98 100644
--- a/protocol/src/main/java/net/md_5/bungee/protocol/Varint21FrameDecoder.java
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/Varint21FrameDecoder.java
@@ -5,11 +5,11 @@ import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.codec.CorruptedFrameException;
+
import java.util.List;
public class Varint21FrameDecoder extends ByteToMessageDecoder
{
-
private static boolean DIRECT_WARNING;
@Override
diff --git a/proxy/src/main/java/dev/_2lstudios/flamecord/commands/FlameCordCommand.java b/proxy/src/main/java/dev/_2lstudios/flamecord/commands/FlameCordCommand.java
index cc76325b2..ae5d4c73f 100644
index cc76325b2..a5b9331f6 100644
--- a/proxy/src/main/java/dev/_2lstudios/flamecord/commands/FlameCordCommand.java
+++ b/proxy/src/main/java/dev/_2lstudios/flamecord/commands/FlameCordCommand.java
@@ -3,6 +3,7 @@ package dev._2lstudios.flamecord.commands;
import java.util.Collection;
@@ -4,6 +4,7 @@ import java.util.Collection;
import java.util.HashSet;
+import dev._2lstudios.antibot.AddressDataManager;
import dev._2lstudios.flamecord.FlameCord;
+import dev._2lstudios.flamecord.antibot.AddressDataManager;
import dev._2lstudios.flamecord.configuration.MessagesConfiguration;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.CommandSender;
@@ -27,9 +28,7 @@ private final BungeeCord bungeeCord;
if (sender.hasPermission("flamecord.usage")) {
@ -974,19 +1338,20 @@ index cc76325b2..ae5d4c73f 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 c00ab4b6a..089cac669 100644
index c00ab4b6a..bbf9c3dba 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
@@ -21,6 +21,8 @@ import java.util.logging.Level;
import javax.crypto.SecretKey;
@@ -22,7 +22,8 @@ import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
+import dev._2lstudios.antibot.AddressData;
+import dev._2lstudios.antibot.CheckManager;
import dev._2lstudios.flamecord.FlameCord;
-
+import dev._2lstudios.flamecord.antibot.AddressData;
+import dev._2lstudios.flamecord.antibot.CheckManager;
import dev._2lstudios.flamecord.configuration.FlameConfig;
@@ -439,6 +441,11 @@ public class InitialHandler extends PacketHandler implements PendingConnection
import dev._2lstudios.flamecord.configuration.FlameCordConfiguration;
import lombok.Getter;
@@ -439,6 +440,11 @@ public class InitialHandler extends PacketHandler implements PendingConnection
return;
}
@ -998,7 +1363,7 @@ index c00ab4b6a..089cac669 100644
switch ( handshake.getRequestedProtocol() )
{
case 1:
@@ -450,6 +457,22 @@ public class InitialHandler extends PacketHandler implements PendingConnection
@@ -450,6 +456,22 @@ public class InitialHandler extends PacketHandler implements PendingConnection
}
thisState = State.STATUS;
ch.setProtocol( Protocol.STATUS );
@ -1021,7 +1386,7 @@ index c00ab4b6a..089cac669 100644
break;
case 2:
// Login
@@ -461,6 +484,21 @@ public class InitialHandler extends PacketHandler implements PendingConnection
@@ -461,6 +483,21 @@ public class InitialHandler extends PacketHandler implements PendingConnection
thisState = State.USERNAME;
ch.setProtocol( Protocol.LOGIN );
@ -1043,7 +1408,7 @@ index c00ab4b6a..089cac669 100644
if ( !ProtocolConstants.SUPPORTED_VERSION_IDS.contains( handshake.getProtocolVersion() ) )
{
if ( handshake.getProtocolVersion() > bungee.getProtocolVersion() )
@@ -525,6 +563,58 @@ public class InitialHandler extends PacketHandler implements PendingConnection
@@ -525,6 +562,58 @@ public class InitialHandler extends PacketHandler implements PendingConnection
return;
}
@ -1103,7 +1468,7 @@ index c00ab4b6a..089cac669 100644
// We can just check by UUID here as names are based on UUID
if ( !isOnlineMode() && bungee.getPlayer( getUniqueId() ) != null )
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java
index 66332af4e..7b852ff69 100644
index 66332af4e..289cce0c3 100644
--- a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java
+++ b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java
@@ -4,11 +4,16 @@ import com.google.common.base.Preconditions;
@ -1111,8 +1476,8 @@ index 66332af4e..7b852ff69 100644
import com.mojang.brigadier.suggestion.Suggestion;
import com.mojang.brigadier.suggestion.Suggestions;
+
+import dev._2lstudios.antibot.CheckManager;
+import dev._2lstudios.flamecord.FlameCord;
+import dev._2lstudios.flamecord.antibot.CheckManager;
import io.netty.channel.Channel;
import java.util.ArrayList;
import java.util.LinkedList;

View File

@ -1,11 +1,11 @@
From 9221f376964681108d3a1f6a899313fc860c01d9 Mon Sep 17 00:00:00 2001
From 152a7b67bbe619c2933d6ee4c486a7a5314fd3da Mon Sep 17 00:00:00 2001
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Fri, 4 Mar 2022 14:09:35 -0300
Subject: [PATCH] Allow Invalid Names
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 76c35626d..1c27409d3 100644
index 1bd6b2164..d8bc8980f 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
@@ -16,6 +16,10 @@ import net.md_5.bungee.config.Configuration;
@ -19,7 +19,7 @@ index 76c35626d..1c27409d3 100644
// FlameCord start - Antibot System
@Getter
private boolean antibotAccountsEnabled = true;
@@ -231,6 +235,8 @@ public class FlameCordConfiguration extends FlameConfig {
@@ -268,6 +272,8 @@ public class FlameCordConfiguration extends FlameConfig {
this.fakePlayersEnabled = setIfUnexistant("custom-motd.fakeplayers.enabled", this.fakePlayersEnabled, configuration);
this.fakePlayersAmount = setIfUnexistant("custom-motd.fakeplayers.amount", this.fakePlayersAmount, configuration);
this.fakePlayersMode = setIfUnexistant("custom-motd.fakeplayers.mode", this.fakePlayersMode, configuration);
@ -29,10 +29,10 @@ index 76c35626d..1c27409d3 100644
this.tcpFastOpen = setIfUnexistant("tcp-fast-open", this.tcpFastOpen, 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 089cac669..91648b499 100644
index bbf9c3dba..952b2a363 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
@@ -522,7 +522,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
@@ -521,7 +521,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
Preconditions.checkState( thisState == State.USERNAME, "Not expecting USERNAME" );
thisState = State.PROCESSING_USERNAME;

View File

@ -1,4 +1,4 @@
From 48878ec51074a1a90d1c4aa761a40fbec74bd8ac Mon Sep 17 00:00:00 2001
From 878867854391af17739c536b7db5c0992c8fcf84 Mon Sep 17 00:00:00 2001
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Tue, 15 Nov 2022 18:07:27 +0100
Subject: [PATCH] Only show connection fail reason when detailed logger is
@ -6,7 +6,7 @@ Subject: [PATCH] Only show connection fail reason when detailed logger is
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 f3d60253..021fe839 100644
index f3d60253f..021fe8398 100644
--- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java
+++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
@@ -405,8 +405,10 @@ public final class UserConnection implements ProxiedPlayer
@ -22,5 +22,5 @@ index f3d60253..021fe839 100644
@Override
--
2.29.2.windows.2
2.37.3.windows.1

View File

@ -1,224 +0,0 @@
From 07f1032863acec085e88e6411ba2d4e1906f959e Mon Sep 17 00:00:00 2001
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Mon, 31 Oct 2022 17:00:58 +0100
Subject: [PATCH] Safe bytebuf release
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 9a7bf9b59..b43ebc8d6 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
@@ -31,33 +31,34 @@ public class MinecraftDecoder extends MessageToMessageDecoder<ByteBuf>
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception
{
- // See Varint21FrameDecoder for the general reasoning. We add this here as ByteToMessageDecoder#handlerRemoved()
- // will fire any cumulated data through the pipeline, so we want to try and stop it here.
- if ( !ctx.channel().isActive() || !in.isReadable() ) // FlameCord - Check if connection is readable
- {
- return;
- }
+ // FlameCord - Safe bytebuf release
+ Object packetTypeInfo = null;
+ ByteBuf slice = null;
+ try {
+ // See Varint21FrameDecoder for the general reasoning. We add this here as ByteToMessageDecoder#handlerRemoved()
+ // will fire any cumulated data through the pipeline, so we want to try and stop it here.
+ if ( !ctx.channel().isActive() || !in.isReadable() ) // FlameCord - Check if connection is readable
+ {
+ return;
+ }
- Protocol.DirectionData prot = ( server ) ? protocol.TO_SERVER : protocol.TO_CLIENT;
-
- // FlameCord - Check size before decoding
- if (prot == protocol.TO_SERVER) {
- final int readableBytes = in.readableBytes();
- final int capacity = in.capacity();
-
- if (readableBytes > 2097152) {
- throw new FastDecoderException("Error decoding packet with too many readableBytes: " + readableBytes);
- } else if (capacity > 2097152) {
- throw new FastDecoderException("Error decoding packet with too big capacity: " + capacity);
+ Protocol.DirectionData prot = ( server ) ? protocol.TO_SERVER : protocol.TO_CLIENT;
+
+ // FlameCord - Check size before decoding
+ if (prot == protocol.TO_SERVER) {
+ final int readableBytes = in.readableBytes();
+ final int capacity = in.capacity();
+
+ if (readableBytes > 2097152) {
+ throw new FastDecoderException("Error decoding packet with too many readableBytes: " + readableBytes);
+ } else if (capacity > 2097152) {
+ throw new FastDecoderException("Error decoding packet with too big capacity: " + capacity);
+ }
}
- }
- // FlameCord - Duplicate buf instead of Copy
- ByteBuf slice = in.duplicate(); // Can't slice this one due to EntityMap :(
+ // FlameCord - Duplicate buf instead of Copy
+ slice = in.duplicate(); // Can't slice this one due to EntityMap :(
- Object packetTypeInfo = null;
- try
- {
// Waterfall start
if (in.readableBytes() == 0 && !server) {
return;
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 a63e67f15..4293e2b49 100644
--- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
+++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
@@ -286,10 +286,15 @@ public class ServerConnector extends PacketHandler
user.unsafe().sendPacket( new PluginMessage( "MC|Brand", brandString.getBytes( StandardCharsets.UTF_8 ), handshakeHandler.isServerForge() ) );
} 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();
+ // FlameCord - Safe bytebuf release
+ ByteBuf brand = null;
+ try {
+ 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() ) );
+ } finally {
+ if (brand != null) brand.release();
+ }
}
// FlameCord end - 1.7.x support
}
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 6e425764b..e7fe0d02b 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
@@ -307,13 +307,24 @@ 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();
+ // FlameCord - Safe bytebuf release
+ ByteBuf brand = null;
+ String serverBrand;
+ try {
+ brand = Unpooled.wrappedBuffer(pluginMessage.getData());
+ serverBrand = DefinedPacket.readString(brand);
+ } finally {
+ if (brand != null) brand.release();
+ }
+
+ // FlameCord - Safe bytebuf release
+ try {
+ brand = ByteBufAllocator.DEFAULT.heapBuffer();
+ DefinedPacket.writeString(bungee.getName() + " <- " + serverBrand, brand ); // Waterfall
+ pluginMessage.setData(brand);
+ } finally {
+ if (brand != null) brand.release();
+ }
} catch (Exception ProtocolHacksSuck)
{
return;
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 abca28bd7..2fd37c2dd 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
@@ -84,46 +84,44 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
{
- // FlameCord - Return if channel isn't active
- if (!ctx.channel().isActive()) {
- if (msg instanceof PacketWrapper) {
- ((PacketWrapper) msg).trySingleRelease();
+ // FlameCord - Safe bytebuf release
+ try
+ {
+ // FlameCord - Return if channel isn't active
+ if (!ctx.channel().isActive()) {
+ return;
}
- return;
- }
-
- if ( msg instanceof HAProxyMessage )
- {
- HAProxyMessage proxy = (HAProxyMessage) msg;
- try
+ if ( msg instanceof HAProxyMessage )
{
- if ( proxy.sourceAddress() != null )
+ HAProxyMessage proxy = (HAProxyMessage) msg;
+ try
{
- InetSocketAddress newAddress = new InetSocketAddress( proxy.sourceAddress(), proxy.sourcePort() );
+ if ( proxy.sourceAddress() != null )
+ {
+ InetSocketAddress newAddress = new InetSocketAddress( proxy.sourceAddress(), proxy.sourcePort() );
- // FlameCord - Option to log haproxy
- if ( FlameCord.getInstance().getFlameCordConfiguration().isLoggerHaProxy() )
- ProxyServer.getInstance().getLogger().log( Level.FINE, "Set remote address via PROXY {0} -> {1}", new Object[]
- {
- channel.getRemoteAddress(), newAddress
- } );
+ // FlameCord - Option to log haproxy
+ 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 );
+ channel.setRemoteAddress( newAddress );
+ }
+ } finally
+ {
+ proxy.release();
}
- } finally
- {
- proxy.release();
+ return;
}
- return;
- }
- if ( handler != null )
- {
PacketWrapper packet = (PacketWrapper) msg;
- boolean sendPacket = handler.shouldHandle( packet );
- try
+
+ if ( handler != null )
{
+ boolean sendPacket = handler.shouldHandle( packet );
if ( sendPacket && packet.packet != null )
{
try
@@ -138,9 +136,11 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
{
handler.handle( packet );
}
- } finally
- {
- packet.trySingleRelease();
+ }
+ } finally
+ {
+ if (msg instanceof PacketWrapper) {
+ ((PacketWrapper) msg).trySingleRelease();
}
}
}
--
2.37.3.windows.1