only send reauth message when encrypted

This commit is contained in:
creeper123123321 2021-07-11 16:30:23 -03:00
parent 3682a0f011
commit 30d7d584c4
2 changed files with 20 additions and 15 deletions

View File

@ -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
}

View File

@ -106,23 +106,26 @@ class LoginState : ConnectionState {
}
fun reauthMessage(handler: MinecraftHandler, backName: String, backHash: String): CompletableFuture<Boolean> {
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
}