mirror of
https://github.com/ViaVersion/ViaProxy.git
synced 2024-11-14 19:15:08 -05:00
Made blank server address validation stricter
This commit is contained in:
parent
1287cb2f9f
commit
3bb37e3f0e
1 changed files with 4 additions and 4 deletions
|
@ -31,16 +31,16 @@ import java.net.SocketAddress;
|
||||||
public class AddressUtil {
|
public class AddressUtil {
|
||||||
|
|
||||||
public static SocketAddress parse(final String serverAddress, final ProtocolVersion version) {
|
public static SocketAddress parse(final String serverAddress, final ProtocolVersion version) {
|
||||||
if (serverAddress.isBlank()) {
|
|
||||||
throw new IllegalArgumentException("Server address cannot be blank");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (serverAddress.startsWith("file:///") || serverAddress.startsWith("unix:///")) { // Unix Socket
|
if (serverAddress.startsWith("file:///") || serverAddress.startsWith("unix:///")) { // Unix Socket
|
||||||
final String filePath = serverAddress.substring(7);
|
final String filePath = serverAddress.substring(7);
|
||||||
|
|
||||||
return new DomainSocketAddress(filePath);
|
return new DomainSocketAddress(filePath);
|
||||||
} else { // IP Address
|
} else { // IP Address
|
||||||
final HostAndPort hostAndPort = HostAndPort.fromString(serverAddress);
|
final HostAndPort hostAndPort = HostAndPort.fromString(serverAddress);
|
||||||
|
if (hostAndPort.getHost().isBlank()) {
|
||||||
|
throw new IllegalArgumentException("Server address cannot be blank");
|
||||||
|
}
|
||||||
|
|
||||||
final int port;
|
final int port;
|
||||||
if (version != null) {
|
if (version != null) {
|
||||||
port = hostAndPort.getPortOrDefault(getDefaultPort(version));
|
port = hostAndPort.getPortOrDefault(getDefaultPort(version));
|
||||||
|
|
Loading…
Reference in a new issue