Paper/patches/server/0108-Configurable-packet-in-spam-threshold.patch

28 Zeilen
1.7 KiB
Diff

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Sun, 11 Sep 2016 14:30:57 -0500
Subject: [PATCH] Configurable packet in spam threshold
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
2023-09-22 22:13:57 +02:00
index d8a78412d2cfa6aff023ecc8e5cc2121767a9097..24bb821dce6e70cf3e8f9c8f757f2967672a8896 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
2023-09-22 22:13:57 +02:00
@@ -1505,13 +1505,14 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
2021-06-11 14:02:28 +02:00
// Spigot start - limit place/interactions
private int limitedPackets;
private long lastLimitedPacket = -1;
2023-06-09 01:44:17 +02:00
+ private static int getSpamThreshold() { return io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.incomingPacketThreshold; } // Paper - Configurable threshold
2021-06-11 14:02:28 +02:00
private boolean checkLimit(long timestamp) {
2021-06-12 08:02:49 +02:00
- if (this.lastLimitedPacket != -1 && timestamp - this.lastLimitedPacket < 30 && this.limitedPackets++ >= 4) {
2023-06-09 01:44:17 +02:00
+ if (this.lastLimitedPacket != -1 && timestamp - this.lastLimitedPacket < getSpamThreshold() && this.limitedPackets++ >= 8) { // Paper - Use threshold, raise packet limit to 8
2021-06-11 14:02:28 +02:00
return false;
}
2021-06-12 08:02:49 +02:00
- if (this.lastLimitedPacket == -1 || timestamp - this.lastLimitedPacket >= 30) {
2023-06-09 01:44:17 +02:00
+ if (this.lastLimitedPacket == -1 || timestamp - this.lastLimitedPacket >= getSpamThreshold()) { // Paper
2021-06-12 08:02:49 +02:00
this.lastLimitedPacket = timestamp;
this.limitedPackets = 0;
2021-06-11 14:02:28 +02:00
return true;