Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-17 05:20:14 +01:00
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;
|
package com.velocitypowered.proxy.util;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
import com.google.common.net.InetAddresses;
|
||||||
|
import java.net.InetAddress;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
@ -19,7 +21,12 @@ public class AddressUtil {
|
|||||||
public static InetSocketAddress parseAddress(String ip) {
|
public static InetSocketAddress parseAddress(String ip) {
|
||||||
Preconditions.checkNotNull(ip, "ip");
|
Preconditions.checkNotNull(ip, "ip");
|
||||||
URI uri = URI.create("tcp://" + 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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren