Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mirai
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Mirai
Commits
6bd22da1
Commit
6bd22da1
authored
Jan 23, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
QQA Debugging update
parent
f4def5ef
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
47 additions
and
66 deletions
+47
-66
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt
...moe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt
+5
-6
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/OutgoingPacketAndroid.kt
...qandroid/network/protocol/packet/OutgoingPacketAndroid.kt
+11
-13
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/PacketFactory.kt
.../mirai/qqandroid/network/protocol/packet/PacketFactory.kt
+18
-16
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/image/ImagePacket.kt
...ai/qqandroid/network/protocol/packet/image/ImagePacket.kt
+2
-3
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/LoginPacket.kt
...ai/qqandroid/network/protocol/packet/login/LoginPacket.kt
+4
-21
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/SvcReqRegisterPacket.kt
...oid/network/protocol/packet/login/SvcReqRegisterPacket.kt
+5
-5
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/TransEmpPacket.kt
...qqandroid/network/protocol/packet/login/TransEmpPacket.kt
+2
-2
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt
View file @
6bd22da1
...
...
@@ -11,7 +11,6 @@ import net.mamoe.mirai.qqandroid.event.PacketReceivedEvent
import
net.mamoe.mirai.qqandroid.network.protocol.packet.KnownPacketFactories
import
net.mamoe.mirai.qqandroid.network.protocol.packet.OutgoingPacket
import
net.mamoe.mirai.qqandroid.network.protocol.packet.login.LoginPacket
import
net.mamoe.mirai.qqandroid.network.protocol.packet.login.PacketId
import
net.mamoe.mirai.qqandroid.network.protocol.packet.login.RegPushReason
import
net.mamoe.mirai.qqandroid.network.protocol.packet.login.SvcReqRegisterPacket
import
net.mamoe.mirai.utils.*
...
...
@@ -101,12 +100,12 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
*/
suspend
fun
parsePacket
(
input
:
Input
)
{
try
{
KnownPacketFactories
.
parseIncomingPacket
(
bot
,
input
)
{
packet
:
Packet
,
packetId
:
PacketId
,
sequenceId
:
Int
->
KnownPacketFactories
.
parseIncomingPacket
(
bot
,
input
)
{
packet
:
Packet
,
commandName
:
String
,
sequenceId
:
Int
->
if
(
PacketReceivedEvent
(
packet
).
broadcast
().
cancelled
)
{
return
@
parseIncomingPacket
}
packetListeners
.
forEach
{
listener
->
if
(
listener
.
filter
(
packetId
,
sequenceId
)
&&
packetListeners
.
remove
(
listener
))
{
if
(
listener
.
filter
(
commandName
,
sequenceId
)
&&
packetListeners
.
remove
(
listener
))
{
listener
.
complete
(
packet
)
}
}
...
...
@@ -202,7 +201,7 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
}
suspend
fun
<
E
:
Packet
>
OutgoingPacket
.
sendAndExpect
():
E
{
val
handler
=
PacketListener
(
packetId
=
packetId
,
sequenceId
=
sequenceId
)
val
handler
=
PacketListener
(
commandName
=
commandName
,
sequenceId
=
sequenceId
)
packetListeners
.
addLast
(
handler
)
//println(delegate.readBytes().toUHexString())
println
(
"Sending length="
+
delegate
.
remaining
)
...
...
@@ -217,10 +216,10 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
@PublishedApi
internal
inner
class
PacketListener
(
val
packetId
:
PacketId
,
val
commandName
:
String
,
val
sequenceId
:
Int
)
:
CompletableDeferred
<
Packet
>
by
CompletableDeferred
(
supervisor
)
{
fun
filter
(
packetId
:
PacketId
,
sequenceId
:
Int
)
=
this
.
packetId
==
packetId
&&
this
.
sequenceId
==
sequenceId
fun
filter
(
commandName
:
String
,
sequenceId
:
Int
)
=
this
.
commandName
==
commandName
&&
this
.
sequenceId
==
sequenceId
}
override
suspend
fun
awaitDisconnection
()
=
supervisor
.
join
()
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/OutgoingPacketAndroid.kt
View file @
6bd22da1
...
...
@@ -6,8 +6,6 @@ import kotlinx.io.core.ByteReadPacket
import
kotlinx.io.core.buildPacket
import
kotlinx.io.core.writeFully
import
net.mamoe.mirai.qqandroid.network.QQAndroidClient
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.MiraiInternalAPI
import
net.mamoe.mirai.utils.cryptor.DecrypterByteArray
import
net.mamoe.mirai.utils.cryptor.encryptAndWrite
...
...
@@ -23,12 +21,12 @@ import net.mamoe.mirai.utils.io.writeQQ
@UseExperimental
(
ExperimentalUnsignedTypes
::
class
)
internal
class
OutgoingPacket
constructor
(
name
:
String
?,
val
packetId
:
PacketId
,
val
commandName
:
String
,
val
sequenceId
:
Int
,
val
delegate
:
ByteReadPacket
)
{
val
name
:
String
by
lazy
{
name
?:
packetId
.
toString
()
name
?:
commandName
.
toString
()
}
}
...
...
@@ -66,13 +64,13 @@ internal val EMPTY_BYTE_ARRAY = ByteArray(0)
internal
inline
fun
PacketFactory
<*>.
buildOutgingPacket
(
client
:
QQAndroidClient
,
name
:
String
?
=
null
,
id
:
PacketId
=
this
.
id
,
commandName
:
String
=
this
.
commandName
,
key
:
ByteArray
,
body
:
BytePacketBuilder
.(
sequenceId
:
Int
)
->
Unit
):
OutgoingPacket
{
val
sequenceId
:
Int
=
client
.
nextSsoSequenceId
()
return
OutgoingPacket
(
name
,
id
,
sequenceId
,
buildPacket
{
return
OutgoingPacket
(
name
,
commandName
,
sequenceId
,
buildPacket
{
writeIntLVPacket
(
lengthOffset
=
{
it
+
4
})
{
writeInt
(
0
x0B
)
writeByte
(
1
)
...
...
@@ -113,13 +111,13 @@ internal inline fun PacketFactory<*>.buildLoginOutgoingPacket(
bodyType
:
Byte
,
extraData
:
ByteArray
=
EMPTY_BYTE_ARRAY
,
name
:
String
?
=
null
,
id
:
PacketId
=
this
.
id
,
commandName
:
String
=
this
.
commandName
,
key
:
ByteArray
=
KEY_16_ZEROS
,
body
:
BytePacketBuilder
.(
sequenceId
:
Int
)
->
Unit
):
OutgoingPacket
{
val
sequenceId
:
Int
=
client
.
nextSsoSequenceId
()
return
OutgoingPacket
(
name
,
id
,
sequenceId
,
buildPacket
{
return
OutgoingPacket
(
name
,
commandName
,
sequenceId
,
buildPacket
{
writeIntLVPacket
(
lengthOffset
=
{
it
+
4
})
{
writeInt
(
0
x00_00_00_0A
)
writeByte
(
bodyType
)
...
...
@@ -168,10 +166,10 @@ private val BRP_STUB = ByteReadPacket(EMPTY_BYTE_ARRAY)
* byte[] body()
*/
@UseExperimental
(
MiraiInternalAPI
::
class
)
internal
inline
fun
BytePacketBuilder
.
write
Login
SsoPacket
(
internal
inline
fun
BytePacketBuilder
.
writeSsoPacket
(
client
:
QQAndroidClient
,
subAppId
:
Long
,
packetId
:
PacketId
,
commandName
:
String
,
extraData
:
ByteReadPacket
=
BRP_STUB
,
sequenceId
:
Int
,
body
:
BytePacketBuilder
.()
->
Unit
...
...
@@ -187,7 +185,7 @@ internal inline fun BytePacketBuilder.writeLoginSsoPacket(
writeInt
((
extraData
.
remaining
+
4
).
toInt
())
writePacket
(
extraData
)
}
packetId
.
commandName
.
let
{
commandName
.
let
{
writeInt
(
it
.
length
+
4
)
writeStringUtf8
(
it
)
}
...
...
@@ -269,7 +267,7 @@ internal inline fun PacketFactory<*>.buildSessionOutgoingPacket(
internal
fun
BytePacketBuilder
.
writeOicqRequestPacket
(
client
:
QQAndroidClient
,
encryptMethod
:
EncryptMethod
,
packetId
:
PacketId
,
commandId
:
Int
,
bodyBlock
:
BytePacketBuilder
.()
->
Unit
)
{
val
body
=
encryptMethod
.
makeBody
(
client
,
bodyBlock
)
...
...
@@ -278,7 +276,7 @@ internal fun BytePacketBuilder.writeOicqRequestPacket(
writeByte
(
0
x02
)
// head
writeShort
((
27
+
2
+
body
.
remaining
).
toShort
())
// orthodox algorithm
writeShort
(
client
.
protocolVersion
)
writeShort
(
packetId
.
commandId
.
toShort
())
writeShort
(
commandId
.
toShort
())
writeShort
(
1
)
// const??
writeQQ
(
client
.
uin
)
writeByte
(
3
)
// originally const
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/PacketFactory.kt
View file @
6bd22da1
This diff is collapsed.
Click to expand it.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/image/ImagePacket.kt
View file @
6bd22da1
...
...
@@ -6,13 +6,12 @@ import kotlinx.serialization.Serializable
import
net.mamoe.mirai.data.Packet
import
net.mamoe.mirai.qqandroid.QQAndroidBot
import
net.mamoe.mirai.qqandroid.network.protocol.packet.PacketFactory
import
net.mamoe.mirai.qqandroid.network.protocol.packet.login.PacketId
import
net.mamoe.mirai.utils.currentTimeSeconds
@UseExperimental
(
ExperimentalUnsignedTypes
::
class
)
internal
object
ImagePacket
:
PacketFactory
<
ImagePacket
.
RequestImgUrlResponse
>()
{
init
{
this
.
_
id
=
PacketId
(
commandId
=
0
x0000
,
commandName
=
"LongConn.OffPicDown"
)
this
.
_
commandName
=
"LongConn.OffPicDown"
}
...
...
@@ -21,7 +20,7 @@ internal object ImagePacket : PacketFactory<ImagePacket.RequestImgUrlResponse>()
}
fun
createCmd0x325Packet
(
req
:
ImgReq
,
networkType
:
Int
=
5
):
Cmd0x352Packet
{
private
fun
createCmd0x325Packet
(
req
:
ImgReq
,
networkType
:
Int
=
5
):
Cmd0x352Packet
{
if
(
req
is
UploadImgReq
)
return
Cmd0x352Packet
(
1
,
req
,
null
,
null
,
networkType
)
if
(
req
is
GetImgUrlReq
)
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/LoginPacket.kt
View file @
6bd22da1
...
...
@@ -25,7 +25,7 @@ import net.mamoe.mirai.utils.io.discardExact
@UseExperimental
(
ExperimentalUnsignedTypes
::
class
)
internal
object
LoginPacket
:
PacketFactory
<
LoginPacket
.
LoginPacketResponse
>()
{
init
{
this
.
_
id
=
PacketId
(
commandId
=
0
x0810
,
commandName
=
"wtlogin.login"
)
this
.
_
commandName
=
"wtlogin.login"
}
object
SubCommand9
{
...
...
@@ -36,8 +36,8 @@ internal object LoginPacket : PacketFactory<LoginPacket.LoginPacketResponse>() {
operator
fun
invoke
(
client
:
QQAndroidClient
):
OutgoingPacket
=
buildLoginOutgoingPacket
(
client
,
bodyType
=
2
)
{
sequenceId
->
write
LoginSsoPacket
(
client
,
subAppId
,
id
,
sequenceId
=
sequenceId
)
{
writeOicqRequestPacket
(
client
,
EncryptMethodECDH7
(
client
.
ecdh
),
id
)
{
write
SsoPacket
(
client
,
subAppId
,
commandName
,
sequenceId
=
sequenceId
)
{
writeOicqRequestPacket
(
client
,
EncryptMethodECDH7
(
client
.
ecdh
),
0
x0810
)
{
writeShort
(
9
)
// subCommand
writeShort
(
17
)
// count of TLVs, probably ignored by server?
//writeShort(LoginType.PASSWORD.value.toShort())
...
...
@@ -563,21 +563,4 @@ internal object LoginPacket : PacketFactory<LoginPacket.LoginPacketResponse>() {
// SEE oicq_request.java at method analysisT17f
}
}
}
@Suppress
(
"FunctionName"
)
internal
fun
PacketId
(
commandId
:
Int
,
commandName
:
String
)
=
object
:
PacketId
{
override
val
commandId
:
Int
get
()
=
commandId
override
val
commandName
:
String
get
()
=
commandName
}
internal
interface
PacketId
{
val
commandId
:
Int
// ushort actually
val
commandName
:
String
}
internal
object
NullPacketId
:
PacketId
{
override
val
commandId
:
Int
get
()
=
error
(
"uninitialized"
)
override
val
commandName
:
String
get
()
=
error
(
"uninitialized"
)
}
}
\ No newline at end of file
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/SvcReqRegisterPacket.kt
View file @
6bd22da1
...
...
@@ -15,7 +15,7 @@ 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.buildLoginOutgoingPacket
import
net.mamoe.mirai.qqandroid.network.protocol.packet.oidb.oidb0x769.Oidb0x769
import
net.mamoe.mirai.qqandroid.network.protocol.packet.write
Login
SsoPacket
import
net.mamoe.mirai.qqandroid.network.protocol.packet.writeSsoPacket
import
net.mamoe.mirai.qqandroid.utils.NetworkType
import
net.mamoe.mirai.utils.currentTimeSeconds
import
net.mamoe.mirai.utils.io.debugPrint
...
...
@@ -40,10 +40,10 @@ internal object SvcReqRegisterPacket : PacketFactory<SvcReqRegisterPacket.Respon
internal
object
Response
:
Packet
const
val
subAppId
=
537062845L
private
const
val
subAppId
=
537062845L
init
{
_
id
=
PacketId
(
0
,
"StatSvc.register"
)
_
commandName
=
"StatSvc.register"
}
operator
fun
invoke
(
...
...
@@ -55,8 +55,8 @@ internal object SvcReqRegisterPacket : PacketFactory<SvcReqRegisterPacket.Respon
extraData
=
client
.
wLoginSigInfo
.
d2
.
data
,
key
=
client
.
wLoginSigInfo
.
d2Key
)
{
sequenceId
->
write
Login
SsoPacket
(
client
,
subAppId
=
subAppId
,
packetId
=
id
,
writeSsoPacket
(
client
,
subAppId
=
subAppId
,
commandName
=
commandName
,
extraData
=
client
.
wLoginSigInfo
.
tgt
.
toReadPacket
(),
sequenceId
=
sequenceId
)
{
writeUniRequestPacket
{
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/TransEmpPacket.kt
View file @
6bd22da1
...
...
@@ -10,7 +10,7 @@ import net.mamoe.mirai.qqandroid.network.protocol.packet.*
internal
object
TransEmpPacket
:
PacketFactory
<
TransEmpPacket
.
Response
>()
{
init
{
_
id
=
PacketId
(
0
x0812
,
"wtlogin.trans_emp"
)
_
commandName
=
"wtlogin.trans_emp"
}
private
const
val
appId
=
16L
...
...
@@ -20,7 +20,7 @@ internal object TransEmpPacket : PacketFactory<TransEmpPacket.Response>() {
fun
SubCommand1
(
client
:
QQAndroidClient
):
OutgoingPacket
=
buildLoginOutgoingPacket
(
client
,
bodyType
=
2
)
{
writeOicqRequestPacket
(
client
,
EncryptMethodECDH135
(
client
.
ecdh
),
id
)
{
writeOicqRequestPacket
(
client
,
EncryptMethodECDH135
(
client
.
ecdh
),
TODO
()
)
{
// oicq.wlogin_sdk.request.trans_emp_1#packTransEmpBody
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment