Fix packet

This commit is contained in:
Him188 2020-01-12 02:32:21 +08:00
parent 34f1936c6d
commit eca68252a7
5 changed files with 9 additions and 10 deletions

View File

@ -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<LoginPacket.LoginPacketResponse>()
println("SessionTicket=${bot.client.wLoginSigInfo.wtSessionTicket.data.toUHexString()}")
println("SessionTicketKey=${bot.client.wLoginSigInfo.wtSessionTicketKey.toUHexString()}")
}
internal fun launchPacketProcessor(rawInput: ByteReadPacket): Job {

View File

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

View File

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

View File

@ -421,7 +421,7 @@ internal object LoginPacket : PacketFactory<LoginPacket.LoginPacketResponse, Log
* login extra data
*/
private fun QQAndroidClient.analysisTlv537(t537: ByteArray) = t537.read {
discardExact(2)
//discardExact(2)
loginExtraData = LoginExtraData( // args are to correct order
uin = readUInt().toLong(),
ip = readUByteLVByteArray(),
@ -509,8 +509,7 @@ internal object LoginPacket : PacketFactory<LoginPacket.LoginPacketResponse, Log
val host = readUShortLVString()
val port = readShort()
bot.logger.warning("更换服务器: host=$host, port=$port, type=$type")
// TODO: 2020/1/9 SET HOST ADDRESS ?? MAY BE IMPORTANT
bot.logger.warning("服务器: host=$host, port=$port, type=$type")
// SEE oicq_request.java at method analysisT173
}
}
@ -524,7 +523,7 @@ internal object LoginPacket : PacketFactory<LoginPacket.LoginPacketResponse, Log
val host = readUShortLVString()
val port = readShort()
// TODO: 2020/1/9 SET IPV6 ADDRESS
bot.logger.warning("服务器 ipv6: host=$host, port=$port, type=$type")
// SEE oicq_request.java at method analysisT17f
}
}

View File

@ -35,7 +35,7 @@ expect class ECDH(keyPair: ECDHKeyPair) {
@Suppress("FunctionName")
expect fun ECDH(): ECDH
internal val initialPublicKey =
val initialPublicKey =
ECDH.constructPublicKey("3046301006072A8648CE3D020106052B8104001F03320004928D8850673088B343264E0C6BACB8496D697799F37211DEB25BB73906CB089FEA9639B4E0260498B51A992D50813DA8".chunkedHexToBytes())
private val commonHeadFor02 = "302E301006072A8648CE3D020106052B8104001F031A00".chunkedHexToBytes()
private val commonHeadForNot02 = "3046301006072A8648CE3D020106052B8104001F033200".chunkedHexToBytes()