Break up and make tab spam limits configurable

Due to the changes in 1.13, clients will send a tab completion request
for all bukkit commands in order to factor in the lack of support for
brigadier and provide backwards support in the API.

Craftbukkit, however; has moved the chat spam limiter to also interact
with the tab completion request, which while good for avoiding abuse,
causes 1.13 clients to easilly be kicked from a server in bukkit due
to this. Removing the spam limit could cause issues for servers, however,
there is no way for servers to manipulate this without blindly cancelling
kick events, which only causes additional complications. This also causes
issues in that the tab spam limit and chat share the same field but different
limits, meaning that a player having typed a long command may be kicked from
the server.

Splitting the field up and making it configurable allows for server owners
to take the burden of this into their own hand without having to rely on
plugins doing unsafe things.

This patch has been applied to 1.12.2 in order to allow people using
plugins which allow clients of newer versions to connect, this is
not a common practice, however is being done as a level of nicety
given the current status of 1.13
This commit is contained in:
Shane Freeder 2018-07-31 13:53:49 +01:00
parent a3db62f3c2
commit 81806abef6
No known key found for this signature in database
GPG Key ID: A3F61EA5A085289C
3 changed files with 76 additions and 5 deletions

View File

@ -1,4 +1,4 @@
From 341c685efb02986f52f829c1a7c56357ce0ad071 Mon Sep 17 00:00:00 2001
From 51c81d45776fa1901de554be33144437e447d69b Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Mon, 28 Mar 2016 21:22:26 -0400
Subject: [PATCH] EntityPathfindEvent
@ -6,7 +6,7 @@ Subject: [PATCH] EntityPathfindEvent
Fires when an Entity decides to start moving to a location.
diff --git a/src/main/java/net/minecraft/server/NavigationAbstract.java b/src/main/java/net/minecraft/server/NavigationAbstract.java
index cc44d30b5..3ac6f84d3 100644
index cc44d30b57..3ac6f84d35 100644
--- a/src/main/java/net/minecraft/server/NavigationAbstract.java
+++ b/src/main/java/net/minecraft/server/NavigationAbstract.java
@@ -4,7 +4,7 @@ import javax.annotation.Nullable;

View File

@ -1,11 +1,11 @@
From 046d1dbd3f9ea1948d7d1c66e188f5d1f142b382 Mon Sep 17 00:00:00 2001
From 6195d48cf4da471efb95da7898c7362fb3806877 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 7 May 2016 23:33:08 -0400
Subject: [PATCH] Don't save empty scoreboard teams to scoreboard.dat
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
index 430b5d0cd..011cbf5e3 100644
index 430b5d0cdc..011cbf5e31 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -225,4 +225,9 @@ public class PaperConfig {
@ -19,7 +19,7 @@ index 430b5d0cd..011cbf5e3 100644
+ }
}
diff --git a/src/main/java/net/minecraft/server/PersistentScoreboard.java b/src/main/java/net/minecraft/server/PersistentScoreboard.java
index c9c01fad9..89c8d045b 100644
index c9c01fad91..89c8d045b7 100644
--- a/src/main/java/net/minecraft/server/PersistentScoreboard.java
+++ b/src/main/java/net/minecraft/server/PersistentScoreboard.java
@@ -184,6 +184,7 @@ public class PersistentScoreboard extends PersistentBase {

View File

@ -0,0 +1,71 @@
From 04c3885b1efb9556ac76b285afae2aef2c14f03c Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Sun, 29 Jul 2018 05:02:15 +0100
Subject: [PATCH] Break up and make tab spam limits configurable
Due to the changes in 1.13, clients will send a tab completion request
for all bukkit commands in order to factor in the lack of support for
brigadier and provide backwards support in the API.
Craftbukkit, however; has moved the chat spam limiter to also interact
with the tab completion request, which while good for avoiding abuse,
causes 1.13 clients to easilly be kicked from a server in bukkit due
to this. Removing the spam limit could cause issues for servers, however,
there is no way for servers to manipulate this without blindly cancelling
kick events, which only causes additional complications. This also causes
issues in that the tab spam limit and chat share the same field but different
limits, meaning that a player having typed a long command may be kicked from
the server.
Splitting the field up and making it configurable allows for server owners
to take the burden of this into their own hand without having to rely on
plugins doing unsafe things.
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
index 5a17ce3d22..a5ff014e33 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -303,4 +303,11 @@ public class PaperConfig {
Bukkit.getLogger().log(Level.INFO, "Using Aikar's Alternative Luck Formula to apply Luck attribute to all loot pool calculations. See https://luckformula.emc.gs");
}
}
+
+ public static int tabSpamIncrement = 10;
+ public static int tabSpamLimit = 500;
+ private static void tabSpamLimiters() {
+ tabSpamIncrement = getInt("settings.spam-limiter.tab-spam-increment", tabSpamIncrement);
+ tabSpamLimit = getInt("settings.spam-limiter.tab-spam-limit", tabSpamLimit);
+ }
}
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index cc11527390..83d1baf33f 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -74,6 +74,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
// CraftBukkit start - multithreaded fields
private volatile int chatThrottle;
private static final AtomicIntegerFieldUpdater chatSpamField = AtomicIntegerFieldUpdater.newUpdater(PlayerConnection.class, "chatThrottle");
+ private final java.util.concurrent.atomic.AtomicInteger tabSpamLimiter = new java.util.concurrent.atomic.AtomicInteger(); // Paper - configurable tab spam limits
// CraftBukkit end
private int j;
private final IntHashMap<Short> k = new IntHashMap();
@@ -203,6 +204,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
this.minecraftServer.methodProfiler.b();
// CraftBukkit start
for (int spam; (spam = this.chatThrottle) > 0 && !chatSpamField.compareAndSet(this, spam, spam - 1); ) ;
+ if (tabSpamLimiter.get() > 0) tabSpamLimiter.getAndDecrement(); // Paper - split to seperate variable
/* Use thread-safe field access instead
if (this.chatThrottle > 0) {
--this.chatThrottle;
@@ -2281,7 +2283,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
// Paper start - async tab completion
public void a(PacketPlayInTabComplete packet) {
// CraftBukkit start
- if (chatSpamField.addAndGet(this, 10) > 500 && !this.minecraftServer.getPlayerList().isOp(this.player.getProfile())) {
+ if (tabSpamLimiter.addAndGet(com.destroystokyo.paper.PaperConfig.tabSpamIncrement) > com.destroystokyo.paper.PaperConfig.tabSpamLimit && !this.minecraftServer.getPlayerList().isOp(this.player.getProfile())) { // Paper start - split and make configurable
minecraftServer.postToMainThread(() -> this.disconnect(new ChatMessage("disconnect.spam", new Object[0])));
return;
}
--
2.18.0