From da798dec48a5f62208afa6d1c1a90039dc27c6fb Mon Sep 17 00:00:00 2001 From: RaphiMC <50594595+RaphiMC@users.noreply.github.com> Date: Thu, 2 Feb 2023 17:13:33 +0100 Subject: [PATCH] Fixed ViaProxy doing nothing when the client version is invalid in status protocol --- .../viaproxy/proxy/client2proxy/Client2ProxyHandler.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/Client2ProxyHandler.java b/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/Client2ProxyHandler.java index ece674c..7e96b58 100644 --- a/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/Client2ProxyHandler.java +++ b/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/Client2ProxyHandler.java @@ -142,13 +142,14 @@ public class Client2ProxyHandler extends SimpleChannelInboundHandler { String address = packet.address.split("\0")[0]; final VersionEnum clientVersion = VersionEnum.fromProtocolVersion(ProtocolVersion.getProtocol(packet.protocolVersion)); - if (ConnectionState.LOGIN.equals(packet.intendedState)) { - if (clientVersion == VersionEnum.UNKNOWN) throw CloseAndReturn.INSTANCE; + this.proxyConnection.setClientVersion(clientVersion); + this.proxyConnection.setConnectionState(packet.intendedState); + + if ((ConnectionState.LOGIN.equals(packet.intendedState) || ConnectionState.STATUS.equals(packet.intendedState)) && clientVersion == VersionEnum.UNKNOWN) { + this.proxyConnection.kickClient("§cYour client version is not supported by ViaProxy!"); } else if (!ConnectionState.STATUS.equals(packet.intendedState)) { throw CloseAndReturn.INSTANCE; } - this.proxyConnection.setClientVersion(clientVersion); - this.proxyConnection.setConnectionState(packet.intendedState); this.customPayloadPacketId = MCPackets.C2S_PLUGIN_MESSAGE.getId(clientVersion.getVersion()); this.chatSessionUpdatePacketId = MCPackets.C2S_CHAT_SESSION_UPDATE.getId(clientVersion.getVersion());