2022-12-22 01:56:04 +01:00
From a19efbabc81d28c8529c2c92fd351c71393bd710 Mon Sep 17 00:00:00 2001
2022-02-25 16:38:45 +01:00
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Fri, 25 Feb 2022 12:28:31 -0300
Subject: [PATCH] InitialHandler Processing State
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
2022-12-12 23:17:06 +01:00
index b340c7a55..c00ab4b6a 100644
2022-02-25 16:38:45 +01:00
--- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
+++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
2022-07-28 15:53:09 +02:00
@@ -132,12 +132,12 @@ public class InitialHandler extends PacketHandler implements PendingConnection
2022-02-25 16:38:45 +01:00
private enum State
{
- HANDSHAKE, STATUS, PING, USERNAME, ENCRYPT, FINISHING;
2022-02-25 23:32:55 +01:00
+ PROCESSING, PROCESSING_USERNAME, HANDSHAKE, STATUS, PING, USERNAME, ENCRYPT, FINISHING;
2022-02-25 16:38:45 +01:00
}
private boolean canSendKickMessage()
2022-02-28 15:45:17 +01:00
{
- return thisState == State.USERNAME || thisState == State.ENCRYPT || thisState == State.FINISHING;
+ return thisState == State.PROCESSING_USERNAME || thisState == State.USERNAME || thisState == State.ENCRYPT || thisState == State.FINISHING;
}
@Override
2022-07-28 15:53:09 +02:00
@@ -273,6 +273,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
2022-02-25 16:38:45 +01:00
public void handle(StatusRequest statusRequest) throws Exception
{
Preconditions.checkState( thisState == State.STATUS, "Not expecting STATUS" );
+ thisState = State.PROCESSING;
ServerInfo forced = AbstractReconnectHandler.getForcedHost( this );
2022-04-23 00:05:34 +02:00
final int protocol = ( ProtocolConstants.SUPPORTED_VERSION_IDS.contains( handshake.getProtocolVersion() ) ) ? handshake.getProtocolVersion() : bungee.getProtocolVersion();
2022-07-28 15:53:09 +02:00
@@ -395,6 +396,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
2022-02-25 16:38:45 +01:00
{
// FlameCord - Never accept invalid packets
Preconditions.checkState( thisState == State.PING, "Not expecting PING" );
+ thisState = State.PROCESSING;
unsafe.sendPacket( ping );
2022-07-28 15:53:09 +02:00
@@ -406,6 +408,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
2022-02-25 16:38:45 +01:00
public void handle(Handshake handshake) throws Exception
{
Preconditions.checkState( thisState == State.HANDSHAKE, "Not expecting HANDSHAKE" );
2022-02-26 03:45:36 +01:00
+ thisState = State.PROCESSING;
2022-02-25 16:38:45 +01:00
this.handshake = handshake;
ch.setVersion( handshake.getProtocolVersion() );
2022-12-12 23:17:06 +01:00
ch.getHandle().pipeline().remove( PipelineUtils.LEGACY_KICKER );
@@ -479,6 +482,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
2022-02-25 16:38:45 +01:00
public void handle(LoginRequest loginRequest) throws Exception
{
Preconditions.checkState( thisState == State.USERNAME, "Not expecting USERNAME" );
2022-02-26 03:45:36 +01:00
+ thisState = State.PROCESSING_USERNAME;
2022-02-25 16:38:45 +01:00
if ( !AllowedCharacters.isValidName( loginRequest.getData(), onlineMode ) )
{
2022-12-12 23:17:06 +01:00
@@ -815,14 +819,14 @@ public class InitialHandler extends PacketHandler implements PendingConnection
2022-02-25 23:32:55 +01:00
@Override
public void setOnlineMode(boolean onlineMode)
{
- Preconditions.checkState( thisState == State.USERNAME, "Can only set online mode status whilst state is username" );
+ Preconditions.checkState( thisState == State.USERNAME || thisState == State.PROCESSING_USERNAME, "Can only set online mode status whilst state is username" );
this.onlineMode = onlineMode;
}
@Override
public void setUniqueId(UUID uuid)
{
- Preconditions.checkState( thisState == State.USERNAME, "Can only set uuid while state is username" );
+ Preconditions.checkState( thisState == State.USERNAME || thisState == State.PROCESSING_USERNAME, "Can only set uuid while state is username" );
// FlameCord - Allow custom uuids even if onlineMode is true
this.uniqueId = uuid;
}
2022-02-25 16:38:45 +01:00
--
2022-10-31 17:06:55 +01:00
2.37.3.windows.1
2022-02-25 16:38:45 +01:00