From 30d7d584c4eb07e0c40a5f45b6d4e71ed8c679eb Mon Sep 17 00:00:00 2001 From: creeper123123321 <7974274+creeper123123321@users.noreply.github.com> Date: Sun, 11 Jul 2021 16:30:23 -0300 Subject: [PATCH] only send reauth message when encrypted --- .../viaversion/aas/handler/ConnectionData.kt | 2 ++ .../aas/handler/state/LoginState.kt | 33 ++++++++++--------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/main/kotlin/com/viaversion/aas/handler/ConnectionData.kt b/src/main/kotlin/com/viaversion/aas/handler/ConnectionData.kt index 145beab..5cb39c0 100644 --- a/src/main/kotlin/com/viaversion/aas/handler/ConnectionData.kt +++ b/src/main/kotlin/com/viaversion/aas/handler/ConnectionData.kt @@ -1,5 +1,6 @@ package com.viaversion.aas.handler +import com.viaversion.aas.codec.CryptoCodec import com.viaversion.aas.handler.state.HandshakeState import com.viaversion.aas.handler.state.ConnectionState import io.netty.channel.Channel @@ -13,4 +14,5 @@ class ConnectionData( ) { val frontHandler get() = frontChannel.pipeline().get(MinecraftHandler::class.java) val backHandler get() = backChannel?.pipeline()?.get(MinecraftHandler::class.java) + val frontEncrypted get() = frontChannel.pipeline().get(CryptoCodec::class.java) != null } \ No newline at end of file diff --git a/src/main/kotlin/com/viaversion/aas/handler/state/LoginState.kt b/src/main/kotlin/com/viaversion/aas/handler/state/LoginState.kt index bf256c0..4e31408 100644 --- a/src/main/kotlin/com/viaversion/aas/handler/state/LoginState.kt +++ b/src/main/kotlin/com/viaversion/aas/handler/state/LoginState.kt @@ -106,23 +106,26 @@ class LoginState : ConnectionState { } fun reauthMessage(handler: MinecraftHandler, backName: String, backHash: String): CompletableFuture { - if (handler.data.frontVer!! < ProtocolVersion.v1_13.version) { + if (!handler.data.frontEncrypted + || handler.data.frontVer!! < ProtocolVersion.v1_13.version + ) { callbackPluginReauth.complete(false) - } else { - val buf = ByteBufAllocator.DEFAULT.buffer() - try { - Type.STRING.write(buf, backName) - Type.STRING.write(buf, backHash) + return callbackPluginReauth + } - val packet = PluginRequest() - packet.id = ThreadLocalRandom.current().nextInt() - packet.channel = "viaaas:reauth" - packet.data = readRemainingBytes(buf) - send(handler.data.frontChannel, packet, true) - pendingReauth = packet.id - } finally { - buf.release() - } + val buf = ByteBufAllocator.DEFAULT.buffer() + try { + Type.STRING.write(buf, backName) + Type.STRING.write(buf, backHash) + + val packet = PluginRequest() + packet.id = ThreadLocalRandom.current().nextInt() + packet.channel = "viaaas:reauth" + packet.data = readRemainingBytes(buf) + send(handler.data.frontChannel, packet, true) + pendingReauth = packet.id + } finally { + buf.release() } return callbackPluginReauth }