From 7ab56d0ca06eadf60a889577e1bcea1e53787640 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Mon, 27 Jul 2020 17:24:04 -0400 Subject: [PATCH] Correctly populate the server address in the Forge case. Fixes #334 (correctly). --- .../connection/backend/VelocityServerConnection.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java index fc2902865..e2aaf7f74 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java @@ -27,6 +27,7 @@ import com.velocitypowered.proxy.server.VelocityRegisteredServer; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelFutureListener; +import java.net.InetSocketAddress; import java.nio.charset.StandardCharsets; import java.util.List; import java.util.concurrent.CompletableFuture; @@ -129,6 +130,7 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation, PlayerInfoForwarding forwardingMode = server.getConfiguration().getPlayerInfoForwardingMode(); // Initiate the handshake. + InetSocketAddress destAddress = registeredServer.getServerInfo().getAddress(); ProtocolVersion protocolVersion = proxyPlayer.getConnection().getNextProtocolVersion(); Handshake handshake = new Handshake(); handshake.setNextStatus(StateRegistry.LOGIN_ID); @@ -139,11 +141,11 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation, byte[] secret = server.getConfiguration().getForwardingSecret(); handshake.setServerAddress(createBungeeGuardForwardingAddress(secret)); } else if (proxyPlayer.getConnection().getType() == ConnectionTypes.LEGACY_FORGE) { - handshake.setServerAddress(handshake.getServerAddress() + HANDSHAKE_HOSTNAME_TOKEN); + handshake.setServerAddress(destAddress.getHostString() + HANDSHAKE_HOSTNAME_TOKEN); } else { - handshake.setServerAddress(registeredServer.getServerInfo().getAddress().getHostString()); + handshake.setServerAddress(destAddress.getHostString()); } - handshake.setPort(registeredServer.getServerInfo().getAddress().getPort()); + handshake.setPort(destAddress.getPort()); mc.delayedWrite(handshake); mc.setProtocolVersion(protocolVersion);