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 799380db0..37f29d3fe 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 @@ -34,14 +34,6 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler bot.logger.info("Trying login") when (val response: LoginPacket.LoginPacketResponse = LoginPacket.SubCommand9(bot.client).sendAndExpect()) { - is UnsafeLogin -> { - bot.logger.info("Login unsuccessful, device auth is needed") - bot.logger.info("登陆失败, 原因为非常用设备登陆") - bot.logger.info("Open the following URL in QQ browser and complete the verification") - bot.logger.info("将下面这个链接在QQ浏览器中打开并完成认证后尝试再次登陆") - bot.logger.info(response.url) - return - } is Captcha -> when (response) { is Captcha.Picture -> { bot.logger.info("需要图片验证码") 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 fd78149c7..5915ef359 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 @@ -15,7 +15,6 @@ import net.mamoe.mirai.utils.MiraiInternalAPI import net.mamoe.mirai.utils.cryptor.ECDH import net.mamoe.mirai.utils.cryptor.contentToString import net.mamoe.mirai.utils.cryptor.decryptBy -import net.mamoe.mirai.utils.cryptor.initialPublicKey import net.mamoe.mirai.utils.getValue import net.mamoe.mirai.utils.io.* import net.mamoe.mirai.utils.unsafeWeakRef @@ -54,7 +53,7 @@ internal open class QQAndroidClient( "tgtgtKey" to tgtgtKey, "tgtKey" to wLoginSigInfo.tgtKey, "deviceToken" to wLoginSigInfo.deviceToken, - "shareKeyCalculatedByConstPubKey" to ecdh.calculateShareKeyByPeerPublicKey(initialPublicKey) + "shareKeyCalculatedByConstPubKey" to ecdh.keyPair.shareKey //"t108" to wLoginSigInfo.t1, //"t10c" to t10c, //"t163" to t163 @@ -287,8 +286,8 @@ internal fun parsePSKeyMapAndPt4TokenMap(data: ByteArray, creationTime: Long, ex val pt4token = readUShortLVByteArray() when { - psKey.size > 0 -> outPSKeyMap[domain] = PSKey(psKey, creationTime, expireTime) - pt4token.size > 0 -> outPt4TokenMap[domain] = Pt4Token(pt4token, creationTime, expireTime) + psKey.isNotEmpty() -> outPSKeyMap[domain] = PSKey(psKey, creationTime, expireTime) + pt4token.isNotEmpty() -> outPt4TokenMap[domain] = Pt4Token(pt4token, creationTime, expireTime) } } } 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 255f8bb4e..12a68b40f 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 @@ -203,17 +203,24 @@ internal object LoginPacket : PacketFactory("wt ) : LoginPacketResponse() sealed class Captcha : LoginPacketResponse() { - lateinit var answer: String class Slider( val data: IoBuffer, val sign: ByteArray - ) : Captcha() + ) : Captcha(){ + override fun toString(): String { + return "LoginPacketResponse.Captcha.Slider" + } + } class Picture( val data: IoBuffer, val sign: ByteArray - ) : Captcha() + ) : Captcha(){ + override fun toString(): String { + return "LoginPacketResponse.Captcha.Picture" + } + } } class UnsafeLogin(val url: String) : LoginPacketResponse() @@ -276,7 +283,7 @@ internal object LoginPacket : PacketFactory("wt @InternalAPI @UseExperimental(MiraiDebugAPI::class) - private suspend fun onSolveLoginCaptcha(tlvMap: Map, bot: QQAndroidBot): LoginPacketResponse.Captcha { + private suspend fun onSolveLoginCaptcha(tlvMap: Map, bot: QQAndroidBot): LoginPacketResponse. Captcha { val client = bot.client // val ret = tlvMap[0x104]?.let { println(it.toUHexString()) } println()