Skip to content

Commit

Permalink
fix issue with signature verification due to erroneous event, 2.5.4 r…
Browse files Browse the repository at this point in the history
…elease
  • Loading branch information
DylanKeir committed Oct 27, 2021
1 parent 8cb66fc commit 1629334
Showing 1 changed file with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,28 @@ public VelocityHandshakeHandler(TCPShieldPlugin plugin) {
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();
Expand All @@ -48,7 +50,7 @@ private void handleEvent(InboundConnection connection) {

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);
Expand Down

0 comments on commit 1629334

Please sign in to comment.