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 c83611f92..e937cdcbe 100644 --- a/mirai-core/src/commonMain/kotlin/network/protocol/packet/PacketFactory.kt +++ b/mirai-core/src/commonMain/kotlin/network/protocol/packet/PacketFactory.kt @@ -169,6 +169,7 @@ internal object KnownPacketFactories { OnlinePushPbPushGroupMsg, OnlinePushReqPush, OnlinePushPbPushTransMsg, + OnlinePushSidExpired, MessageSvcPushNotify, MessageSvcPushReaded, MessageSvcRequestPushStatus, @@ -440,4 +441,4 @@ internal object KnownPacketFactories { consumer(packetFactory, packet, packetFactory.commandName, ssoSequenceId) } -} \ No newline at end of file +} diff --git a/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/receive/OnlinePush.SidExpired.kt b/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/receive/OnlinePush.SidExpired.kt new file mode 100644 index 000000000..7d8f181ef --- /dev/null +++ b/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/receive/OnlinePush.SidExpired.kt @@ -0,0 +1,38 @@ +/* + * Copyright 2019-2021 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/master/LICENSE + */ + +package net.mamoe.mirai.internal.network.protocol.packet.chat.receive + +import kotlinx.io.core.ByteReadPacket +import net.mamoe.mirai.internal.QQAndroidBot +import net.mamoe.mirai.internal.network.Packet +import net.mamoe.mirai.internal.network.protocol.packet.IncomingPacketFactory +import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacket +import net.mamoe.mirai.internal.network.protocol.packet.buildResponseUniPacket +import net.mamoe.mirai.internal.network.protocol.packet.login.StatSvc +import net.mamoe.mirai.internal.network.protocol.packet.login.wtlogin.WtLogin10 +import net.mamoe.mirai.internal.network.protocol.packet.sendAndExpect + +internal object OnlinePushSidExpired : IncomingPacketFactory<Packet?>("OnlinePush.SidTicketExpired") { + + override suspend fun QQAndroidBot.handle(packet: Packet?, sequenceId: Int): OutgoingPacket { + return buildResponseUniPacket( + client, + sequenceId = sequenceId, + key = client.wLoginSigInfo.d2Key + ) {}.also { + WtLogin10(client, mainSigMap = 3554528).sendAndExpect(bot) + StatSvc.Register.online(client).sendAndExpect(bot) + } + } + + override suspend fun ByteReadPacket.decode(bot: QQAndroidBot, sequenceId: Int): Packet? { + return null + } +} diff --git a/mirai-core/src/commonMain/kotlin/network/protocol/packet/login/WtLogin.kt b/mirai-core/src/commonMain/kotlin/network/protocol/packet/login/WtLogin.kt index 1c38ddd61..b54e2c66b 100644 --- a/mirai-core/src/commonMain/kotlin/network/protocol/packet/login/WtLogin.kt +++ b/mirai-core/src/commonMain/kotlin/network/protocol/packet/login/WtLogin.kt @@ -433,6 +433,8 @@ internal class WtLogin { } ?: encryptedDownloadSession encryptA1 = tlvMap119.getOrDefault(0x106, encryptA1) noPicSig = tlvMap119.getOrDefault(0x16a, noPicSig) + psKeyMap.putAll(outPSKeyMap.orEmpty().toMutableMap()) + pt4TokenMap.putAll(outPt4TokenMap.orEmpty().toMutableMap()) } } else { var a1: ByteArray? = tlvMap119.getOrFail(0x106) diff --git a/mirai-core/src/commonMain/kotlin/network/protocol/packet/login/wtlogin/WtLogin10.kt b/mirai-core/src/commonMain/kotlin/network/protocol/packet/login/wtlogin/WtLogin10.kt index a7ef570f0..3aa26b337 100644 --- a/mirai-core/src/commonMain/kotlin/network/protocol/packet/login/wtlogin/WtLogin10.kt +++ b/mirai-core/src/commonMain/kotlin/network/protocol/packet/login/wtlogin/WtLogin10.kt @@ -24,6 +24,8 @@ internal object WtLogin10 : WtLoginExt { const val appId: Long = 16L operator fun invoke( client: QQAndroidClient, + subAppId: Long = 100, + mainSigMap: Int = client.mainSigMap ) = WtLogin.ExchangeEmp.buildLoginOutgoingPacket(client, bodyType = 2, key = ByteArray(16)) { sequenceId -> writeSsoPacket( client, @@ -39,7 +41,7 @@ internal object WtLogin10 : WtLoginExt { ) { writeShort(11) // subCommand writeShort(17) - t100(appId, 100, client.appClientVersion, client.ssoVersion, client.mainSigMap) + t100(appId, subAppId, client.appClientVersion, client.ssoVersion, mainSigMap) t10a(client.wLoginSigInfo.tgt) t116(client.miscBitMap, client.subSigMap) t108(client.ksid)