From d29279285e49765727707fb70033f94f455f4074 Mon Sep 17 00:00:00 2001 From: Tad Hunt Date: Thu, 22 Sep 2022 22:54:50 -0600 Subject: [PATCH] This commit fixes https://github.com/LOOHP/Limbo/issues/51 "Incorrect Payload Received in KeepAlive packet for player" The problem is that in my setup (described in the issue linked above) the loohp-limbo server is receiving an unsolicited PacketInKeepAlive message prior to sending any out. This causes the payload validation check to fail, resulting in the connection then being closed. This commit changes the PacketInKeepAlive handler to ignore (other than logging) unsolicited KeepAlive messages rather than act on them. Possibly the logging is a bad idea unless it's limited to being suppressed via a debug flag... --- src/main/java/com/loohp/limbo/network/ClientConnection.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/loohp/limbo/network/ClientConnection.java b/src/main/java/com/loohp/limbo/network/ClientConnection.java index 1d7ef3f..a0713a6 100644 --- a/src/main/java/com/loohp/limbo/network/ClientConnection.java +++ b/src/main/java/com/loohp/limbo/network/ClientConnection.java @@ -613,8 +613,11 @@ public class ClientConnection extends Thread { processMoveEvent.consume(event, to); } } else if (packetIn instanceof PacketPlayInKeepAlive) { + long lastPayload = getLastKeepAlivePayLoad(); PacketPlayInKeepAlive alive = (PacketPlayInKeepAlive) packetIn; - if (alive.getPayload() != getLastKeepAlivePayLoad()) { + if (lastPayload == -1) { + Limbo.getInstance().getConsole().sendMessage("Unsolicited KeepAlive packet for player " + player.getName() + " (payload " + String.valueOf(alive.getPayload()) + ")"); + } else if (alive.getPayload() != lastPayload) { Limbo.getInstance().getConsole().sendMessage("Incorrect Payload received in KeepAlive packet for player " + player.getName()); break; }