From eca68252a7d427e696b6a5be57d668eeefc0723b Mon Sep 17 00:00:00 2001 From: Him188 Date: Sun, 12 Jan 2020 02:32:21 +0800 Subject: [PATCH] Fix packet --- .../mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt | 7 +++---- .../net/mamoe/mirai/qqandroid/network/QQAndroidClient.kt | 2 +- .../net/mamoe/mirai/qqandroid/network/protocol/README.md | 1 + .../qqandroid/network/protocol/packet/login/LoginPacket.kt | 7 +++---- .../kotlin/net.mamoe.mirai/utils/cryptor/ECDH.kt | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt index cf40a7e7d..6b29913fb 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt @@ -14,10 +14,7 @@ import net.mamoe.mirai.qqandroid.network.protocol.packet.login.LoginPacket import net.mamoe.mirai.qqandroid.network.protocol.packet.login.PacketId import net.mamoe.mirai.utils.LockFreeLinkedList import net.mamoe.mirai.utils.MiraiInternalAPI -import net.mamoe.mirai.utils.io.ClosedChannelException -import net.mamoe.mirai.utils.io.PlatformSocket -import net.mamoe.mirai.utils.io.ReadPacketInternalException -import net.mamoe.mirai.utils.io.debugPrint +import net.mamoe.mirai.utils.io.* import net.mamoe.mirai.utils.unsafeWeakRef import kotlin.coroutines.CoroutineContext @@ -35,6 +32,8 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler println("Sending login") LoginPacket.SubCommand9(bot.client).sendAndExpect() + println("SessionTicket=${bot.client.wLoginSigInfo.wtSessionTicket.data.toUHexString()}") + println("SessionTicketKey=${bot.client.wLoginSigInfo.wtSessionTicketKey.toUHexString()}") } internal fun launchPacketProcessor(rawInput: ByteReadPacket): Job { diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidClient.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidClient.kt index c8561532b..9cbfbdb2b 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidClient.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidClient.kt @@ -118,7 +118,7 @@ internal open class QQAndroidClient( var loginExtraData: LoginExtraData? = null lateinit var wFastLoginInfo: WFastLoginInfo var reserveUinInfo: ReserveUinInfo? = null - var wLoginSigInfo: WLoginSigInfo? = null + lateinit var wLoginSigInfo: WLoginSigInfo var tlv113: ByteArray? = null lateinit var qrPushSig: ByteArray diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/README.md b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/README.md index 63505d54e..2af31c4eb 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/README.md +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/README.md @@ -47,6 +47,7 @@ OutgoingPacket { byte 2 // head flag short 27 + 2 + remaining.length ushort client.protocolVersion // const 8001 + ushort commandId // e.g. 0x0810 ushort 0x0001 uint client.uin byte 3 // const diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/LoginPacket.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/LoginPacket.kt index d3081662b..917990d54 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/LoginPacket.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/LoginPacket.kt @@ -421,7 +421,7 @@ internal object LoginPacket : PacketFactory