#3342: Fix sanitized address being not IP but hostname after InetSocketAddress#getHostName()

This commit is contained in:
tsuoihito 2022-06-30 21:28:32 +10:00 committed by md_5
parent 2a716bbc7f
commit c8e876bfe2
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11

View File

@ -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 )