From 1fde79d7ad6724d96e12a32bb3ebc53b0af965d7 Mon Sep 17 00:00:00 2001 From: StageGuard <1355416608@qq.com> Date: Sat, 17 Jun 2023 12:23:04 +0800 Subject: [PATCH] [core] decode SsoSecureA2Access --- .../kotlin/network/components/PacketCodec.kt | 6 +++--- .../network/protocol/packet/PacketFactory.kt | 2 ++ ...soEstablishShareKey.kt => TRpcRawPacket.kt} | 18 ++++++++++++++---- .../network/protocol/packet/sso/prefix.kt | 12 ------------ 4 files changed, 19 insertions(+), 19 deletions(-) rename mirai-core/src/commonMain/kotlin/network/protocol/packet/sso/{SsoEstablishShareKey.kt => TRpcRawPacket.kt} (64%) delete mode 100644 mirai-core/src/commonMain/kotlin/network/protocol/packet/sso/prefix.kt diff --git a/mirai-core/src/commonMain/kotlin/network/components/PacketCodec.kt b/mirai-core/src/commonMain/kotlin/network/components/PacketCodec.kt index a9d4bfc99..18f5834fc 100644 --- a/mirai-core/src/commonMain/kotlin/network/components/PacketCodec.kt +++ b/mirai-core/src/commonMain/kotlin/network/components/PacketCodec.kt @@ -18,7 +18,7 @@ import net.mamoe.mirai.internal.network.components.PacketCodecException.Kind.* import net.mamoe.mirai.internal.network.handler.selector.NetworkException import net.mamoe.mirai.internal.network.protocol.packet.* import net.mamoe.mirai.internal.network.protocol.packet.login.WtLogin -import net.mamoe.mirai.internal.network.protocol.packet.sso.PREFIX_TRPC_SSO +import net.mamoe.mirai.internal.network.protocol.packet.sso.TRpcRawPacket import net.mamoe.mirai.internal.utils.crypto.Ecdh import net.mamoe.mirai.internal.utils.crypto.TEA import net.mamoe.mirai.utils.* @@ -174,7 +174,7 @@ internal class PacketCodecImpl : PacketCodec { "which may means protocol is updated.", flag3Exception ) - } else if (raw.commandName.startsWith(PREFIX_TRPC_SSO)) { + } else if (raw.commandName.startsWith(TRpcRawPacket.COMMAND_PREFIX)) { PacketLogger.verbose { "received a trpc native packet: ${raw.commandName}" } } else { throw flag3Exception @@ -194,7 +194,7 @@ internal class PacketCodecImpl : PacketCodec { raw.commandName, raw.sequenceId, raw.body.withUse { - if (raw.commandName.startsWith(PREFIX_TRPC_SSO)) { + if (raw.commandName.startsWith(TRpcRawPacket.COMMAND_PREFIX)) { readBytes() } else { try { diff --git a/mirai-core/src/commonMain/kotlin/network/protocol/packet/PacketFactory.kt b/mirai-core/src/commonMain/kotlin/network/protocol/packet/PacketFactory.kt index 93bd1d34a..d2e6ad780 100644 --- a/mirai-core/src/commonMain/kotlin/network/protocol/packet/PacketFactory.kt +++ b/mirai-core/src/commonMain/kotlin/network/protocol/packet/PacketFactory.kt @@ -27,6 +27,7 @@ import net.mamoe.mirai.internal.network.protocol.packet.login.Heartbeat import net.mamoe.mirai.internal.network.protocol.packet.login.StatSvc import net.mamoe.mirai.internal.network.protocol.packet.login.WtLogin import net.mamoe.mirai.internal.network.protocol.packet.sso.SsoEstablishShareKey +import net.mamoe.mirai.internal.network.protocol.packet.sso.SsoSecureA2Access import net.mamoe.mirai.internal.network.protocol.packet.summarycard.ChangeFriendRemark import net.mamoe.mirai.internal.network.protocol.packet.summarycard.SummaryCard import net.mamoe.mirai.utils.DeprecatedSinceMirai @@ -133,6 +134,7 @@ internal object KnownPacketFactories { WtLogin.ExchangeEmp, WtLogin.TransEmp, SsoEstablishShareKey, + SsoSecureA2Access, StatSvc.Register, StatSvc.GetOnlineStatus, StatSvc.SimpleGet, diff --git a/mirai-core/src/commonMain/kotlin/network/protocol/packet/sso/SsoEstablishShareKey.kt b/mirai-core/src/commonMain/kotlin/network/protocol/packet/sso/TRpcRawPacket.kt similarity index 64% rename from mirai-core/src/commonMain/kotlin/network/protocol/packet/sso/SsoEstablishShareKey.kt rename to mirai-core/src/commonMain/kotlin/network/protocol/packet/sso/TRpcRawPacket.kt index c46942d4a..72680aec2 100644 --- a/mirai-core/src/commonMain/kotlin/network/protocol/packet/sso/SsoEstablishShareKey.kt +++ b/mirai-core/src/commonMain/kotlin/network/protocol/packet/sso/TRpcRawPacket.kt @@ -14,12 +14,22 @@ import net.mamoe.mirai.internal.QQAndroidBot import net.mamoe.mirai.internal.network.Packet import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacketFactory -internal object SsoEstablishShareKey : OutgoingPacketFactory<SsoEstablishShareKey.RawData>( - "trpc.o3.ecdh_access.EcdhAccess.SsoEstablishShareKey" -) { +internal abstract class TRpcRawPacket(commandName: String) : + OutgoingPacketFactory<TRpcRawPacket.RawData>(commandName) { internal class RawData(val data: ByteArray) : Packet override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): RawData { return RawData(readBytes()) } -} \ No newline at end of file + + companion object { + const val COMMAND_PREFIX = "trpc.o3" + } +} + +internal object SsoEstablishShareKey : + TRpcRawPacket("$COMMAND_PREFIX.ecdh_access.EcdhAccess.SsoEstablishShareKey") + +internal object SsoSecureA2Access : + TRpcRawPacket("$COMMAND_PREFIX.ecdh_access.EcdhAccess.SsoSecureA2Access") + diff --git a/mirai-core/src/commonMain/kotlin/network/protocol/packet/sso/prefix.kt b/mirai-core/src/commonMain/kotlin/network/protocol/packet/sso/prefix.kt deleted file mode 100644 index 313193824..000000000 --- a/mirai-core/src/commonMain/kotlin/network/protocol/packet/sso/prefix.kt +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright 2019-2023 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/dev/LICENSE - */ - -package net.mamoe.mirai.internal.network.protocol.packet.sso - -internal const val PREFIX_TRPC_SSO = "trpc.o3" \ No newline at end of file