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

28 lines
1.7 KiB
Diff
Raw Normal View History

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
index 3fb87f80087747c6f888e8bb0bf3deb40aa9419e..50872f8d2a9046f7fee57b5d0e9c5af48927dafc 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
@@ -1598,13 +1598,14 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
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;