Skip to content

Commit

Permalink
Made blank server address validation stricter
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphiMC committed Oct 30, 2024
1 parent 1287cb2 commit 3bb37e3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/java/net/raphimc/viaproxy/util/AddressUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@
public class AddressUtil {

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
final String filePath = serverAddress.substring(7);

return new DomainSocketAddress(filePath);
} else { // IP Address
final HostAndPort hostAndPort = HostAndPort.fromString(serverAddress);
if (hostAndPort.getHost().isBlank()) {
throw new IllegalArgumentException("Server address cannot be blank");
}

final int port;
if (version != null) {
port = hostAndPort.getPortOrDefault(getDefaultPort(version));
Expand Down

0 comments on commit 3bb37e3

Please sign in to comment.