aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0105-Configurable-packet-in-spam-threshold.patch
blob: 8fbef567c57656f03f14c2bc119780fd58dac8a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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 f8e38d3334eca60cd5abe1838b1f274a82c8ede5..bffff41f73b91c83fa35ebf34314cb6fdbfcb643 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1608,13 +1608,14 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
     // Spigot start - limit place/interactions
     private int limitedPackets;
     private long lastLimitedPacket = -1;
+    private static int getSpamThreshold() { return io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.incomingPacketThreshold; } // Paper - Configurable threshold
 
     private boolean checkLimit(long timestamp) {
-        if (this.lastLimitedPacket != -1 && timestamp - this.lastLimitedPacket < 30 && this.limitedPackets++ >= 4) {
+        if (this.lastLimitedPacket != -1 && timestamp - this.lastLimitedPacket < getSpamThreshold() && this.limitedPackets++ >= 8) { // Paper - Configurable threshold; raise packet limit to 8
             return false;
         }
 
-        if (this.lastLimitedPacket == -1 || timestamp - this.lastLimitedPacket >= 30) {
+        if (this.lastLimitedPacket == -1 || timestamp - this.lastLimitedPacket >= getSpamThreshold()) { // Paper - Configurable threshold
             this.lastLimitedPacket = timestamp;
             this.limitedPackets = 0;
             return true;