13
0
geforkt von Mirrors/Velocity

Explicitly parse IP addresses before using an unresolved address

This allows plugins to more correctly use InetSocketAddress#getAddress(),
however "gotchas" remain.
Dieser Commit ist enthalten in:
Andrew Steinborn 2019-08-07 16:21:03 -04:00
Ursprung 4940f6b447
Commit 7c2cbdbf1f

Datei anzeigen

@ -1,6 +1,8 @@
package com.velocitypowered.proxy.util;
import com.google.common.base.Preconditions;
import com.google.common.net.InetAddresses;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.URI;
@ -19,7 +21,12 @@ public class AddressUtil {
public static InetSocketAddress parseAddress(String ip) {
Preconditions.checkNotNull(ip, "ip");
URI uri = URI.create("tcp://" + ip);
return InetSocketAddress.createUnresolved(uri.getHost(), uri.getPort());
try {
InetAddress ia = InetAddresses.forUriString(uri.getHost());
return new InetSocketAddress(ia, uri.getPort());
} catch (IllegalArgumentException e) {
return InetSocketAddress.createUnresolved(uri.getHost(), uri.getPort());
}
}
/**