From c9a904ed17eb8d86ef8425c04900b5cf01d5d80c Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Thu, 26 Dec 2024 15:19:56 +0000 Subject: [PATCH] Fix keepalive logic resetting counter This would of actually arised in the client being kicked due to sending bad keepalive packets due to the erronious extra sending of keepalives too --- .../network/ServerCommonPacketListenerImpl.java.patch | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch index e21dc4c54b..af6cdd217d 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch @@ -95,7 +95,7 @@ } } -@@ -88,30 +_,117 @@ +@@ -88,30 +_,119 @@ public void handlePong(ServerboundPongPacket packet) { } @@ -208,15 +208,16 @@ Profiler.get().push("keepAlive"); long millis = Util.getMillis(); - if (!this.isSingleplayerOwner() && millis - this.keepAliveTime >= 15000L) { -- if (this.keepAlivePending) { -- this.disconnect(TIMEOUT_DISCONNECTION_MESSAGE); + // Paper start - give clients a longer time to respond to pings as per pre 1.12.2 timings + // This should effectively place the keepalive handling back to "as it was" before 1.12.2 + final long elapsedTime = millis - this.keepAliveTime; + if (!this.isSingleplayerOwner() && elapsedTime >= 15000L) { // use vanilla's 15000L between keep alive packets -+ if (this.keepAlivePending && !this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // check keepalive limit, don't fire if already disconnected + if (this.keepAlivePending) { +- this.disconnect(TIMEOUT_DISCONNECTION_MESSAGE); ++ if (!this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // check keepalive limit, don't fire if already disconnected ++ this.disconnect(TIMEOUT_DISCONNECTION_MESSAGE, org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT); // Paper - kick event cause ++ } + // Paper end - give clients a longer time to respond to pings as per pre 1.12.2 timings -+ this.disconnect(TIMEOUT_DISCONNECTION_MESSAGE, org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT); // Paper - kick event cause } else if (this.checkIfClosed(millis)) { this.keepAlivePending = true; this.keepAliveTime = millis;