Skip to content

Commit

Permalink
Log error when a packet has extra data
Browse files Browse the repository at this point in the history
  • Loading branch information
acrylic-style committed Aug 27, 2022
1 parent f69b301 commit 2b631c9
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,12 @@ public static void handleProxySide(ServerConnection server, byte[] rawData) {
ProxyMessageHandler<Message> handler = (ProxyMessageHandler<Message>) protocol.getHandler();
Message message = handler.read(server, in);
Objects.requireNonNull(message, "handler.read(in) returned null");
if (in.available() > 0) {
Logger.getCurrentLogger().error(
"Received extra data after message {} from server connection {}: {} of {} bytes remaining",
message, server, in.available(), data.length);
//throw new RuntimeException("Received extra data after message " + message + " from server connection " + server + ": " + in.available() + " of " + data.length + " bytes remaining");
}
handler.handle(server, message);
} catch (Exception | AssertionError e) {
Logger.getCurrentLogger().warn("Failed to handle plugin message from " + server, e);
Expand Down Expand Up @@ -274,6 +280,12 @@ public static void handleServerSide(@NotNull PacketSender sender, byte[] rawData
ServerMessageHandler<Message> handler = (ServerMessageHandler<Message>) protocol.getHandler();
Message message = handler.read(in);
Objects.requireNonNull(message, "handler.read(in) returned null");
if (in.available() > 0) {
Logger.getCurrentLogger().error(
"Received extra data after message {} from {}: {} of {} bytes remaining",
message, sender, in.available(), data.length);
//throw new RuntimeException("Received extra data after message " + message + " from " + sender + ": " + in.available() + " of " + data.length + " bytes remaining");
}
handler.handle(sender, message);
} catch (Exception | AssertionError e) {
Logger.getCurrentLogger().warn("Failed to handle plugin message from " + sender, e);
Expand Down

0 comments on commit 2b631c9

Please sign in to comment.