Commit 3cbd26e2 authored by jiahua.liu's avatar jiahua.liu

Merge remote-tracking branch 'origin/master'

parents 897ec106 a707af64
...@@ -98,13 +98,14 @@ internal class GroupImpl(bot: QQAndroidBot, override val coroutineContext: Corou ...@@ -98,13 +98,14 @@ internal class GroupImpl(bot: QQAndroidBot, override val coroutineContext: Corou
override suspend fun sendMessage(message: MessageChain) { override suspend fun sendMessage(message: MessageChain) {
bot.network.run { bot.network.run {
val response = MessageSvc.PbSendMsg.ToGroup(
bot.client,
id,
message
).sendAndExpect<MessageSvc.PbSendMsg.Response>()
check( check(
MessageSvc.PbSendMsg.ToGroup( response is MessageSvc.PbSendMsg.Response.SUCCESS
bot.client, ) { "send message failed: $response" }
id,
message
).sendAndExpect<MessageSvc.PbSendMsg.Response>() is MessageSvc.PbSendMsg.Response.SUCCESS
) { "send message failed" }
} }
} }
......
...@@ -212,7 +212,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo ...@@ -212,7 +212,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
} }
override fun encodeTaggedEnum(tag: Int, enumDescription: SerialDescriptor, ordinal: Int) { override fun encodeTaggedEnum(tag: Int, enumDescription: SerialDescriptor, ordinal: Int) {
TODO() encodeTaggedInt(tag, ordinal)
} }
override fun encodeTaggedNull(tag: Int) { override fun encodeTaggedNull(tag: Int) {
...@@ -332,9 +332,9 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo ...@@ -332,9 +332,9 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
override fun decodeTaggedString(tag: Int): String = input.readString(tag) override fun decodeTaggedString(tag: Int): String = input.readString(tag)
override fun decodeTaggedBoolean(tag: Int): Boolean = input.readBoolean(tag) override fun decodeTaggedBoolean(tag: Int): Boolean = input.readBoolean(tag)
override fun decodeTaggedEnum(tag: Int, enumDescription: SerialDescriptor): Int {
override fun decodeTaggedEnum(tag: Int, enumDescription: SerialDescriptor): Int = return input.readInt(tag)
TODO() }
/** /**
* 在 [KSerializer.serialize] 前 * 在 [KSerializer.serialize] 前
......
...@@ -112,6 +112,9 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler ...@@ -112,6 +112,9 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
} }
} }
//val msg = MessageSvc.PbGetMsg(bot.client, MsgSvc.SyncFlag.START, currentTimeSeconds).sendAndExpect<MessageSvc.PbGetMsg.Response>()
//println(msg.contentToString())
try { try {
bot.logger.info("开始加载好友信息") bot.logger.info("开始加载好友信息")
var currentFriendCount = 0 var currentFriendCount = 0
...@@ -347,6 +350,16 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler ...@@ -347,6 +350,16 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
private val packetReceiveLock: Mutex = Mutex() private val packetReceiveLock: Mutex = Mutex()
/**
* 发送一个包, 但不期待任何返回.
*/
suspend fun OutgoingPacket.sendWithoutExpect() {
bot.logger.info("Send: ${this.commandName}")
withContext(this@QQAndroidBotNetworkHandler.coroutineContext + CoroutineName("Packet sender")) {
channel.send(delegate)
}
}
/** /**
* 发送一个包, 并挂起直到接收到指定的返回包或超时(3000ms) * 发送一个包, 并挂起直到接收到指定的返回包或超时(3000ms)
*/ */
...@@ -363,19 +376,17 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler ...@@ -363,19 +376,17 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
channel.send(delegate) channel.send(delegate)
} }
bot.logger.info("Send: ${this.commandName}") bot.logger.info("Send: ${this.commandName}")
try { return withTimeoutOrNull(timeoutMillis) {
return withTimeoutOrNull(timeoutMillis) { @Suppress("UNCHECKED_CAST")
@Suppress("UNCHECKED_CAST") handler.await() as E
handler.await() as E // 不要 `withTimeout`. timeout 的异常会不知道去哪了.
// 不要 `withTimeout`. timeout 的异常会不知道去哪了. } ?: net.mamoe.mirai.qqandroid.utils.inline {
} ?: net.mamoe.mirai.qqandroid.utils.inline { error("timeout when receiving response of $commandName")
error("timeout when receiving response of $commandName")
}
} finally {
packetListeners.remove(handler)
} }
} catch (e: Exception) { } catch (e: Exception) {
lastException = e lastException = e
} finally {
packetListeners.remove(handler)
} }
} }
throw lastException!! throw lastException!!
......
...@@ -86,6 +86,8 @@ internal open class QQAndroidClient( ...@@ -86,6 +86,8 @@ internal open class QQAndroidClient(
var mainSigMap: Int = 16724722 var mainSigMap: Int = 16724722
var subSigMap: Int = 0x10400 //=66,560 var subSigMap: Int = 0x10400 //=66,560
var configPushSvcPushReqSequenceId: Int = 0
private val _ssoSequenceId: AtomicInt = atomic(85600) private val _ssoSequenceId: AtomicInt = atomic(85600)
@MiraiInternalAPI("Do not use directly. Get from the lambda param of buildSsoPacket") @MiraiInternalAPI("Do not use directly. Get from the lambda param of buildSsoPacket")
...@@ -96,7 +98,10 @@ internal open class QQAndroidClient( ...@@ -96,7 +98,10 @@ internal open class QQAndroidClient(
val apkVersionName: ByteArray = "8.2.0".toByteArray() val apkVersionName: ByteArray = "8.2.0".toByteArray()
private val messageSequenceId: AtomicInt = atomic(0) private val messageSequenceId: AtomicInt = atomic(0)
internal fun atomicNextMessageSequenceId(): Int = messageSequenceId.getAndIncrement() internal fun atomicNextMessageSequenceId(): Int = messageSequenceId.getAndAdd(2)
private val requestPacketRequestId: AtomicInt = atomic(1921334513)
internal fun nextRequestPacketRequestId(): Int = requestPacketRequestId.getAndAdd(2)
val appClientVersion: Int = 0 val appClientVersion: Int = 0
...@@ -112,7 +117,6 @@ internal open class QQAndroidClient( ...@@ -112,7 +117,6 @@ internal open class QQAndroidClient(
class C2cMessageSyncData { class C2cMessageSyncData {
var syncCookie: ByteArray? = null var syncCookie: ByteArray? = null
var pubAccountCookie = EMPTY_BYTE_ARRAY var pubAccountCookie = EMPTY_BYTE_ARRAY
var syncFlag: Int = 0
var msgCtrlBuf: ByteArray = EMPTY_BYTE_ARRAY var msgCtrlBuf: ByteArray = EMPTY_BYTE_ARRAY
} }
......
package net.mamoe.mirai.qqandroid.network.protocol.data.jce
import kotlinx.serialization.SerialId
import kotlinx.serialization.Serializable
import net.mamoe.mirai.data.Packet
import net.mamoe.mirai.qqandroid.io.JceStruct
@Serializable
internal class BigDataChannel(
@SerialId(0) val vBigdataIplists: List<BigDataIpList>,
@SerialId(1) val sBigdataSigSession: ByteArray? = null,
@SerialId(2) val sBigdataKeySession: ByteArray? = null,
@SerialId(3) val uSigUin: Long? = null,
@SerialId(4) val iConnectFlag: Int? = 1,
@SerialId(5) val vBigdataPbBuf: ByteArray? = null
) : JceStruct
@Serializable
internal class BigDataIpInfo(
@SerialId(0) val uType: Long,
@SerialId(1) val sIp: String = "",
@SerialId(2) val uPort: Long
) : JceStruct
@Serializable
internal class BigDataIpList(
@SerialId(0) val uServiceType: Long,
@SerialId(1) val vIplist: List<BigDataIpInfo>,
@SerialId(2) val netSegConfs: List<NetSegConf>? = null,
@SerialId(3) val ufragmentSize: Long? = null
) : JceStruct
@Serializable
internal class ClientLogConfig(
@SerialId(1) val type: Int,
@SerialId(2) val timeStart: TimeStamp? = null,
@SerialId(3) val timeFinish: TimeStamp? = null,
@SerialId(4) val loglevel: Byte? = null,
@SerialId(5) val cookie: Int? = null,
@SerialId(6) val lseq: Long? = null
) : JceStruct
@Serializable
internal class DomainIpChannel(
@SerialId(0) val vDomainIplists: List<DomainIpList>
) : JceStruct
@Serializable
internal class DomainIpInfo(
@SerialId(1) val uIp: Int,
@SerialId(2) val uPort: Int
) : JceStruct
@Serializable
internal class DomainIpList(
@SerialId(0) val uDomainType: Int,
@SerialId(1) val vIplist: List<DomainIpInfo>
) : JceStruct
@Serializable
internal class FileStoragePushFSSvcList(
@SerialId(0) val vUpLoadList: List<FileStorageServerListInfo>,
@SerialId(1) val vPicDownLoadList: List<FileStorageServerListInfo>,
@SerialId(2) val vGPicDownLoadList: List<FileStorageServerListInfo>? = null,
@SerialId(3) val vQzoneProxyServiceList: List<FileStorageServerListInfo>? = null,
@SerialId(4) val vUrlEncodeServiceList: List<FileStorageServerListInfo>? = null,
@SerialId(5) val bigDataChannel: BigDataChannel? = null,
@SerialId(6) val vVipEmotionList: List<FileStorageServerListInfo>? = null,
@SerialId(7) val vC2CPicDownList: List<FileStorageServerListInfo>? = null,
@SerialId(8) val fmtIPInfo: FmtIPInfo? = null,
@SerialId(9) val domainIpChannel: DomainIpChannel? = null,
@SerialId(10) val pttlist: ByteArray? = null
) : JceStruct
@Serializable
internal class FileStorageServerListInfo(
@SerialId(1) val sIP: String = "",
@SerialId(2) val iPort: Int
) : JceStruct
@Serializable
internal class FmtIPInfo(
@SerialId(0) val sGateIp: String = "",
@SerialId(1) val iGateIpOper: Long
) : JceStruct
@Serializable
internal class NetSegConf(
@SerialId(0) val uint32NetType: Long? = null,
@SerialId(1) val uint32Segsize: Long? = null,
@SerialId(2) val uint32Segnum: Long? = null,
@SerialId(3) val uint32Curconnnum: Long? = null
) : JceStruct
@Suppress("ArrayInDataClass")
@Serializable
internal data class PushReq(
@SerialId(1) val type: Int,
@SerialId(2) val jcebuf: ByteArray,
@SerialId(3) val seq: Long
) : JceStruct, Packet
@Serializable
internal class PushResp(
@SerialId(1) val type: Int,
@SerialId(2) val seq: Long,
@SerialId(3) val jcebuf: ByteArray? = null
) : JceStruct
@Serializable
internal class SsoServerList(
@SerialId(1) val v2G3GList: List<SsoServerListInfo>,
@SerialId(3) val vWifiList: List<SsoServerListInfo>,
@SerialId(4) val iReconnect: Int,
@SerialId(5) val testSpeed: Byte? = null,
@SerialId(6) val useNewList: Byte? = null,
@SerialId(7) val iMultiConn: Int? = 1,
@SerialId(8) val vHttp2g3glist: List<SsoServerListInfo>? = null,
@SerialId(9) val vHttpWifilist: List<SsoServerListInfo>? = null
) : JceStruct
@Serializable
internal class SsoServerListInfo(
@SerialId(1) val sIP: String = "",
@SerialId(2) val iPort: Int,
@SerialId(3) val linkType: Byte,
@SerialId(4) val proxy: Byte,
@SerialId(5) val protocolType: Byte? = null,
@SerialId(6) val iTimeOut: Int? = 10
) : JceStruct
@Serializable
internal class TimeStamp(
@SerialId(1) val year: Int,
@SerialId(2) val month: Byte,
@SerialId(3) val day: Byte,
@SerialId(4) val hour: Byte
) : JceStruct
package net.mamoe.mirai.qqandroid.network.protocol.data.jce package net.mamoe.mirai.qqandroid.network.protocol.data.jce
import kotlinx.atomicfu.AtomicInt
import kotlinx.atomicfu.atomic
import kotlinx.serialization.SerialId import kotlinx.serialization.SerialId
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import net.mamoe.mirai.qqandroid.io.JceStruct import net.mamoe.mirai.qqandroid.io.JceStruct
...@@ -14,20 +12,14 @@ internal class RequestPacket( ...@@ -14,20 +12,14 @@ internal class RequestPacket(
@SerialId(1) val iVersion: Short = 3, @SerialId(1) val iVersion: Short = 3,
@SerialId(2) val cPacketType: Byte = 0, @SerialId(2) val cPacketType: Byte = 0,
@SerialId(3) val iMessageType: Int = 0, @SerialId(3) val iMessageType: Int = 0,
@SerialId(4) val iRequestId: Int = nextRequestPacketRequestId(), @SerialId(4) val iRequestId: Int,
@SerialId(5) val sServantName: String = "", @SerialId(5) val sServantName: String = "",
@SerialId(6) val sFuncName: String = "", @SerialId(6) val sFuncName: String = "",
@SerialId(7) val sBuffer: ByteArray = EMPTY_BYTE_ARRAY, @SerialId(7) val sBuffer: ByteArray = EMPTY_BYTE_ARRAY,
@SerialId(8) val iTimeout: Int = 0, @SerialId(8) val iTimeout: Int = 0,
@SerialId(9) val context: Map<String, String> = EMPTY_MAP, @SerialId(9) val context: Map<String, String> = EMPTY_MAP,
@SerialId(10) val status: Map<String, String> = EMPTY_MAP @SerialId(10) val status: Map<String, String> = EMPTY_MAP
) : JceStruct { ) : JceStruct
}
private val requestPacketRequestId: AtomicInt = atomic(1921334513)
internal fun nextRequestPacketRequestId(): Int = requestPacketRequestId.getAndAdd(2)
@Serializable @Serializable
internal class RequestDataVersion3( internal class RequestDataVersion3(
......
...@@ -18,7 +18,7 @@ internal class MsgSvc : ProtoBuf { ...@@ -18,7 +18,7 @@ internal class MsgSvc : ProtoBuf {
@SerialId(1) val result: Int = 0, @SerialId(1) val result: Int = 0,
@SerialId(2) val errmsg: String = "", @SerialId(2) val errmsg: String = "",
@SerialId(3) val syncCookie: ByteArray = EMPTY_BYTE_ARRAY, @SerialId(3) val syncCookie: ByteArray = EMPTY_BYTE_ARRAY,
@SerialId(4) val syncFlag: Int /* enum */ = 0, @SerialId(4) val syncFlag: SyncFlag,
@SerialId(5) val uinPairMsgs: List<MsgComm.UinPairMsg>? = null, @SerialId(5) val uinPairMsgs: List<MsgComm.UinPairMsg>? = null,
@SerialId(6) val bindUin: Long = 0L, @SerialId(6) val bindUin: Long = 0L,
@SerialId(7) val msgRspType: Int = 0, @SerialId(7) val msgRspType: Int = 0,
...@@ -147,9 +147,15 @@ internal class MsgSvc : ProtoBuf { ...@@ -147,9 +147,15 @@ internal class MsgSvc : ProtoBuf {
@SerialId(2) val groupWithDraw: List<PbGroupMsgWithDrawReq>? = null @SerialId(2) val groupWithDraw: List<PbGroupMsgWithDrawReq>? = null
) : ProtoBuf ) : ProtoBuf
internal enum class SyncFlag {
START,
CONTINUE,
STOP
}
@Serializable @Serializable
internal class PbGetMsgReq( internal class PbGetMsgReq(
@SerialId(1) val syncFlag: Int /* enum */ = 0, @SerialId(1) val syncFlag: SyncFlag,
@SerialId(2) val syncCookie: ByteArray = EMPTY_BYTE_ARRAY, @SerialId(2) val syncCookie: ByteArray = EMPTY_BYTE_ARRAY,
@SerialId(3) val rambleFlag: Int = 1, @SerialId(3) val rambleFlag: Int = 1,
@SerialId(4) val latestRambleNumber: Int = 20, @SerialId(4) val latestRambleNumber: Int = 20,
......
...@@ -3,14 +3,33 @@ package net.mamoe.mirai.qqandroid.network.protocol.data.proto ...@@ -3,14 +3,33 @@ package net.mamoe.mirai.qqandroid.network.protocol.data.proto
import kotlinx.serialization.SerialId import kotlinx.serialization.SerialId
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import net.mamoe.mirai.qqandroid.io.ProtoBuf import net.mamoe.mirai.qqandroid.io.ProtoBuf
import kotlin.random.Random
@Serializable @Serializable
class SyncCookie( class SyncCookie(
@SerialId(2) val time: Long, @SerialId(1) val time1: Long? = null, // 1580277992
@SerialId(3) val unknown1: Long = 2994099792, @SerialId(2) val time: Long, // 1580277992
@SerialId(4) val unknown2: Long = 3497826378, @SerialId(3) val unknown1: Long = Random.nextLong(),// 678328038
@SerialId(5) val const1: Long = 1680172298, @SerialId(4) val unknown2: Long = Random.nextLong(), // 1687142153
@SerialId(6) val const2: Long = 2424173273, @SerialId(5) val const1: Long = Random.nextLong(), // 1458467940
@SerialId(7) val unknown3: Long = 0, @SerialId(11) val const2: Long = Random.nextLong(), // 2683038258
@SerialId(8) val unknown4: Long = 0 @SerialId(12) val unknown3: Long = 0x1d,
) : ProtoBuf @SerialId(13) val lastSyncTime: Long? = null,
\ No newline at end of file @SerialId(14) val unknown4: Long = 0
) : ProtoBuf
/*
@Serializable
class SyncCookie(
@SerialId(1) val time1: Long? = null, // 1580277992
@SerialId(2) val time: Long, // 1580277992
@SerialId(3) val unknown1: Long = 678328038,// 678328038
@SerialId(4) val unknown2: Long = 1687142153, // 1687142153
@SerialId(5) val const1: Long = 1458467940, // 1458467940
@SerialId(11) val const2: Long = 2683038258, // 2683038258
@SerialId(12) val unknown3: Long = 0x1d,
@SerialId(13) val lastSyncTime: Long? = null,
@SerialId(14) val unknown4: Long = 0
) : ProtoBuf
*/
\ No newline at end of file
...@@ -87,9 +87,9 @@ internal inline fun PacketFactory<*>.buildOutgoingUniPacket( ...@@ -87,9 +87,9 @@ internal inline fun PacketFactory<*>.buildOutgoingUniPacket(
commandName: String = this.commandName, commandName: String = this.commandName,
key: ByteArray = client.wLoginSigInfo.d2Key, key: ByteArray = client.wLoginSigInfo.d2Key,
extraData: ByteReadPacket = BRP_STUB, extraData: ByteReadPacket = BRP_STUB,
sequenceId: Int = client.nextSsoSequenceId(),
body: BytePacketBuilder.(sequenceId: Int) -> Unit body: BytePacketBuilder.(sequenceId: Int) -> Unit
): OutgoingPacket { ): OutgoingPacket {
val sequenceId: Int = client.nextSsoSequenceId()
return OutgoingPacket(name, commandName, sequenceId, buildPacket { return OutgoingPacket(name, commandName, sequenceId, buildPacket {
writeIntLVPacket(lengthOffset = { it + 4 }) { writeIntLVPacket(lengthOffset = { it + 4 }) {
......
...@@ -10,6 +10,7 @@ import net.mamoe.mirai.qqandroid.network.protocol.data.jce.RequestPacket ...@@ -10,6 +10,7 @@ import net.mamoe.mirai.qqandroid.network.protocol.data.jce.RequestPacket
import net.mamoe.mirai.qqandroid.network.protocol.packet.chat.receive.MessageSvc import net.mamoe.mirai.qqandroid.network.protocol.packet.chat.receive.MessageSvc
import net.mamoe.mirai.qqandroid.network.protocol.packet.chat.receive.OnlinePush import net.mamoe.mirai.qqandroid.network.protocol.packet.chat.receive.OnlinePush
import net.mamoe.mirai.qqandroid.network.protocol.packet.list.FriendList import net.mamoe.mirai.qqandroid.network.protocol.packet.list.FriendList
import net.mamoe.mirai.qqandroid.network.protocol.packet.login.ConfigPushSvc
import net.mamoe.mirai.qqandroid.network.protocol.packet.login.LoginPacket import net.mamoe.mirai.qqandroid.network.protocol.packet.login.LoginPacket
import net.mamoe.mirai.qqandroid.network.protocol.packet.login.StatSvc import net.mamoe.mirai.qqandroid.network.protocol.packet.login.StatSvc
import net.mamoe.mirai.utils.DefaultLogger import net.mamoe.mirai.utils.DefaultLogger
...@@ -67,7 +68,8 @@ internal object KnownPacketFactories : List<PacketFactory<*>> by mutableListOf( ...@@ -67,7 +68,8 @@ internal object KnownPacketFactories : List<PacketFactory<*>> by mutableListOf(
MessageSvc.PushForceOffline, MessageSvc.PushForceOffline,
MessageSvc.PbSendMsg, MessageSvc.PbSendMsg,
FriendList.GetFriendGroupList, FriendList.GetFriendGroupList,
FriendList.GetTroopListSimplify FriendList.GetTroopListSimplify,
ConfigPushSvc.PushReq
) { ) {
// SvcReqMSFLoginNotify 自己的其他设备上限 // SvcReqMSFLoginNotify 自己的其他设备上限
// MessageSvc.PushReaded 电脑阅读了别人的消息, 告知手机 // MessageSvc.PushReaded 电脑阅读了别人的消息, 告知手机
...@@ -194,11 +196,14 @@ internal object KnownPacketFactories : List<PacketFactory<*>> by mutableListOf( ...@@ -194,11 +196,14 @@ internal object KnownPacketFactories : List<PacketFactory<*>> by mutableListOf(
PacketLogger.verbose("sequenceId = $ssoSequenceId") PacketLogger.verbose("sequenceId = $ssoSequenceId")
check(readInt() == 0) check(readInt() == 0)
val extraData = readBytes(readInt() - 4) val extraData = readBytes(readInt() - 4)
PacketLogger.verbose("sso(inner)extraData = ${extraData.toUHexString()}") PacketLogger.verbose("(sso/inner)extraData = ${extraData.toUHexString()}")
commandName = readString(readInt() - 4) commandName = readString(readInt() - 4)
bot.client.outgoingPacketUnknownValue = readBytes(readInt() - 4) bot.client.outgoingPacketUnknownValue = readBytes(readInt() - 4)
if (commandName == "ConfigPushSvc.PushReq") {
bot.client.configPushSvcPushReqSequenceId = ssoSequenceId
}
dataCompressed = readInt() dataCompressed = readInt()
} }
......
...@@ -24,9 +24,11 @@ import net.mamoe.mirai.qqandroid.network.protocol.packet.PacketFactory ...@@ -24,9 +24,11 @@ import net.mamoe.mirai.qqandroid.network.protocol.packet.PacketFactory
import net.mamoe.mirai.qqandroid.network.protocol.packet.buildOutgoingUniPacket import net.mamoe.mirai.qqandroid.network.protocol.packet.buildOutgoingUniPacket
import net.mamoe.mirai.qqandroid.utils.toMessageChain import net.mamoe.mirai.qqandroid.utils.toMessageChain
import net.mamoe.mirai.qqandroid.utils.toRichTextElems import net.mamoe.mirai.qqandroid.utils.toRichTextElems
import net.mamoe.mirai.utils.MiraiInternalAPI
import net.mamoe.mirai.utils.cryptor.contentToString import net.mamoe.mirai.utils.cryptor.contentToString
import net.mamoe.mirai.utils.currentTimeSeconds import net.mamoe.mirai.utils.currentTimeSeconds
import net.mamoe.mirai.utils.io.hexToBytes import net.mamoe.mirai.utils.io.hexToBytes
import net.mamoe.mirai.utils.io.toUHexString
import kotlin.math.absoluteValue import kotlin.math.absoluteValue
import kotlin.random.Random import kotlin.random.Random
...@@ -43,7 +45,7 @@ internal class MessageSvc { ...@@ -43,7 +45,7 @@ internal class MessageSvc {
override suspend fun QQAndroidBot.handle(packet: RequestPushNotify) { override suspend fun QQAndroidBot.handle(packet: RequestPushNotify) {
network.run { network.run {
PbGetMsg(client, packet.stMsgInfo?.uMsgTime ?: 0).sendAndExpect<MultiPacket<FriendMessage>>() PbGetMsg(client, MsgSvc.SyncFlag.START, packet.stMsgInfo?.uMsgTime ?: 0).sendAndExpect<MultiPacket<FriendMessage>>()
} }
} }
...@@ -53,17 +55,19 @@ internal class MessageSvc { ...@@ -53,17 +55,19 @@ internal class MessageSvc {
/** /**
* 获取好友消息和消息记录 * 获取好友消息和消息记录
*/ */
internal object PbGetMsg : PacketFactory<MultiPacket<FriendMessage>>("MessageSvc.PbGetMsg") { @UseExperimental(MiraiInternalAPI::class)
internal object PbGetMsg : PacketFactory<PbGetMsg.Response>("MessageSvc.PbGetMsg") {
val EXTRA_DATA = val EXTRA_DATA =
"08 00 12 33 6D 6F 64 65 6C 3A 78 69 61 6F 6D 69 20 36 3B 6F 73 3A 32 32 3B 76 65 72 73 69 6F 6E 3A 76 32 6D 61 6E 3A 78 69 61 6F 6D 69 73 79 73 3A 4C 4D 59 34 38 5A 18 E4 E1 A4 FF FE 2D 20 E9 E1 A4 FF FE 2D 28 A8 E1 A4 FF FE 2D 30 99 E1 A4 FF FE 2D".hexToBytes() "08 00 12 33 6D 6F 64 65 6C 3A 78 69 67 6F 6D 69 20 36 3B 6F 73 3A 32 32 3B 76 65 72 73 69 6F 6E 3A 76 32 6D 61 6E 3A 78 69 61 6F 6D 69 73 79 73 3A 4C 4D 59 34 38 5A 18 E4 E1 A4 FF FE 2D 20 E9 E1 A4 FF FE 2D 28 A8 E1 A4 FF FE 2D 30 99 E1 A4 FF FE 2D".hexToBytes()
operator fun invoke( operator fun invoke(
client: QQAndroidClient, client: QQAndroidClient,
syncFlag: MsgSvc.SyncFlag = MsgSvc.SyncFlag.START,
msgTime: Long //PbPushMsg.msg.msgHead.msgTime msgTime: Long //PbPushMsg.msg.msgHead.msgTime
): OutgoingPacket = buildOutgoingUniPacket( ): OutgoingPacket = buildOutgoingUniPacket(
client//, client
// extraData = EXTRA_DATA.toReadPacket()
) { ) {
println("syncCookie=${client.c2cMessageSync.syncCookie?.toUHexString()}")
writeProtoBuf( writeProtoBuf(
MsgSvc.PbGetMsgReq.serializer(), MsgSvc.PbGetMsgReq.serializer(),
MsgSvc.PbGetMsgReq( MsgSvc.PbGetMsgReq(
...@@ -74,10 +78,10 @@ internal class MessageSvc { ...@@ -74,10 +78,10 @@ internal class MessageSvc {
otherRambleNumber = 3, otherRambleNumber = 3,
onlineSyncFlag = 1, onlineSyncFlag = 1,
whisperSessionId = 0, whisperSessionId = 0,
syncFlag = syncFlag,
// serverBuf = from.serverBuf ?: EMPTY_BYTE_ARRAY, // serverBuf = from.serverBuf ?: EMPTY_BYTE_ARRAY,
syncCookie = client.c2cMessageSync.syncCookie syncCookie = client.c2cMessageSync.syncCookie
?: SyncCookie(msgTime).toByteArray(SyncCookie.serializer()).also { client.c2cMessageSync.syncCookie = it }, ?: SyncCookie(time = Random.nextLong()).toByteArray(SyncCookie.serializer())//.also { client.c2cMessageSync.syncCookie = it },
syncFlag = 1
// syncFlag = client.c2cMessageSync.syncFlag, // syncFlag = client.c2cMessageSync.syncFlag,
//msgCtrlBuf = client.c2cMessageSync.msgCtrlBuf, //msgCtrlBuf = client.c2cMessageSync.msgCtrlBuf,
//pubaccountCookie = client.c2cMessageSync.pubAccountCookie //pubaccountCookie = client.c2cMessageSync.pubAccountCookie
...@@ -85,25 +89,40 @@ internal class MessageSvc { ...@@ -85,25 +89,40 @@ internal class MessageSvc {
) )
} }
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): MultiPacket<FriendMessage> {
@UseExperimental(MiraiInternalAPI::class)
internal class GetMsgSuccess(delegate: MutableList<FriendMessage>) : Response(MsgSvc.SyncFlag.STOP, delegate)
/**
* 不要直接 expect 这个 class. 它可能
*/
@MiraiInternalAPI
open class Response(internal val syncFlagFromServer: MsgSvc.SyncFlag, delegate: MutableList<FriendMessage>) : MultiPacket<FriendMessage>(delegate) {
override fun toString(): String {
return "MessageSvc.PbGetMsg.Response($syncFlagFromServer=$syncFlagFromServer, messages=List(size=${this.size}))"
}
}
@UseExperimental(MiraiInternalAPI::class)
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): Response {
// 00 00 01 0F 08 00 12 00 1A 34 08 FF C1 C4 F1 05 10 FF C1 C4 F1 05 18 E6 ED B9 C3 02 20 89 FE BE A4 06 28 8A CA 91 D1 0C 48 9B A5 BD 9B 0A 58 DE 9D 99 F8 08 60 1D 68 FF C1 C4 F1 05 70 00 20 02 2A 9D 01 08 F3 C1 C4 F1 05 10 A2 FF 8C F0 03 18 01 22 8A 01 0A 2A 08 A2 FF 8C F0 03 10 DD F1 92 B7 07 18 A6 01 20 0B 28 AE F9 01 30 F4 C1 C4 F1 05 38 A7 E3 D8 D4 84 80 80 80 01 B8 01 CD B5 01 12 08 08 01 10 00 18 00 20 00 1A 52 0A 50 0A 27 08 00 10 F4 C1 C4 F1 05 18 A7 E3 D8 D4 04 20 00 28 0C 30 00 38 86 01 40 22 4A 0C E5 BE AE E8 BD AF E9 9B 85 E9 BB 91 12 08 0A 06 0A 04 4E 4D 53 4C 12 15 AA 02 12 9A 01 0F 80 01 01 C8 01 00 F0 01 00 F8 01 00 90 02 00 12 04 4A 02 08 00 30 01 2A 15 08 97 A2 C1 F1 05 10 95 A6 F5 E5 0C 18 01 30 01 40 01 48 81 01 2A 10 08 D3 F7 B5 F1 05 10 DD F1 92 B7 07 18 01 30 01 38 00 42 00 48 00 // 00 00 01 0F 08 00 12 00 1A 34 08 FF C1 C4 F1 05 10 FF C1 C4 F1 05 18 E6 ED B9 C3 02 20 89 FE BE A4 06 28 8A CA 91 D1 0C 48 9B A5 BD 9B 0A 58 DE 9D 99 F8 08 60 1D 68 FF C1 C4 F1 05 70 00 20 02 2A 9D 01 08 F3 C1 C4 F1 05 10 A2 FF 8C F0 03 18 01 22 8A 01 0A 2A 08 A2 FF 8C F0 03 10 DD F1 92 B7 07 18 A6 01 20 0B 28 AE F9 01 30 F4 C1 C4 F1 05 38 A7 E3 D8 D4 84 80 80 80 01 B8 01 CD B5 01 12 08 08 01 10 00 18 00 20 00 1A 52 0A 50 0A 27 08 00 10 F4 C1 C4 F1 05 18 A7 E3 D8 D4 04 20 00 28 0C 30 00 38 86 01 40 22 4A 0C E5 BE AE E8 BD AF E9 9B 85 E9 BB 91 12 08 0A 06 0A 04 4E 4D 53 4C 12 15 AA 02 12 9A 01 0F 80 01 01 C8 01 00 F0 01 00 F8 01 00 90 02 00 12 04 4A 02 08 00 30 01 2A 15 08 97 A2 C1 F1 05 10 95 A6 F5 E5 0C 18 01 30 01 40 01 48 81 01 2A 10 08 D3 F7 B5 F1 05 10 DD F1 92 B7 07 18 01 30 01 38 00 42 00 48 00
discardExact(4) discardExact(4)
val resp = readProtoBuf(MsgSvc.PbGetMsgResp.serializer()) val resp = readProtoBuf(MsgSvc.PbGetMsgResp.serializer())
if (resp.result != 0) { if (resp.result != 0) {
return MultiPacket(emptyList()) println("!!! Result=${resp.result} !!!: " + resp.contentToString())
return GetMsgSuccess(mutableListOf())
} }
bot.client.c2cMessageSync.syncCookie = resp.syncCookie bot.client.c2cMessageSync.syncCookie = resp.syncCookie
bot.client.c2cMessageSync.pubAccountCookie = resp.pubAccountCookie bot.client.c2cMessageSync.pubAccountCookie = resp.pubAccountCookie
bot.client.c2cMessageSync.syncFlag = resp.syncFlag
bot.client.c2cMessageSync.msgCtrlBuf = resp.msgCtrlBuf bot.client.c2cMessageSync.msgCtrlBuf = resp.msgCtrlBuf
println(resp.contentToString())
if (resp.uinPairMsgs == null) { if (resp.uinPairMsgs == null) {
return MultiPacket(emptyList()) return GetMsgSuccess(mutableListOf())
} }
return MultiPacket(resp.uinPairMsgs.asSequence().flatMap { it.msg.asSequence() }.mapNotNull {
val messages = resp.uinPairMsgs.asSequence().flatMap { it.msg.asSequence() }.mapNotNull {
when (it.msgHead.msgType) { when (it.msgHead.msgType) {
166 -> { 166 -> {
FriendMessage( FriendMessage(
...@@ -115,10 +134,29 @@ internal class MessageSvc { ...@@ -115,10 +134,29 @@ internal class MessageSvc {
} }
else -> null else -> null
} }
}.toList()) }.toMutableList()
if (resp.syncFlag == MsgSvc.SyncFlag.STOP) {
return GetMsgSuccess(messages)
}
return Response(resp.syncFlag, messages)
}
override suspend fun QQAndroidBot.handle(packet: Response) {
when (packet.syncFlagFromServer) {
MsgSvc.SyncFlag.STOP,
MsgSvc.SyncFlag.START -> return
MsgSvc.SyncFlag.CONTINUE -> {
network.run {
PbGetMsg(client, MsgSvc.SyncFlag.CONTINUE, currentTimeSeconds)
}
return
}
}
} }
} }
/** /**
* 被挤下线 * 被挤下线
*/ */
...@@ -165,7 +203,7 @@ internal class MessageSvc { ...@@ -165,7 +203,7 @@ internal class MessageSvc {
msgSeq = client.atomicNextMessageSequenceId(), msgSeq = client.atomicNextMessageSequenceId(),
msgRand = Random.nextInt().absoluteValue, msgRand = Random.nextInt().absoluteValue,
syncCookie = client.c2cMessageSync.syncCookie?.takeIf { it.isNotEmpty() } syncCookie = client.c2cMessageSync.syncCookie?.takeIf { it.isNotEmpty() }
?: SyncCookie(currentTimeSeconds).toByteArray(SyncCookie.serializer()) ?: SyncCookie(time = currentTimeSeconds).toByteArray(SyncCookie.serializer())
// msgVia = 1 // msgVia = 1
) )
) )
...@@ -192,9 +230,10 @@ internal class MessageSvc { ...@@ -192,9 +230,10 @@ internal class MessageSvc {
elems = message.toRichTextElems() elems = message.toRichTextElems()
) )
), ),
msgSeq = client.atomicNextMessageSequenceId(), msgSeq = client.atomicNextMessageSequenceId()
msgRand = 123, // msgRand = 123
syncCookie = client.c2cMessageSync.syncCookie?.takeIf { it.isNotEmpty() } ?: byteArrayOf() //syncCookie = client.c2cMessageSync.syncCookie?.takeIf { it.isNotEmpty() } ?:
//SyncCookie(currentTimeSeconds, Random.nextLong().absoluteValue, Random.nextLong().absoluteValue).toByteArray(SyncCookie.serializer())
// msgVia = 1 // msgVia = 1
) )
) )
......
...@@ -11,21 +11,12 @@ import net.mamoe.mirai.qqandroid.io.serialization.toByteArray ...@@ -11,21 +11,12 @@ import net.mamoe.mirai.qqandroid.io.serialization.toByteArray
import net.mamoe.mirai.qqandroid.io.serialization.writeJceStruct import net.mamoe.mirai.qqandroid.io.serialization.writeJceStruct
import net.mamoe.mirai.qqandroid.network.QQAndroidClient import net.mamoe.mirai.qqandroid.network.QQAndroidClient
import net.mamoe.mirai.qqandroid.network.protocol.data.jce.* import net.mamoe.mirai.qqandroid.network.protocol.data.jce.*
import net.mamoe.mirai.qqandroid.network.protocol.data.jce.FriendInfo
import net.mamoe.mirai.qqandroid.network.protocol.data.jce.GetFriendListReq
import net.mamoe.mirai.qqandroid.network.protocol.data.jce.GetFriendListResp
import net.mamoe.mirai.qqandroid.network.protocol.data.jce.GetTroopListReqV2Simplify
import net.mamoe.mirai.qqandroid.network.protocol.data.jce.RequestPacket
import net.mamoe.mirai.qqandroid.network.protocol.data.proto.Vec0xd50 import net.mamoe.mirai.qqandroid.network.protocol.data.proto.Vec0xd50
import net.mamoe.mirai.qqandroid.network.protocol.packet.EMPTY_BYTE_ARRAY import net.mamoe.mirai.qqandroid.network.protocol.packet.EMPTY_BYTE_ARRAY
import net.mamoe.mirai.qqandroid.network.protocol.packet.OutgoingPacket import net.mamoe.mirai.qqandroid.network.protocol.packet.OutgoingPacket
import net.mamoe.mirai.qqandroid.network.protocol.packet.PacketFactory import net.mamoe.mirai.qqandroid.network.protocol.packet.PacketFactory
import net.mamoe.mirai.qqandroid.network.protocol.packet.buildOutgoingUniPacket import net.mamoe.mirai.qqandroid.network.protocol.packet.buildOutgoingUniPacket
import net.mamoe.mirai.qqandroid.network.protocol.packet.list.FriendList.GetFriendGroupList.decode
import net.mamoe.mirai.utils.cryptor.contentToString
import net.mamoe.mirai.utils.io.discardExact import net.mamoe.mirai.utils.io.discardExact
import net.mamoe.mirai.utils.io.readRemainingBytes
import net.mamoe.mirai.utils.io.toUHexString
internal class FriendList { internal class FriendList {
...@@ -48,6 +39,7 @@ internal class FriendList { ...@@ -48,6 +39,7 @@ internal class FriendList {
sFuncName = "GetTroopMemberListReq", sFuncName = "GetTroopMemberListReq",
sServantName = "mqq.IMService.FriendListServiceServantObj", sServantName = "mqq.IMService.FriendListServiceServantObj",
iVersion = 3, iVersion = 3,
iRequestId = client.nextRequestPacketRequestId(),
sBuffer = jceRequestSBuffer( sBuffer = jceRequestSBuffer(
"GTML", "GTML",
GetTroopMemberListReq.serializer(), GetTroopMemberListReq.serializer(),
...@@ -98,7 +90,7 @@ internal class FriendList { ...@@ -98,7 +90,7 @@ internal class FriendList {
iVersion = 3, iVersion = 3,
cPacketType = 0x00, cPacketType = 0x00,
iMessageType = 0x00000, iMessageType = 0x00000,
iRequestId = 1921334513, iRequestId = client.nextRequestPacketRequestId(),
sBuffer = jceRequestSBuffer( sBuffer = jceRequestSBuffer(
"GetTroopListReqV2Simplify", "GetTroopListReqV2Simplify",
GetTroopListReqV2Simplify.serializer(), GetTroopListReqV2Simplify.serializer(),
...@@ -109,6 +101,7 @@ internal class FriendList { ...@@ -109,6 +101,7 @@ internal class FriendList {
shVersion = 7, shVersion = 7,
dwCompanyId = 0, dwCompanyId = 0,
versionNum = 1, versionNum = 1,
vecGroupInfo = listOf(),
getLongGroupName = 1 getLongGroupName = 1
) )
) )
......
package net.mamoe.mirai.qqandroid.network.protocol.packet.login
import kotlinx.io.core.ByteReadPacket
import kotlinx.io.core.discardExact
import net.mamoe.mirai.qqandroid.QQAndroidBot
import net.mamoe.mirai.qqandroid.io.serialization.JceCharset
import net.mamoe.mirai.qqandroid.io.serialization.decodeUniPacket
import net.mamoe.mirai.qqandroid.io.serialization.jceRequestSBuffer
import net.mamoe.mirai.qqandroid.io.serialization.writeJceStruct
import net.mamoe.mirai.qqandroid.network.protocol.data.jce.PushResp
import net.mamoe.mirai.qqandroid.network.protocol.data.jce.RequestPacket
import net.mamoe.mirai.qqandroid.network.protocol.packet.PacketFactory
import net.mamoe.mirai.qqandroid.network.protocol.packet.buildOutgoingUniPacket
import net.mamoe.mirai.utils.cryptor.contentToString
import net.mamoe.mirai.utils.io.debugPrintThis
import net.mamoe.mirai.qqandroid.network.protocol.data.jce.PushReq as PushReqJceStruct
internal class ConfigPushSvc {
object PushReq : PacketFactory<PushReqJceStruct>("ConfigPushSvc.PushReq") {
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): PushReqJceStruct {
discardExact(4)
val pushReq = decodeUniPacket(PushReqJceStruct.serializer())
println(pushReq.contentToString())
return pushReq
}
override suspend fun QQAndroidBot.handle(packet: PushReqJceStruct) {
network.run {
buildOutgoingUniPacket(
client,
sequenceId = client.configPushSvcPushReqSequenceId.also { println("configPushSvcPushReqSequenceId=${client.configPushSvcPushReqSequenceId}") },
commandName = "ConfigPushSvc.PushResp",
name = "ConfigPushSvc.PushResp"
) {
writeJceStruct(
RequestPacket.serializer(),
RequestPacket(
iRequestId = 0,
iVersion = 3,
sServantName = "QQService.ConfigPushSvc.MainServant",
sFuncName = "PushResp",
sBuffer = jceRequestSBuffer(
"PushResp",
PushResp.serializer(),
PushResp(
type = packet.type,
seq = packet.seq,
jcebuf = if (packet.type == 3) packet.jcebuf else null
)
)
),
charset = JceCharset.UTF8
)
writePacket(this.build().debugPrintThis())
}.sendWithoutExpect()
}
}
}
}
\ No newline at end of file
...@@ -59,6 +59,7 @@ internal class StatSvc { ...@@ -59,6 +59,7 @@ internal class StatSvc {
RequestPacket( RequestPacket(
sServantName = "PushService", sServantName = "PushService",
sFuncName = "SvcReqRegister", sFuncName = "SvcReqRegister",
iRequestId = 0,
sBuffer = jceRequestSBuffer( sBuffer = jceRequestSBuffer(
"SvcReqRegister", "SvcReqRegister",
SvcReqRegister.serializer(), SvcReqRegister.serializer(),
......
...@@ -126,7 +126,7 @@ fun ByteReadPacket.analysisOneFullPacket(): ByteReadPacket = debugIfFail("Failed ...@@ -126,7 +126,7 @@ fun ByteReadPacket.analysisOneFullPacket(): ByteReadPacket = debugIfFail("Failed
} else { } else {
//if (flag2 == 1) { //if (flag2 == 1) {
val loginExtraData = readBytes(readInt() - 4) val loginExtraData = readBytes(readInt() - 4)
loginExtraData.debugPrint("loginExtraData") loginExtraData.debugPrintThis("loginExtraData")
// } else { // } else {
// this.debugPrint() // this.debugPrint()
// error("未知 flag2") // error("未知 flag2")
...@@ -137,7 +137,7 @@ fun ByteReadPacket.analysisOneFullPacket(): ByteReadPacket = debugIfFail("Failed ...@@ -137,7 +137,7 @@ fun ByteReadPacket.analysisOneFullPacket(): ByteReadPacket = debugIfFail("Failed
println("uin=" + readString(readInt() - 4)) println("uin=" + readString(readInt() - 4))
println("// 解密 body") println("// 解密 body")
readRemainingBytes().tryDecrypt().toReadPacket().debugPrint("outer body decrypted").apply { readRemainingBytes().tryDecrypt().toReadPacket().debugPrintThis("outer body decrypted").apply {
when (flag1) { when (flag1) {
0x0A -> decodeSso() 0x0A -> decodeSso()
0x0B -> decodeUni() 0x0B -> decodeUni()
...@@ -148,7 +148,7 @@ fun ByteReadPacket.analysisOneFullPacket(): ByteReadPacket = debugIfFail("Failed ...@@ -148,7 +148,7 @@ fun ByteReadPacket.analysisOneFullPacket(): ByteReadPacket = debugIfFail("Failed
2 -> { 2 -> {
this.debugPrint("Oicq Request").apply { this.debugPrintThis("Oicq Request").apply {
/* /*
byte 2 // head flag byte 2 // head flag
short 27 + 2 + remaining.length short 27 + 2 + remaining.length
...@@ -259,7 +259,7 @@ fun ByteReadPacket.analysisOneFullPacket(): ByteReadPacket = debugIfFail("Failed ...@@ -259,7 +259,7 @@ fun ByteReadPacket.analysisOneFullPacket(): ByteReadPacket = debugIfFail("Failed
} }
} }
else -> { else -> {
this.debugPrint("uni packet") this.debugPrintThis("uni packet")
} }
} }
} }
...@@ -274,11 +274,8 @@ fun ByteReadPacket.decodeUni() { ...@@ -274,11 +274,8 @@ fun ByteReadPacket.decodeUni() {
println("// 尝试解 Uni") println("// 尝试解 Uni")
println("// head") println("// head")
//return //return
readBytes(readInt() - 4).debugPrint("head").toReadPacket().apply { readBytes(readInt() - 4).debugPrintThis("head").toReadPacket().apply {
val commandName = readString(readInt() - 4).also { PacketLogger.warning("commandName=$it") } val commandName = readString(readInt() - 4).also { PacketLogger.warning("commandName=$it") }
if(commandName.contains("GetTroopList")){
println("!\n".repeat(100))
}
println(commandName) println(commandName)
println(" unknown4Bytes=" + readBytes(readInt() - 4).toUHexString()) println(" unknown4Bytes=" + readBytes(readInt() - 4).toUHexString())
// 00 00 00 1A 43 6F 6E 66 69 67 50 75 73 68 53 76 63 2E 50 75 73 68 52 65 73 70 // 00 00 00 1A 43 6F 6E 66 69 67 50 75 73 68 53 76 63 2E 50 75 73 68 52 65 73 70
...@@ -286,7 +283,7 @@ fun ByteReadPacket.decodeUni() { ...@@ -286,7 +283,7 @@ fun ByteReadPacket.decodeUni() {
// 00 00 00 04 // 00 00 00 04
println(" extraData=" + readBytes(readInt() - 4).toUHexString()) println(" extraData=" + readBytes(readInt() - 4).toUHexString())
} }
readBytes(readInt() - 4).debugPrint("Real body").read { readBytes(readInt() - 4).debugPrintThis("Real body").read {
// real body // real body
//10 03 2C 3C 4C 56 23 51 51 53 65 72 76 69 63 65 2E 43 6F 6E 66 69 67 50 75 73 68 53 76 63 2E 4D 61 69 6E 53 65 72 76 61 6E 74 66 08 50 75 73 68 52 65 73 70 7D 00 00 1A 08 00 01 06 08 50 75 73 68 52 65 73 70 1D 00 00 09 0A 10 01 22 14 DA 6E B1 0B 8C 98 0C A8 0C //10 03 2C 3C 4C 56 23 51 51 53 65 72 76 69 63 65 2E 43 6F 6E 66 69 67 50 75 73 68 53 76 63 2E 4D 61 69 6E 53 65 72 76 61 6E 74 66 08 50 75 73 68 52 65 73 70 7D 00 00 1A 08 00 01 06 08 50 75 73 68 52 65 73 70 1D 00 00 09 0A 10 01 22 14 DA 6E B1 0B 8C 98 0C A8 0C
......
...@@ -53,7 +53,7 @@ fun ByteReadPacket.decodeMultiServerToClientPackets() { ...@@ -53,7 +53,7 @@ fun ByteReadPacket.decodeMultiServerToClientPackets() {
} }
private fun processFullPacketWithoutLength(packet: ByteReadPacket) { private fun processFullPacketWithoutLength(packet: ByteReadPacket) {
packet.debugPrint("正在处理").apply { packet.debugPrintThis("正在处理").apply {
require(remaining < Int.MAX_VALUE) { "rawInput is too long" } require(remaining < Int.MAX_VALUE) { "rawInput is too long" }
// login // login
val flag1 = readInt() val flag1 = readInt()
...@@ -86,7 +86,7 @@ private fun processFullPacketWithoutLength(packet: ByteReadPacket) { ...@@ -86,7 +86,7 @@ private fun processFullPacketWithoutLength(packet: ByteReadPacket) {
}).getOrElse { }).getOrElse {
PacketLogger.verbose("解密失败, 尝试其他各种key") PacketLogger.verbose("解密失败, 尝试其他各种key")
this.readBytes().tryDecryptOrNull()?.toReadPacket() this.readBytes().tryDecryptOrNull()?.toReadPacket()
}?.debugPrint("sso/uni body=")?.let { }?.debugPrintThis("sso/uni body=")?.let {
if (flag1 == 0x0A) { if (flag1 == 0x0A) {
parseSsoFrame(flag3, it) parseSsoFrame(flag3, it)
} else { } else {
...@@ -115,7 +115,7 @@ private fun processFullPacketWithoutLength(packet: ByteReadPacket) { ...@@ -115,7 +115,7 @@ private fun processFullPacketWithoutLength(packet: ByteReadPacket) {
} }
tlvMap[0x119]?.let { t119Data -> tlvMap[0x119]?.let { t119Data ->
t119Data.decryptBy(tgtgtKey).toReadPacket().debugPrint("0x119data").apply { t119Data.decryptBy(tgtgtKey).toReadPacket().debugPrintThis("0x119data").apply {
discardExact(2) // always discarded. 00 1C discardExact(2) // always discarded. 00 1C
// 00 1C // 00 1C
// 01 08 00 10 A1 73 76 98 64 E0 38 C6 C8 18 73 FA D3 85 DA D6 01 6A 00 30 1D 99 4A 28 7E B3 B8 AC 74 B9 C4 BB 6D BB 41 72 F7 5C 9F 0F 79 8A 82 4F 1F 69 34 6D 10 D6 BB E8 A3 4A 2B 5D F1 C7 05 3C F8 72 EF CF 67 E4 3C 94 01 06 00 78 B4 ED 9F 44 ED 10 18 A8 85 0A 8A 85 79 45 47 7F 25 AA EE 2C 53 83 80 0A B3 B0 47 3E 95 51 A4 AE 3E CA A0 1D B4 91 F7 BB 2E 94 76 A8 C8 97 02 C4 5B 15 02 B7 03 9A FC C2 58 6D 17 92 46 AE EB 2F 6F 65 B8 69 6C D6 9D AC 18 6F 07 53 AC FE FA BC BD CE 57 13 10 2D 5A C6 50 AA C2 AE 18 D4 FD CD F2 E0 D1 25 29 56 21 35 8F 01 9D D6 69 44 8F 06 D0 23 26 D3 0E E6 E6 B7 01 0C 00 10 73 32 61 4E 2C 72 35 58 68 28 47 3E 2B 6E 52 62 01 0A 00 48 A4 DA 48 FB B4 8D DA 7B 86 D7 A7 FE 01 1B 70 6F 54 F8 55 38 B0 AD 1B 0C 0B B9 F6 94 24 F8 9E 30 32 22 99 0C 22 CD 44 B8 B0 8A A8 65 E1 B8 F0 49 EF E1 23 D7 0D A3 F1 BB 52 B7 4B AF BD 50 EA BF 15 02 78 2B 8B 10 FB 15 01 0D 00 10 29 75 38 72 21 5D 3F 24 37 46 67 79 2B 65 6D 34 01 14 00 60 00 01 5E 19 65 8C 00 58 93 DD 4D 2C 2D 01 44 99 62 B8 7A EF 04 C5 71 0B F1 BE 4C F4 21 F2 97 B0 14 67 0E 14 9F D8 A2 0B 93 40 90 80 F3 59 7A 69 45 D7 D4 53 4C 08 3A 56 1D C9 95 36 2C 7C 5E EE 36 47 5F AE 26 72 76 FD FD 69 E6 0C 2D 3A E8 CF D4 8D 76 C9 17 C3 E3 CD 21 AB 04 6B 70 C5 EC EC 01 0E 00 10 56 48 3E 29 3A 5A 21 74 55 6A 2C 72 58 73 79 71 01 03 00 30 9B A6 5D 85 5C 40 7C 28 E7 05 A9 25 CA F5 FC C0 51 40 85 F3 2F D2 37 F9 09 A6 E6 56 7F 7A 2E 7D 9F B9 1C 00 65 55 D2 A9 60 03 77 AB 6A F5 3F CE 01 33 00 30 F4 3A A7 08 E2 04 FA C8 9D 54 49 DE 63 EA F0 A5 1C C4 03 57 51 B6 AE 0B 55 41 F8 AB 22 F1 DC A3 B0 73 08 55 14 02 BF FF 55 87 42 4C 23 70 91 6A 01 34 00 10 61 C7 02 3F 1D BE A6 27 2F 24 D4 92 95 68 71 EF 05 28 00 1A 7B 22 51 49 4D 5F 69 6E 76 69 74 61 74 69 6F 6E 5F 62 69 74 22 3A 22 31 22 7D 03 22 00 10 CE 1E 2E DC 69 24 4F 9B FF 2F 52 D8 8F 69 DD 40 01 1D 00 76 5F 5E 10 E2 34 36 79 27 23 53 4D 65 6B 6A 33 6D 7D 4E 3C 5F 00 60 00 01 5E 19 65 8C 00 58 67 00 9C 02 E4 BC DB A3 93 98 A1 ED 4C 91 08 6F 0C 06 E0 12 6A DC 14 5B 4D 20 7C 82 83 AE 94 53 A2 4A A0 35 FF 59 9D F3 EF 82 42 61 67 2A 31 E7 87 7E 74 E7 A3 E7 5C A8 3C 87 CF 40 6A 9F E5 F7 20 4E 56 C6 4F 1C 98 3A 8B A9 4F 1D 10 35 C2 3B A1 08 7A 89 0B 25 0C 63 01 1F 00 0A 00 01 51 80 00 00 03 84 00 00 01 38 00 0E 00 00 00 01 01 0A 00 27 8D 00 00 00 00 00 01 1A 00 13 02 5B 06 01 0E 73 74 65 61 6D 63 68 69 6E 61 2E 66 75 6E 05 22 00 14 00 00 00 00 76 E4 B8 DD AB 53 02 9F 5E 19 65 8C 20 02 ED BD 05 37 00 17 01 01 00 00 00 00 76 E4 B8 DD 04 AB 53 02 9F 5E 19 65 8C 20 02 ED BD 01 20 00 0A 4D 39 50 57 50 6E 4C 31 65 4F 01 6D 00 2C 31 7A 50 7A 63 72 70 4D 30 43 6E 31 37 4C 32 32 6E 77 2D 36 7A 4E 71 48 48 59 41 35 48 71 77 41 37 6D 76 4F 63 2D 4A 56 77 47 51 5F 05 12 03 5D 00 0E 00 0A 74 65 6E 70 61 79 2E 63 6F 6D 00 2C 6E 4A 72 55 55 74 63 2A 34 7A 32 76 31 66 6A 75 77 6F 6A 65 73 72 76 4F 68 70 66 45 76 4A 75 55 4B 6D 34 43 2D 76 74 38 4D 77 38 5F 00 00 00 11 6F 70 65 6E 6D 6F 62 69 6C 65 2E 71 71 2E 63 6F 6D 00 2C 78 59 35 65 62 4D 74 48 44 6D 30 53 6F 68 56 71 68 33 43 79 79 34 6F 63 65 4A 46 6A 51 58 65 68 30 44 61 75 55 30 6C 78 65 52 6B 5F 00 00 00 0B 64 6F 63 73 2E 71 71 2E 63 6F 6D 00 2C 64 6A 62 79 47 57 45 4F 34 58 34 6A 36 4A 73 48 45 65 6B 73 69 74 72 78 79 62 57 69 77 49 68 46 45 70 72 4A 59 4F 2D 6B 36 47 6F 5F 00 00 00 0E 63 6F 6E 6E 65 63 74 2E 71 71 2E 63 6F 6D 00 2C 64 4C 31 41 79 32 41 31 74 33 58 36 58 58 2A 74 33 64 4E 70 2A 31 61 2D 50 7A 65 57 67 48 70 2D 65 47 78 6B 59 74 71 62 69 6C 55 5F 00 00 00 0C 71 7A 6F 6E 65 2E 71 71 2E 63 6F 6D 00 2C 75 6A 55 5A 4F 6A 4F 48 52 61 75 6B 32 55 50 38 77 33 34 68 36 69 46 38 2A 77 4E 50 35 2D 66 54 75 37 67 39 56 67 44 57 2A 6B 6F 5F 00 00 00 0A 76 69 70 2E 71 71 2E 63 6F 6D 00 2C 37 47 31 44 6F 54 2D 4D 57 50 63 2D 62 43 46 68 63 62 32 56 38 6E 77 4A 75 41 51 63 54 39 77 45 49 62 57 43 4A 4B 44 4D 6C 6D 34 5F 00 00 00 0A 71 75 6E 2E 71 71 2E 63 6F 6D 00 2C 7A 73 70 5A 56 43 59 45 7A 35 2A 4F 6B 4E 68 6E 74 79 61 69 6E 6F 68 4D 32 6B 41 6C 2A 74 31 63 7A 48 57 77 30 41 6A 4B 50 4B 6B 5F 00 00 00 0B 67 61 6D 65 2E 71 71 2E 63 6F 6D 00 2C 32 6F 2D 51 53 36 65 43 70 37 6A 43 4E 34 6A 74 6E 47 4F 4B 33 67 73 32 63 4A 6F 56 71 58 65 44 48 61 55 39 65 34 2D 32 34 64 30 5F 00 00 00 0C 71 71 77 65 62 2E 71 71 2E 63 6F 6D 00 2C 63 54 4D 79 64 51 43 35 50 74 43 45 51 72 6F 33 53 54 41 66 7A 56 2D 44 76 46 56 35 58 6D 56 6B 49 31 68 4C 55 48 4E 65 76 56 38 5F 00 00 00 0D 6F 66 66 69 63 65 2E 71 71 2E 63 6F 6D 00 2C 6F 73 72 54 36 32 69 37 66 76 6D 49 50 64 6F 58 4B 48 74 38 58 52 59 56 77 72 7A 6E 69 31 58 7A 57 4C 77 2A 71 36 33 44 74 73 6F 5F 00 00 00 09 74 69 2E 71 71 2E 63 6F 6D 00 2C 41 61 77 4D 78 4D 32 79 58 51 47 75 72 75 55 6C 66 53 58 79 5A 57 48 53 78 52 57 58 50 74 6B 6B 4F 78 6F 66 4A 59 47 6C 71 68 34 5F 00 00 00 0B 6D 61 69 6C 2E 71 71 2E 63 6F 6D 00 2C 67 72 57 68 58 77 34 4C 6E 4B 49 4F 67 63 78 45 71 70 33 61 45 67 37 38 46 7A 77 4E 6D 4B 48 56 6E 6F 50 4C 4F 32 6D 57 6D 6E 38 5F 00 00 00 09 71 7A 6F 6E 65 2E 63 6F 6D 00 2C 72 61 47 79 51 35 54 72 4D 55 7A 6E 74 31 4E 52 44 2D 50 72 74 72 41 55 43 35 6A 61 2D 49 47 2D 73 77 4C 6D 49 51 51 41 44 4C 41 5F 00 00 00 0A 6D 6D 61 2E 71 71 2E 63 6F 6D 00 2C 39 73 2D 4F 51 30 67 76 39 42 6A 37 58 71 52 49 4E 30 35 46 32 64 4D 47 67 47 43 58 57 4A 62 68 63 30 38 63 7A 4B 52 76 6B 78 6B 5F 00 00 03 05 00 10 77 75 6E 54 5F 7E 66 7A 72 40 3C 6E 35 50 53 46 01 43 00 40 3A AE 30 87 81 3D EE BA 31 9C EA 9D 0D D4 73 B1 81 12 E0 94 71 73 7A B0 47 3D 09 47 E5 1B E1 E2 06 1A CB A4 E3 71 9E A6 EA 2A 73 5C C8 D3 B1 2A B1 C7 DA 04 A6 6D 12 26 DF 6B 8B EC C7 12 F8 E1 01 18 00 05 00 00 00 01 00 01 63 00 10 67 6B 60 23 24 6A 55 39 4E 58 24 5E 39 2B 7A 69 01 38 00 5E 00 00 00 09 01 06 00 27 8D 00 00 00 00 00 01 0A 00 24 EA 00 00 00 00 00 01 1C 00 1A 5E 00 00 00 00 00 01 02 00 01 51 80 00 00 00 00 01 03 00 00 1C 20 00 00 00 00 01 20 00 01 51 80 00 00 00 00 01 36 00 1B AF 80 00 00 00 00 01 43 00 1B AF 80 00 00 00 00 01 64 00 1B AF 80 00 00 00 00 01 30 00 0E 00 00 5E 19 65 8C 9F 02 53 AB 00 00 00 00 // 01 08 00 10 A1 73 76 98 64 E0 38 C6 C8 18 73 FA D3 85 DA D6 01 6A 00 30 1D 99 4A 28 7E B3 B8 AC 74 B9 C4 BB 6D BB 41 72 F7 5C 9F 0F 79 8A 82 4F 1F 69 34 6D 10 D6 BB E8 A3 4A 2B 5D F1 C7 05 3C F8 72 EF CF 67 E4 3C 94 01 06 00 78 B4 ED 9F 44 ED 10 18 A8 85 0A 8A 85 79 45 47 7F 25 AA EE 2C 53 83 80 0A B3 B0 47 3E 95 51 A4 AE 3E CA A0 1D B4 91 F7 BB 2E 94 76 A8 C8 97 02 C4 5B 15 02 B7 03 9A FC C2 58 6D 17 92 46 AE EB 2F 6F 65 B8 69 6C D6 9D AC 18 6F 07 53 AC FE FA BC BD CE 57 13 10 2D 5A C6 50 AA C2 AE 18 D4 FD CD F2 E0 D1 25 29 56 21 35 8F 01 9D D6 69 44 8F 06 D0 23 26 D3 0E E6 E6 B7 01 0C 00 10 73 32 61 4E 2C 72 35 58 68 28 47 3E 2B 6E 52 62 01 0A 00 48 A4 DA 48 FB B4 8D DA 7B 86 D7 A7 FE 01 1B 70 6F 54 F8 55 38 B0 AD 1B 0C 0B B9 F6 94 24 F8 9E 30 32 22 99 0C 22 CD 44 B8 B0 8A A8 65 E1 B8 F0 49 EF E1 23 D7 0D A3 F1 BB 52 B7 4B AF BD 50 EA BF 15 02 78 2B 8B 10 FB 15 01 0D 00 10 29 75 38 72 21 5D 3F 24 37 46 67 79 2B 65 6D 34 01 14 00 60 00 01 5E 19 65 8C 00 58 93 DD 4D 2C 2D 01 44 99 62 B8 7A EF 04 C5 71 0B F1 BE 4C F4 21 F2 97 B0 14 67 0E 14 9F D8 A2 0B 93 40 90 80 F3 59 7A 69 45 D7 D4 53 4C 08 3A 56 1D C9 95 36 2C 7C 5E EE 36 47 5F AE 26 72 76 FD FD 69 E6 0C 2D 3A E8 CF D4 8D 76 C9 17 C3 E3 CD 21 AB 04 6B 70 C5 EC EC 01 0E 00 10 56 48 3E 29 3A 5A 21 74 55 6A 2C 72 58 73 79 71 01 03 00 30 9B A6 5D 85 5C 40 7C 28 E7 05 A9 25 CA F5 FC C0 51 40 85 F3 2F D2 37 F9 09 A6 E6 56 7F 7A 2E 7D 9F B9 1C 00 65 55 D2 A9 60 03 77 AB 6A F5 3F CE 01 33 00 30 F4 3A A7 08 E2 04 FA C8 9D 54 49 DE 63 EA F0 A5 1C C4 03 57 51 B6 AE 0B 55 41 F8 AB 22 F1 DC A3 B0 73 08 55 14 02 BF FF 55 87 42 4C 23 70 91 6A 01 34 00 10 61 C7 02 3F 1D BE A6 27 2F 24 D4 92 95 68 71 EF 05 28 00 1A 7B 22 51 49 4D 5F 69 6E 76 69 74 61 74 69 6F 6E 5F 62 69 74 22 3A 22 31 22 7D 03 22 00 10 CE 1E 2E DC 69 24 4F 9B FF 2F 52 D8 8F 69 DD 40 01 1D 00 76 5F 5E 10 E2 34 36 79 27 23 53 4D 65 6B 6A 33 6D 7D 4E 3C 5F 00 60 00 01 5E 19 65 8C 00 58 67 00 9C 02 E4 BC DB A3 93 98 A1 ED 4C 91 08 6F 0C 06 E0 12 6A DC 14 5B 4D 20 7C 82 83 AE 94 53 A2 4A A0 35 FF 59 9D F3 EF 82 42 61 67 2A 31 E7 87 7E 74 E7 A3 E7 5C A8 3C 87 CF 40 6A 9F E5 F7 20 4E 56 C6 4F 1C 98 3A 8B A9 4F 1D 10 35 C2 3B A1 08 7A 89 0B 25 0C 63 01 1F 00 0A 00 01 51 80 00 00 03 84 00 00 01 38 00 0E 00 00 00 01 01 0A 00 27 8D 00 00 00 00 00 01 1A 00 13 02 5B 06 01 0E 73 74 65 61 6D 63 68 69 6E 61 2E 66 75 6E 05 22 00 14 00 00 00 00 76 E4 B8 DD AB 53 02 9F 5E 19 65 8C 20 02 ED BD 05 37 00 17 01 01 00 00 00 00 76 E4 B8 DD 04 AB 53 02 9F 5E 19 65 8C 20 02 ED BD 01 20 00 0A 4D 39 50 57 50 6E 4C 31 65 4F 01 6D 00 2C 31 7A 50 7A 63 72 70 4D 30 43 6E 31 37 4C 32 32 6E 77 2D 36 7A 4E 71 48 48 59 41 35 48 71 77 41 37 6D 76 4F 63 2D 4A 56 77 47 51 5F 05 12 03 5D 00 0E 00 0A 74 65 6E 70 61 79 2E 63 6F 6D 00 2C 6E 4A 72 55 55 74 63 2A 34 7A 32 76 31 66 6A 75 77 6F 6A 65 73 72 76 4F 68 70 66 45 76 4A 75 55 4B 6D 34 43 2D 76 74 38 4D 77 38 5F 00 00 00 11 6F 70 65 6E 6D 6F 62 69 6C 65 2E 71 71 2E 63 6F 6D 00 2C 78 59 35 65 62 4D 74 48 44 6D 30 53 6F 68 56 71 68 33 43 79 79 34 6F 63 65 4A 46 6A 51 58 65 68 30 44 61 75 55 30 6C 78 65 52 6B 5F 00 00 00 0B 64 6F 63 73 2E 71 71 2E 63 6F 6D 00 2C 64 6A 62 79 47 57 45 4F 34 58 34 6A 36 4A 73 48 45 65 6B 73 69 74 72 78 79 62 57 69 77 49 68 46 45 70 72 4A 59 4F 2D 6B 36 47 6F 5F 00 00 00 0E 63 6F 6E 6E 65 63 74 2E 71 71 2E 63 6F 6D 00 2C 64 4C 31 41 79 32 41 31 74 33 58 36 58 58 2A 74 33 64 4E 70 2A 31 61 2D 50 7A 65 57 67 48 70 2D 65 47 78 6B 59 74 71 62 69 6C 55 5F 00 00 00 0C 71 7A 6F 6E 65 2E 71 71 2E 63 6F 6D 00 2C 75 6A 55 5A 4F 6A 4F 48 52 61 75 6B 32 55 50 38 77 33 34 68 36 69 46 38 2A 77 4E 50 35 2D 66 54 75 37 67 39 56 67 44 57 2A 6B 6F 5F 00 00 00 0A 76 69 70 2E 71 71 2E 63 6F 6D 00 2C 37 47 31 44 6F 54 2D 4D 57 50 63 2D 62 43 46 68 63 62 32 56 38 6E 77 4A 75 41 51 63 54 39 77 45 49 62 57 43 4A 4B 44 4D 6C 6D 34 5F 00 00 00 0A 71 75 6E 2E 71 71 2E 63 6F 6D 00 2C 7A 73 70 5A 56 43 59 45 7A 35 2A 4F 6B 4E 68 6E 74 79 61 69 6E 6F 68 4D 32 6B 41 6C 2A 74 31 63 7A 48 57 77 30 41 6A 4B 50 4B 6B 5F 00 00 00 0B 67 61 6D 65 2E 71 71 2E 63 6F 6D 00 2C 32 6F 2D 51 53 36 65 43 70 37 6A 43 4E 34 6A 74 6E 47 4F 4B 33 67 73 32 63 4A 6F 56 71 58 65 44 48 61 55 39 65 34 2D 32 34 64 30 5F 00 00 00 0C 71 71 77 65 62 2E 71 71 2E 63 6F 6D 00 2C 63 54 4D 79 64 51 43 35 50 74 43 45 51 72 6F 33 53 54 41 66 7A 56 2D 44 76 46 56 35 58 6D 56 6B 49 31 68 4C 55 48 4E 65 76 56 38 5F 00 00 00 0D 6F 66 66 69 63 65 2E 71 71 2E 63 6F 6D 00 2C 6F 73 72 54 36 32 69 37 66 76 6D 49 50 64 6F 58 4B 48 74 38 58 52 59 56 77 72 7A 6E 69 31 58 7A 57 4C 77 2A 71 36 33 44 74 73 6F 5F 00 00 00 09 74 69 2E 71 71 2E 63 6F 6D 00 2C 41 61 77 4D 78 4D 32 79 58 51 47 75 72 75 55 6C 66 53 58 79 5A 57 48 53 78 52 57 58 50 74 6B 6B 4F 78 6F 66 4A 59 47 6C 71 68 34 5F 00 00 00 0B 6D 61 69 6C 2E 71 71 2E 63 6F 6D 00 2C 67 72 57 68 58 77 34 4C 6E 4B 49 4F 67 63 78 45 71 70 33 61 45 67 37 38 46 7A 77 4E 6D 4B 48 56 6E 6F 50 4C 4F 32 6D 57 6D 6E 38 5F 00 00 00 09 71 7A 6F 6E 65 2E 63 6F 6D 00 2C 72 61 47 79 51 35 54 72 4D 55 7A 6E 74 31 4E 52 44 2D 50 72 74 72 41 55 43 35 6A 61 2D 49 47 2D 73 77 4C 6D 49 51 51 41 44 4C 41 5F 00 00 00 0A 6D 6D 61 2E 71 71 2E 63 6F 6D 00 2C 39 73 2D 4F 51 30 67 76 39 42 6A 37 58 71 52 49 4E 30 35 46 32 64 4D 47 67 47 43 58 57 4A 62 68 63 30 38 63 7A 4B 52 76 6B 78 6B 5F 00 00 03 05 00 10 77 75 6E 54 5F 7E 66 7A 72 40 3C 6E 35 50 53 46 01 43 00 40 3A AE 30 87 81 3D EE BA 31 9C EA 9D 0D D4 73 B1 81 12 E0 94 71 73 7A B0 47 3D 09 47 E5 1B E1 E2 06 1A CB A4 E3 71 9E A6 EA 2A 73 5C C8 D3 B1 2A B1 C7 DA 04 A6 6D 12 26 DF 6B 8B EC C7 12 F8 E1 01 18 00 05 00 00 00 01 00 01 63 00 10 67 6B 60 23 24 6A 55 39 4E 58 24 5E 39 2B 7A 69 01 38 00 5E 00 00 00 09 01 06 00 27 8D 00 00 00 00 00 01 0A 00 24 EA 00 00 00 00 00 01 1C 00 1A 5E 00 00 00 00 00 01 02 00 01 51 80 00 00 00 00 01 03 00 00 1C 20 00 00 00 00 01 20 00 01 51 80 00 00 00 00 01 36 00 1B AF 80 00 00 00 00 01 43 00 1B AF 80 00 00 00 00 01 64 00 1B AF 80 00 00 00 00 01 30 00 0E 00 00 5E 19 65 8C 9F 02 53 AB 00 00 00 00
...@@ -219,9 +219,6 @@ private fun parseSsoFrame(flag3: Int, input: ByteReadPacket): KnownPacketFactori ...@@ -219,9 +219,6 @@ private fun parseSsoFrame(flag3: Int, input: ByteReadPacket): KnownPacketFactori
commandName = readString(readInt() - 4) commandName = readString(readInt() - 4)
DebugLogger.warning("commandName=$commandName") DebugLogger.warning("commandName=$commandName")
if(commandName.contains("GetTroopList")){
println("!\n".repeat(100))
}
val unknown = readBytes(readInt() - 4) val unknown = readBytes(readInt() - 4)
//if (unknown.toInt() != 0x02B05B8B) DebugLogger.debug("got new unknown: ${unknown.toUHexString()}") //if (unknown.toInt() != 0x02B05B8B) DebugLogger.debug("got new unknown: ${unknown.toUHexString()}")
......
...@@ -10,7 +10,7 @@ fun main(){ ...@@ -10,7 +10,7 @@ fun main(){
) )
File( File(
""" """
E:\Projects\QQAndroidFF\app\src\main\java\friendlist\ E:\Projects\QQAndroidFF\app\src\main\java\ConfigPush
""".trimIndent() """.trimIndent()
).listFiles()!!.forEach { ).listFiles()!!.forEach {
try { try {
......
...@@ -16,7 +16,7 @@ import net.mamoe.mirai.utils.cryptor.Decrypter ...@@ -16,7 +16,7 @@ import net.mamoe.mirai.utils.cryptor.Decrypter
import net.mamoe.mirai.utils.cryptor.DecrypterType import net.mamoe.mirai.utils.cryptor.DecrypterType
import net.mamoe.mirai.utils.cryptor.readProtoMap import net.mamoe.mirai.utils.cryptor.readProtoMap
import net.mamoe.mirai.utils.io.ByteArrayPool import net.mamoe.mirai.utils.io.ByteArrayPool
import net.mamoe.mirai.utils.io.debugPrint import net.mamoe.mirai.utils.io.debugPrintThis
import net.mamoe.mirai.utils.io.read import net.mamoe.mirai.utils.io.read
import net.mamoe.mirai.utils.io.toUHexString import net.mamoe.mirai.utils.io.toUHexString
...@@ -50,7 +50,7 @@ abstract class PacketFactory<out TPacket : Packet, TDecrypter : Decrypter>(val d ...@@ -50,7 +50,7 @@ abstract class PacketFactory<out TPacket : Packet, TDecrypter : Decrypter>(val d
val headLength = readInt() val headLength = readInt()
val protoLength = readInt() val protoLength = readInt()
if (debuggingTag != null) { if (debuggingTag != null) {
readBytes(headLength).debugPrint("$debuggingTag head") readBytes(headLength).debugPrintThis("$debuggingTag head")
} else { } else {
discardExact(headLength) discardExact(headLength)
} }
...@@ -58,7 +58,7 @@ abstract class PacketFactory<out TPacket : Packet, TDecrypter : Decrypter>(val d ...@@ -58,7 +58,7 @@ abstract class PacketFactory<out TPacket : Packet, TDecrypter : Decrypter>(val d
// println(ByteReadPacket(bytes).readProtoMap()) // println(ByteReadPacket(bytes).readProtoMap())
if (debuggingTag != null) { if (debuggingTag != null) {
bytes.read { readProtoMap() }.toString().debugPrint("$debuggingTag proto") bytes.read { readProtoMap() }.toString().debugPrintThis("$debuggingTag proto")
} }
return ProtoBuf.load(deserializer, bytes) return ProtoBuf.load(deserializer, bytes)
......
...@@ -15,7 +15,7 @@ import kotlinx.io.core.readAvailable ...@@ -15,7 +15,7 @@ import kotlinx.io.core.readAvailable
import kotlinx.io.pool.useInstance import kotlinx.io.pool.useInstance
import net.mamoe.mirai.contact.GroupId import net.mamoe.mirai.contact.GroupId
import net.mamoe.mirai.utils.io.ByteArrayPool import net.mamoe.mirai.utils.io.ByteArrayPool
import net.mamoe.mirai.utils.io.debugPrint import net.mamoe.mirai.utils.io.debugPrintThis
@Suppress("SpellCheckingInspection") @Suppress("SpellCheckingInspection")
...@@ -46,7 +46,7 @@ internal suspend inline fun HttpClient.postImage( ...@@ -46,7 +46,7 @@ internal suspend inline fun HttpClient.postImage(
userAgent("QQClient") userAgent("QQClient")
buildString().debugPrint("URL") buildString().debugPrintThis("URL")
} }
body = object : OutgoingContent.WriteChannelContent() { body = object : OutgoingContent.WriteChannelContent() {
......
...@@ -6,7 +6,7 @@ import kotlinx.io.core.ByteReadPacket ...@@ -6,7 +6,7 @@ import kotlinx.io.core.ByteReadPacket
import net.mamoe.mirai.Bot import net.mamoe.mirai.Bot
import net.mamoe.mirai.data.EventPacket import net.mamoe.mirai.data.EventPacket
import net.mamoe.mirai.utils.PacketVersion import net.mamoe.mirai.utils.PacketVersion
import net.mamoe.mirai.utils.io.debugPrint import net.mamoe.mirai.utils.io.debugPrintThis
data class GroupFileUploadPacket(inline val xmlMessage: String) : EventPacket data class GroupFileUploadPacket(inline val xmlMessage: String) : EventPacket
...@@ -14,7 +14,7 @@ data class GroupFileUploadPacket(inline val xmlMessage: String) : EventPacket ...@@ -14,7 +14,7 @@ data class GroupFileUploadPacket(inline val xmlMessage: String) : EventPacket
@PacketVersion(date = "2019.7.1", timVersion = "2.3.2 (21173)") @PacketVersion(date = "2019.7.1", timVersion = "2.3.2 (21173)")
internal object GroupFileUploadEventFactory : KnownEventParserAndHandler<GroupFileUploadPacket>(0x002Du) { internal object GroupFileUploadEventFactory : KnownEventParserAndHandler<GroupFileUploadPacket>(0x002Du) {
override suspend fun ByteReadPacket.parse(bot: Bot, identity: EventPacketIdentity): GroupFileUploadPacket { override suspend fun ByteReadPacket.parse(bot: Bot, identity: EventPacketIdentity): GroupFileUploadPacket {
this.debugPrint("GroupFileUploadPacket") this.debugPrintThis("GroupFileUploadPacket")
return GroupFileUploadPacket("") return GroupFileUploadPacket("")
/* /*
discardExact(60) discardExact(60)
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
package net.mamoe.mirai.timpc.network.packet.login package net.mamoe.mirai.timpc.network.packet.login
import kotlinx.io.core.* import kotlinx.io.core.*
import net.mamoe.mirai.network.BotNetworkHandler
import net.mamoe.mirai.data.Packet import net.mamoe.mirai.data.Packet
import net.mamoe.mirai.network.BotNetworkHandler
import net.mamoe.mirai.timpc.network.TIMProtocol import net.mamoe.mirai.timpc.network.TIMProtocol
import net.mamoe.mirai.timpc.network.packet.OutgoingPacket import net.mamoe.mirai.timpc.network.packet.OutgoingPacket
import net.mamoe.mirai.timpc.network.packet.PacketFactory import net.mamoe.mirai.timpc.network.packet.PacketFactory
...@@ -142,7 +142,7 @@ internal object CaptchaPacket : PacketFactory<CaptchaPacket.CaptchaResponse, Cap ...@@ -142,7 +142,7 @@ internal object CaptchaPacket : PacketFactory<CaptchaPacket.CaptchaResponse, Cap
} }
0x13u -> { 0x13u -> {
CaptchaResponse.Transmission().apply { CaptchaResponse.Transmission().apply {
with(debugPrint("验证码包")) { with(debugPrintThis("验证码包")) {
/* /*
* 00 05 01 00 00 01 23 * 00 05 01 00 00 01 23
* 00 40 A0 E9 2F 12 1D 2E B1 15 26 89 EB C3 F0 9A 0C 03 00 03 A0 F2 74 57 58 57 E9 7A 2B C7 52 5D BC D8 7B D5 A4 7C AD 33 85 85 39 88 D2 CE AD 68 36 2E F0 AE 19 E8 25 3A F7 3A AD BE 19 A9 E7 C4 B5 4C * 00 40 A0 E9 2F 12 1D 2E B1 15 26 89 EB C3 F0 9A 0C 03 00 03 A0 F2 74 57 58 57 E9 7A 2B C7 52 5D BC D8 7B D5 A4 7C AD 33 85 85 39 88 D2 CE AD 68 36 2E F0 AE 19 E8 25 3A F7 3A AD BE 19 A9 E7 C4 B5 4C
......
...@@ -5,11 +5,13 @@ package net.mamoe.mirai.data ...@@ -5,11 +5,13 @@ package net.mamoe.mirai.data
*/ */
interface Packet interface Packet
object NoPakcet : Packet
/** /**
* PacketFactory 可以一次解析多个包出来. 它们将会被分别广播. * PacketFactory 可以一次解析多个包出来. 它们将会被分别广播.
*/ */
class MultiPacket<P : Packet>(delegate: List<P>) : List<P> by delegate, Packet { open class MultiPacket<P : Packet>(internal val delegate: MutableList<P>) : List<P> by delegate, Packet {
override fun toString(): String { override fun toString(): String {
return "MultiPacket<${this.firstOrNull()?.let { it::class.simpleName }?: "?"}>" return "MultiPacket<${this.firstOrNull()?.let { it::class.simpleName } ?: "?"}>"
} }
} }
\ No newline at end of file
...@@ -19,19 +19,19 @@ fun Throwable.logStacktrace(message: String? = null) = DebugLogger.error(message ...@@ -19,19 +19,19 @@ fun Throwable.logStacktrace(message: String? = null) = DebugLogger.error(message
fun debugPrintln(any: Any?) = DebugLogger.debug(any) fun debugPrintln(any: Any?) = DebugLogger.debug(any)
@MiraiDebugAPI("Low efficiency.") @MiraiDebugAPI("Low efficiency.")
fun String.debugPrint(name: String): String { fun String.debugPrintThis(name: String): String {
DebugLogger.debug("$name=$this") DebugLogger.debug("$name=$this")
return this return this
} }
@MiraiDebugAPI("Low efficiency.") @MiraiDebugAPI("Low efficiency.")
fun ByteArray.debugPrint(name: String): ByteArray { fun ByteArray.debugPrintThis(name: String): ByteArray {
DebugLogger.debug(name + "=" + this.toUHexString()) DebugLogger.debug(name + "=" + this.toUHexString())
return this return this
} }
@MiraiDebugAPI("Low efficiency.") @MiraiDebugAPI("Low efficiency.")
fun IoBuffer.debugPrint(name: String): IoBuffer { fun IoBuffer.debugPrintThis(name: String): IoBuffer {
ByteArrayPool.useInstance { ByteArrayPool.useInstance {
val count = this.readAvailable(it) val count = this.readAvailable(it)
DebugLogger.debug(name + "=" + it.toUHexString(offset = 0, length = count)) DebugLogger.debug(name + "=" + it.toUHexString(offset = 0, length = count))
...@@ -54,7 +54,7 @@ fun Input.debugDiscardExact(n: Number, name: String = "") { ...@@ -54,7 +54,7 @@ fun Input.debugDiscardExact(n: Number, name: String = "") {
} }
@MiraiDebugAPI("Low efficiency.") @MiraiDebugAPI("Low efficiency.")
fun ByteReadPacket.debugPrint(name: String = ""): ByteReadPacket { fun ByteReadPacket.debugPrintThis(name: String = ""): ByteReadPacket {
ByteArrayPool.useInstance { ByteArrayPool.useInstance {
val count = this.readAvailable(it) val count = this.readAvailable(it)
DebugLogger.debug("ByteReadPacket $name=" + it.toUHexString(offset = 0, length = count)) DebugLogger.debug("ByteReadPacket $name=" + it.toUHexString(offset = 0, length = count))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment