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:
Ursprung
2c3b30fff2
Commit
3b9db94ce9
@ -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,8 +21,13 @@ public class AddressUtil {
|
||||
public static InetSocketAddress parseAddress(String ip) {
|
||||
Preconditions.checkNotNull(ip, "ip");
|
||||
URI uri = URI.create("tcp://" + ip);
|
||||
try {
|
||||
InetAddress ia = InetAddresses.forUriString(uri.getHost());
|
||||
return new InetSocketAddress(ia, uri.getPort());
|
||||
} catch (IllegalArgumentException e) {
|
||||
return InetSocketAddress.createUnresolved(uri.getHost(), uri.getPort());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to parse an IP address of the form <code>127.0.0.1:25565</code>. The returned
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren