From 1629334e711494bc95b1a09ff498d1c45b8d56b2 Mon Sep 17 00:00:00 2001 From: Dylan Keir Date: Wed, 27 Oct 2021 22:17:57 +0100 Subject: [PATCH] fix issue with signature verification due to erroneous event, 2.5.4 release --- .../handler/VelocityHandshakeHandler.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/net/tcpshield/tcpshield/velocity/handler/VelocityHandshakeHandler.java b/src/main/java/net/tcpshield/tcpshield/velocity/handler/VelocityHandshakeHandler.java index c90ebc6..7d166ef 100644 --- a/src/main/java/net/tcpshield/tcpshield/velocity/handler/VelocityHandshakeHandler.java +++ b/src/main/java/net/tcpshield/tcpshield/velocity/handler/VelocityHandshakeHandler.java @@ -20,26 +20,28 @@ public class VelocityHandshakeHandler { this.plugin = plugin; } - @Subscribe(order = PostOrder.FIRST) - public void onPreLogin(PreLoginEvent e) { - InboundConnection connection = e.getConnection(); - handleEvent(connection); - } + // Turns out this event sometimes passes erroneous hostnames + // which have the null bytes terminated as FML data which causes + // issues with the verification process. +// @Subscribe(order = PostOrder.FIRST) +// public void onPreLogin(PreLoginEvent e) { +// InboundConnection connection = e.getConnection(); +// handleEvent(connection, "onPreLogin"); +// } @Subscribe(order = PostOrder.FIRST) public void onHandshake(ConnectionHandshakeEvent e) { InboundConnection connection = e.getConnection(); - handleEvent(connection); + handleEvent(connection, "onHandshake"); } @Subscribe(order = PostOrder.FIRST) public void onProxyPing(ProxyPingEvent e) { InboundConnection connection = e.getConnection(); - handleEvent(connection); + handleEvent(connection, "onProxyPing"); } - - private void handleEvent(InboundConnection connection) { + private void handleEvent(InboundConnection connection, String debugSource) { VelocityPlayer player = new VelocityPlayer(connection); if (player.isLegacy()) { player.disconnect(); @@ -48,7 +50,7 @@ public class VelocityHandshakeHandler { VelocityPacket packet = new VelocityPacket(connection); - this.plugin.getDebugger().warn("Velocity: Raw player hostname: " + packet.getPayloadString()); + this.plugin.getDebugger().warn("Velocity: " + debugSource + " Raw player hostname: " + packet.getPayloadString()); try { plugin.getPacketHandler().handleHandshake(packet, player);