Improved wildcard domain syntax kick message

This commit is contained in:
Lenni0451 2024-05-01 17:51:40 +02:00
parent 0353a9323b
commit 50f49709b0
No known key found for this signature in database
GPG Key ID: 5D59B86635AD3F2F
1 changed files with 6 additions and 4 deletions

View File

@ -134,19 +134,21 @@ public class Client2ProxyHandler extends SimpleChannelInboundHandler<IPacket> {
if (handshakeParts[0].toLowerCase().contains(".viaproxy.")) {
handshakeParts[0] = handshakeParts[0].substring(0, handshakeParts[0].toLowerCase().lastIndexOf(".viaproxy."));
} else {
throw CloseAndReturn.INSTANCE;
throw new IllegalArgumentException();
}
final ArrayHelper arrayHelper = ArrayHelper.instanceOf(handshakeParts[0].split(Pattern.quote("_")));
if (arrayHelper.getLength() < 3) {
throw CloseAndReturn.INSTANCE;
throw new IllegalArgumentException();
}
final String versionString = arrayHelper.get(arrayHelper.getLength() - 1);
serverVersion = ProtocolVersionUtil.fromNameLenient(versionString);
if (serverVersion == null) throw CloseAndReturn.INSTANCE;
if (serverVersion == null) {
this.proxyConnection.kickClient("§cWrong domain syntax!\n§cUnknown server version.");
}
final String connectIP = arrayHelper.getAsString(0, arrayHelper.getLength() - 3, "_");
final int connectPort = arrayHelper.getInteger(arrayHelper.getLength() - 2);
serverAddress = AddressUtil.parse(connectIP + ":" + connectPort, serverVersion);
} catch (CloseAndReturn e) {
} catch (IllegalArgumentException e) {
this.proxyConnection.kickClient("§cWrong domain syntax! §6Please use:\n§7address_port_version.viaproxy.hostname");
}
} else if (ViaProxy.getConfig().getWildcardDomainHandling() == ViaProxyConfig.WildcardDomainHandling.INTERNAL) {