#3533: Don't put initial client in configure phase until server is ready

This commit is contained in:
md_5 2023-09-29 06:50:28 +10:00
parent b34cfcde5a
commit 78aef86a8f
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11
3 changed files with 19 additions and 22 deletions

View File

@ -43,7 +43,6 @@ import net.md_5.bungee.protocol.packet.GameState;
import net.md_5.bungee.protocol.packet.Handshake;
import net.md_5.bungee.protocol.packet.Kick;
import net.md_5.bungee.protocol.packet.Login;
import net.md_5.bungee.protocol.packet.LoginAcknowledged;
import net.md_5.bungee.protocol.packet.LoginPayloadRequest;
import net.md_5.bungee.protocol.packet.LoginPayloadResponse;
import net.md_5.bungee.protocol.packet.LoginRequest;
@ -334,9 +333,9 @@ public class ServerConnector extends PacketHandler
user.unsafe().sendPacket( new StartConfiguration() );
} else
{
ch.setDecodeProtocol( Protocol.CONFIGURATION );
ch.write( new LoginAcknowledged() );
ch.setEncodeProtocol( Protocol.CONFIGURATION );
LoginResult loginProfile = user.getPendingConnection().getLoginProfile();
user.unsafe().sendPacket( new LoginSuccess( user.getUniqueId(), user.getName(), ( loginProfile == null ) ? null : loginProfile.getProperties() ) );
user.getCh().setEncodeProtocol( Protocol.CONFIGURATION );
}
}

View File

@ -59,7 +59,6 @@ import net.md_5.bungee.protocol.packet.Handshake;
import net.md_5.bungee.protocol.packet.Kick;
import net.md_5.bungee.protocol.packet.LegacyHandshake;
import net.md_5.bungee.protocol.packet.LegacyPing;
import net.md_5.bungee.protocol.packet.LoginAcknowledged;
import net.md_5.bungee.protocol.packet.LoginPayloadResponse;
import net.md_5.bungee.protocol.packet.LoginRequest;
import net.md_5.bungee.protocol.packet.LoginSuccess;
@ -123,12 +122,12 @@ public class InitialHandler extends PacketHandler implements PendingConnection
private enum State
{
HANDSHAKE, STATUS, PING, USERNAME, ENCRYPT, FINISHING, CONFIGURING;
HANDSHAKE, STATUS, PING, USERNAME, ENCRYPT, FINISHING;
}
private boolean canSendKickMessage()
{
return thisState == State.USERNAME || thisState == State.ENCRYPT || thisState == State.FINISHING || thisState == State.CONFIGURING;
return thisState == State.USERNAME || thisState == State.ENCRYPT || thisState == State.FINISHING;
}
@Override
@ -598,15 +597,12 @@ public class InitialHandler extends PacketHandler implements PendingConnection
userCon = new UserConnection( bungee, ch, getName(), InitialHandler.this );
userCon.setCompressionThreshold( BungeeCord.getInstance().config.getCompressionThreshold() );
unsafe.sendPacket( new LoginSuccess( getUniqueId(), getName(), ( loginProfile == null ) ? null : loginProfile.getProperties() ) );
if ( getVersion() >= ProtocolConstants.MINECRAFT_1_20_2 )
{
thisState = State.CONFIGURING;
} else
if ( getVersion() < ProtocolConstants.MINECRAFT_1_20_2 )
{
unsafe.sendPacket( new LoginSuccess( getUniqueId(), getName(), ( loginProfile == null ) ? null : loginProfile.getProperties() ) );
ch.setProtocol( Protocol.GAME );
finish2();
}
finish2();
}
}
} );
@ -617,15 +613,6 @@ public class InitialHandler extends PacketHandler implements PendingConnection
bungee.getPluginManager().callEvent( new LoginEvent( InitialHandler.this, complete ) );
}
@Override
public void handle(LoginAcknowledged loginAcknowledged) throws Exception
{
Preconditions.checkState( thisState == State.CONFIGURING, "Not expecting CONFIGURING" );
ch.setEncodeProtocol( Protocol.CONFIGURATION );
finish2();
}
private void finish2()
{
userCon.init();

View File

@ -331,8 +331,19 @@ public class UpstreamBridge extends PacketHandler
con.getPendingConnection().relayMessage( pluginMessage );
}
@Override
public void handle(LoginAcknowledged loginAcknowledged) throws Exception
{
configureServer();
}
@Override
public void handle(StartConfiguration startConfiguration) throws Exception
{
configureServer();
}
private void configureServer()
{
ChannelWrapper ch = con.getServer().getCh();
if ( ch.getDecodeProtocol() == Protocol.LOGIN )