mirror of
https://github.com/GeyserMC/GeyserConnect.git
synced 2025-06-26 06:15:21 +02:00
Add better redirection based on the clients connecting IP
This commit is contained in:
parent
34a5170f9b
commit
5c439cb2a3
2 changed files with 14 additions and 1 deletions
|
@ -46,6 +46,7 @@ import org.geysermc.connect.ui.UIHandler;
|
|||
import org.geysermc.connect.utils.Player;
|
||||
import org.geysermc.connector.entity.attribute.AttributeType;
|
||||
import org.geysermc.connector.network.BedrockProtocol;
|
||||
import org.geysermc.connector.network.session.auth.BedrockClientData;
|
||||
import org.geysermc.connector.utils.AttributeUtils;
|
||||
import org.geysermc.connector.utils.LanguageUtils;
|
||||
|
||||
|
@ -146,6 +147,9 @@ public class PacketHandler implements BedrockPacketHandler {
|
|||
player = new Player(extraData, session);
|
||||
masterServer.getPlayers().put(player.getXuid(), player);
|
||||
|
||||
// Store the full client data
|
||||
player.setClientData(OBJECT_MAPPER.convertValue(OBJECT_MAPPER.readTree(skinData.getPayload().toBytes()), BedrockClientData.class));
|
||||
|
||||
// Tell the client we have logged in successfully
|
||||
PlayStatusPacket playStatusPacket = new PlayStatusPacket();
|
||||
playStatusPacket.setStatus(PlayStatusPacket.Status.LOGIN_SUCCESS);
|
||||
|
|
|
@ -43,6 +43,7 @@ import org.geysermc.common.window.FormWindow;
|
|||
import org.geysermc.connect.MasterServer;
|
||||
import org.geysermc.connect.ui.FormID;
|
||||
import org.geysermc.connect.ui.UIHandler;
|
||||
import org.geysermc.connector.network.session.auth.BedrockClientData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -66,6 +67,9 @@ public class Player {
|
|||
@Setter
|
||||
private Server currentServer;
|
||||
|
||||
@Setter
|
||||
private BedrockClientData clientData;
|
||||
|
||||
public Player(JsonNode extraData, BedrockServerSession session) {
|
||||
this.xuid = extraData.get("XUID").asText();
|
||||
this.identity = UUID.fromString(extraData.get("identity").asText());
|
||||
|
@ -189,7 +193,12 @@ public class Player {
|
|||
* Send the player to the Geyser proxy server or straight to the bedrock server if it is
|
||||
*/
|
||||
public void connectToProxy() {
|
||||
String address = MasterServer.getInstance().getGeyserConnectConfig().getRemoteAddress();
|
||||
// Use the clients connecting IP then fallback to the remote address from config
|
||||
String address = clientData.getServerAddress().split(":")[0].trim();
|
||||
if (address.isEmpty()) {
|
||||
address = MasterServer.getInstance().getGeyserConnectConfig().getRemoteAddress();
|
||||
}
|
||||
|
||||
int port = MasterServer.getInstance().getGeyserConnectConfig().getGeyser().getPort();
|
||||
|
||||
if (currentServer.isBedrock()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue