From ff546226638ddaec57cfc33c14f5e83ce0cee30d Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Sun, 18 Apr 2021 08:20:04 -0400 Subject: [PATCH 1/2] Forced hosts should be case-insensitive. Fixes #464 --- .../proxy/connection/client/ConnectedPlayer.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java index 2c7aa7e86..fe49f71ee 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java @@ -79,6 +79,7 @@ import java.net.InetSocketAddress; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.Locale; import java.util.Objects; import java.util.Optional; import java.util.UUID; @@ -736,7 +737,9 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player { */ private Optional getNextServerToTry(@Nullable RegisteredServer current) { if (serversToTry == null) { - String virtualHostStr = getVirtualHost().map(InetSocketAddress::getHostString).orElse(""); + String virtualHostStr = getVirtualHost().map(InetSocketAddress::getHostString) + .orElse("") + .toLowerCase(Locale.ROOT); serversToTry = server.getConfiguration().getForcedHosts().getOrDefault(virtualHostStr, Collections.emptyList()); } From ca52f8989e325109ce075900e7caf66fb867ce8f Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Sun, 18 Apr 2021 08:22:36 -0400 Subject: [PATCH 2/2] Load forced hosts as lowercase too, see #464 --- .../proxy/config/VelocityConfiguration.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/config/VelocityConfiguration.java b/proxy/src/main/java/com/velocitypowered/proxy/config/VelocityConfiguration.java index 12d1e9511..570504636 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/config/VelocityConfiguration.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/config/VelocityConfiguration.java @@ -43,6 +43,7 @@ import java.nio.file.StandardCopyOption; import java.security.SecureRandom; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Optional; import java.util.Random; @@ -600,9 +601,11 @@ public class VelocityConfiguration implements ProxyConfig { Map> forcedHosts = new HashMap<>(); for (UnmodifiableConfig.Entry entry : config.entrySet()) { if (entry.getValue() instanceof String) { - forcedHosts.put(entry.getKey(), ImmutableList.of(entry.getValue())); + forcedHosts.put(entry.getKey().toLowerCase(Locale.ROOT), + ImmutableList.of(entry.getValue())); } else if (entry.getValue() instanceof List) { - forcedHosts.put(entry.getKey(), ImmutableList.copyOf((List) entry.getValue())); + forcedHosts.put(entry.getKey().toLowerCase(Locale.ROOT), + ImmutableList.copyOf((List) entry.getValue())); } else { throw new IllegalStateException( "Invalid value of type " + entry.getValue().getClass() + " in forced hosts!");