From 2f23e5cb9c4c1d2f50b0dd341df0dfbac05f8bdf Mon Sep 17 00:00:00 2001 From: nils Date: Fri, 10 Mar 2023 06:13:20 +0100 Subject: [PATCH] fix: Fix legacy ping passthough (#3601) --- .../geysermc/geyser/ping/GeyserLegacyPingPassthrough.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/geysermc/geyser/ping/GeyserLegacyPingPassthrough.java b/core/src/main/java/org/geysermc/geyser/ping/GeyserLegacyPingPassthrough.java index a69d9bc3e..bdbe2f760 100644 --- a/core/src/main/java/org/geysermc/geyser/ping/GeyserLegacyPingPassthrough.java +++ b/core/src/main/java/org/geysermc/geyser/ping/GeyserLegacyPingPassthrough.java @@ -79,7 +79,8 @@ public class GeyserLegacyPingPassthrough implements IGeyserPingPassthrough, Runn try (Socket socket = new Socket()) { String address = geyser.getConfig().getRemote().address(); int port = geyser.getConfig().getRemote().port(); - socket.connect(new InetSocketAddress(address, port), 5000); + InetSocketAddress endpoint = new InetSocketAddress(address, port); + socket.connect(endpoint, 5000); ByteArrayOutputStream byteArrayStream = new ByteArrayOutputStream(); try (DataOutputStream handshake = new DataOutputStream(byteArrayStream)) { @@ -103,7 +104,8 @@ public class GeyserLegacyPingPassthrough implements IGeyserPingPassthrough, Runn HAProxyProxiedProtocol.TCP4.byteValue() : HAProxyProxiedProtocol.TCP6.byteValue()); byte[] srcAddrBytes = NetUtil.createByteArrayFromIpAddressString( ((InetSocketAddress) socket.getLocalSocketAddress()).getAddress().getHostAddress()); - byte[] dstAddrBytes = NetUtil.createByteArrayFromIpAddressString(address); + byte[] dstAddrBytes = NetUtil.createByteArrayFromIpAddressString( + endpoint.getAddress().getHostAddress()); dataOutputStream.writeShort(srcAddrBytes.length + dstAddrBytes.length + 4); dataOutputStream.write(srcAddrBytes); dataOutputStream.write(dstAddrBytes);