mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
Update upstrean CB/S
This commit is contained in:
parent
4bf0ca21fe
commit
ca7a828688
@ -0,0 +1,46 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <1254957+zachbr@users.noreply.github.com>
|
||||
Date: Sun, 11 Sep 2016 14:30:57 -0500
|
||||
Subject: [PATCH] Configurable packet in spam threshold
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
@@ -0,0 +0,0 @@ public class PaperConfig {
|
||||
private static void bungeeOnlineMode() {
|
||||
bungeeOnlineMode = getBoolean("settings.bungee-online-mode", true);
|
||||
}
|
||||
+
|
||||
+ public static int packetInSpamThreshold = 300;
|
||||
+ private static void packetInSpamThreshold() {
|
||||
+ if (version < 11) {
|
||||
+ int oldValue = getInt("settings.play-in-use-item-spam-threshold", 300);
|
||||
+ set("settings.incoming-packet-spam-threshold", oldValue);
|
||||
+ }
|
||||
+ packetInSpamThreshold = getInt("settings.incoming-packet-spam-threshold", 300);
|
||||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
@@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
// Spigot start - limit place/interactions
|
||||
private int limitedPackets;
|
||||
private long lastLimitedPacket = -1;
|
||||
+ private static final int THRESHOLD = com.destroystokyo.paper.PaperConfig.packetInSpamThreshold; // Paper - Configurable threshold
|
||||
|
||||
private boolean checkLimit(long timestamp) {
|
||||
- if (lastLimitedPacket != -1 && timestamp - lastLimitedPacket < 30 && limitedPackets++ >= 4) {
|
||||
+ if (lastLimitedPacket != -1 && timestamp - lastLimitedPacket < THRESHOLD && limitedPackets++ >= 4) { // Paper
|
||||
return false;
|
||||
}
|
||||
|
||||
- if (lastLimitedPacket == -1 || timestamp - lastLimitedPacket >= 30) {
|
||||
+ if (lastLimitedPacket == -1 || timestamp - lastLimitedPacket >= THRESHOLD) { // Paper
|
||||
lastLimitedPacket = timestamp;
|
||||
limitedPackets = 0;
|
||||
return true;
|
||||
--
|
@ -66,8 +66,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+
|
||||
+ commands = new HashMap<String, Command>();
|
||||
+
|
||||
+ version = getInt("config-version", 10);
|
||||
+ set("config-version", 10);
|
||||
+ version = getInt("config-version", 11);
|
||||
+ set("config-version", 11);
|
||||
+ readConfig(PaperConfig.class, null);
|
||||
+ }
|
||||
+
|
||||
|
@ -1,82 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <1254957+zachbr@users.noreply.github.com>
|
||||
Date: Sat, 10 Sep 2016 21:40:51 -0500
|
||||
Subject: [PATCH] Rate limit PacketPlayInUseItem
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
@@ -0,0 +0,0 @@ public class PaperConfig {
|
||||
private static void bungeeOnlineMode() {
|
||||
bungeeOnlineMode = getBoolean("settings.bungee-online-mode", true);
|
||||
}
|
||||
+
|
||||
+ public static int playInUseItemThreshold = 300;
|
||||
+ private static void playInUseItemThreshold() {
|
||||
+ playInUseItemThreshold = getInt("settings.play-in-use-item-spam-threshold", 300);
|
||||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/PacketPlayInUseItem.java b/src/main/java/net/minecraft/server/PacketPlayInUseItem.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/PacketPlayInUseItem.java
|
||||
+++ b/src/main/java/net/minecraft/server/PacketPlayInUseItem.java
|
||||
@@ -0,0 +0,0 @@ public class PacketPlayInUseItem implements Packet<PacketListenerPlayIn> {
|
||||
private float d;
|
||||
private float e;
|
||||
private float f;
|
||||
+ public long timestamp; // Paper - Used for rate limiting
|
||||
|
||||
public PacketPlayInUseItem() {}
|
||||
|
||||
@@ -0,0 +0,0 @@ public class PacketPlayInUseItem implements Packet<PacketListenerPlayIn> {
|
||||
this.d = (float) packetdataserializer.readUnsignedByte() / 16.0F;
|
||||
this.e = (float) packetdataserializer.readUnsignedByte() / 16.0F;
|
||||
this.f = (float) packetdataserializer.readUnsignedByte() / 16.0F;
|
||||
+ this.timestamp = System.currentTimeMillis(); // Paper
|
||||
}
|
||||
|
||||
public void b(PacketDataSerializer packetdataserializer) throws IOException {
|
||||
@@ -0,0 +0,0 @@ public class PacketPlayInUseItem implements Packet<PacketListenerPlayIn> {
|
||||
packetdataserializer.writeByte((int) (this.d * 16.0F));
|
||||
packetdataserializer.writeByte((int) (this.e * 16.0F));
|
||||
packetdataserializer.writeByte((int) (this.f * 16.0F));
|
||||
+ this.timestamp = System.currentTimeMillis(); // Paper
|
||||
}
|
||||
|
||||
public void a(PacketListenerPlayIn packetlistenerplayin) {
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
@@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
||||
+ // Paper start - Rate limit UseItem as well, copied from Spigot implementation below in BlockPlace
|
||||
+ private long lastPlaceUse = -1;
|
||||
+ private int packetsUse = 0;
|
||||
+ private static final int THRESHOLD = com.destroystokyo.paper.PaperConfig.playInUseItemThreshold;
|
||||
+ // Paper end
|
||||
public void a(PacketPlayInUseItem packetplayinuseitem) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinuseitem, this, this.player.x());
|
||||
if (this.player.cj()) return; // CraftBukkit
|
||||
@@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
EnumDirection enumdirection = packetplayinuseitem.b();
|
||||
|
||||
this.player.resetIdleTimer();
|
||||
+
|
||||
+ // Paper start - Rate limit UseItem as well, copied from Spigot implementation below in BlockPlace
|
||||
+ if (lastPlaceUse != -1 && packetplayinuseitem.timestamp - lastPlaceUse < THRESHOLD && packetsUse++ >= 4) {
|
||||
+ return;
|
||||
+ } else if (packetplayinuseitem.timestamp - lastPlaceUse >= THRESHOLD || lastPlaceUse == -1) {
|
||||
+ lastPlaceUse = packetplayinuseitem.timestamp;
|
||||
+ packetsUse = 0;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
if (blockposition.getY() >= this.minecraftServer.getMaxBuildHeight() - 1 && (enumdirection == EnumDirection.UP || blockposition.getY() >= this.minecraftServer.getMaxBuildHeight())) {
|
||||
ChatMessage chatmessage = new ChatMessage("build.tooHigh", new Object[] { Integer.valueOf(this.minecraftServer.getMaxBuildHeight())});
|
||||
|
||||
--
|
@ -68,7 +68,6 @@ import NBTTagCompound
|
||||
import NBTTagList
|
||||
import PersistentScoreboard
|
||||
import PacketPlayInUseEntity
|
||||
import PacketPlayInUseItem
|
||||
import PacketPlayOutPlayerListHeaderFooter
|
||||
import PacketPlayOutScoreboardTeam
|
||||
import PacketPlayOutTitle
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 8788b79a48a324130c400658c13f8176787d742a
|
||||
Subproject commit 75a8885d1fbb8f1bb38ef3d6a0f03598893c01ed
|
@ -1 +1 @@
|
||||
Subproject commit 80fccb72715ba063c2ec0e038bf7ddb2599849ad
|
||||
Subproject commit 570526c2b4840753183aa81995ea81008238eeb2
|
Loading…
Reference in New Issue
Block a user