From 1823f86dbb84022c7eaf541c5a62b36c7b47a5e1 Mon Sep 17 00:00:00 2001 From: Outfluencer <48880402+Outfluencer@users.noreply.github.com> Date: Fri, 17 Sep 2021 18:16:01 +1000 Subject: [PATCH] #3190: Improve login protocol state machine Prevents repetition of packets --- .../net/md_5/bungee/connection/InitialHandler.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java index 916a0fef..f5238abc 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java @@ -115,12 +115,12 @@ public class InitialHandler extends PacketHandler implements PendingConnection private enum State { - HANDSHAKE, STATUS, PING, USERNAME, ENCRYPT, FINISHED; + HANDSHAKE, STATUS, PING, USERNAME, ENCRYPT, FINISHING; } private boolean canSendKickMessage() { - return thisState == State.USERNAME || thisState == State.ENCRYPT || thisState == State.FINISHED; + return thisState == State.USERNAME || thisState == State.ENCRYPT || thisState == State.FINISHING; } @Override @@ -392,12 +392,13 @@ public class InitialHandler extends PacketHandler implements PendingConnection } if ( onlineMode ) { + thisState = State.ENCRYPT; unsafe().sendPacket( request = EncryptionUtil.encryptRequest() ); } else { + thisState = State.FINISHING; finish(); } - thisState = State.ENCRYPT; } }; @@ -455,7 +456,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection } } }; - + thisState = State.FINISHING; HttpClient.get( authURL, ch.getHandle().eventLoop(), handler ); } @@ -542,8 +543,6 @@ public class InitialHandler extends PacketHandler implements PendingConnection } userCon.connect( server, null, true, ServerConnectEvent.Reason.JOIN_PROXY ); - - thisState = State.FINISHED; } } } );