From c8e876bfe231781c38fcc98b09f4cb45c72a7168 Mon Sep 17 00:00:00 2001 From: tsuoihito Date: Thu, 30 Jun 2022 21:28:32 +1000 Subject: [PATCH] #3342: Fix sanitized address being not IP but hostname after InetSocketAddress#getHostName() --- proxy/src/main/java/net/md_5/bungee/util/AddressUtil.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/proxy/src/main/java/net/md_5/bungee/util/AddressUtil.java b/proxy/src/main/java/net/md_5/bungee/util/AddressUtil.java index 03dabe01..5d349b37 100644 --- a/proxy/src/main/java/net/md_5/bungee/util/AddressUtil.java +++ b/proxy/src/main/java/net/md_5/bungee/util/AddressUtil.java @@ -1,5 +1,6 @@ package net.md_5.bungee.util; +import com.google.common.base.Preconditions; import java.net.Inet6Address; import java.net.InetSocketAddress; import lombok.AccessLevel; @@ -11,7 +12,8 @@ public class AddressUtil public static String sanitizeAddress(InetSocketAddress addr) { - String string = addr.getHostString(); + Preconditions.checkArgument( !addr.isUnresolved(), "Unresolved address" ); + String string = addr.getAddress().getHostAddress(); // Remove IPv6 scope if present if ( addr.getAddress() instanceof Inet6Address )