SpigotMC / BungeeCord

BungeeCord, the 6th in a generation of server portal suites. Efficiently proxies and maintains connections and transport between multiple Minecraft servers.
https://www.spigotmc.org/go/bungeecord
Other
1.58k stars 1.11k forks source link

LoginPayloadRequest should be forwarded to client in ServerConnector #3755

Closed Outfluencer closed 4 weeks ago

Outfluencer commented 1 month ago

Bungeecord version

-

Server version

-

Client version

No response

Bungeecord plugins

-

The bug

Right now the serverconnector always tells the server it doesnt know the login payload You can only send a LoginPayload to the client in login state, if the client is not in the right state, should we just send an normal payload and forward the clients reponse wrapped in a LoginPayloadResponse to the backend or reponse with empty data or bungee specific data?

Or any other ideas?

https://github.com/SpigotMC/BungeeCord/blob/6ea49962c57b5c69c93d857a66d39fe8248cc5ca/proxy/src/main/java/net/md_5/bungee/ServerConnector.java#L499

this line should be changed to

Protocol encodeProtocol = user.getCh().getEncodeProtocol();
// this will only work for the first server the player connects to
if ( encodeProtocol.TO_CLIENT.hasPacket( loginPayloadRequest.getClass(), user.getPendingConnection().getVersion() ) )
{
    user.getPendingConnection().sendData( loginPayloadRequest.getChannel(), loginPayloadRequest.getData() ).thenAccept( (data) -> ch.write( new LoginPayloadResponse( loginPayloadRequest.getId(), data ) ) );
} else
{
    // print warning bungee.getLogger().log( Level.WARNING, "{0} Can't forward LoginPayloadRequest, client is in the wrong state!", this );
    // ch.write( new LoginPayloadResponse( loginPayloadRequest.getId(), null ) )

    // or fake it with normal payload
    // send custom payload receive response and put it in LoginPayloadResponse and send it

    // or send bungee specific data ( a custom byte array to let the backend know we coulnt forward it)
}

anyways

Log output (links)

No response

Checking

Janmm14 commented 1 month ago

I think we should not alter the current behaviour. If mods want to support bungeecord, in new versions they should be able to figure it out using plugin messages in configuration state.