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
0b01fd7b
Commit
0b01fd7b
authored
Jan 31, 2020
by
jiahua.liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
troop List
parent
288d0df7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
99 additions
and
8 deletions
+99
-8
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt
...moe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt
+8
-3
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/http/HttpRequest.kt
...lin/net/mamoe/mirai/qqandroid/network/http/HttpRequest.kt
+81
-0
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/PacketFactory.kt
.../mirai/qqandroid/network/protocol/packet/PacketFactory.kt
+1
-1
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/list/FriendListPacket.kt
...qandroid/network/protocol/packet/list/FriendListPacket.kt
+3
-4
mirai-core-qqandroid/src/jvmTest/kotlin/androidPacketTests/clientToServer.kt
...d/src/jvmTest/kotlin/androidPacketTests/clientToServer.kt
+3
-0
mirai-core-qqandroid/src/jvmTest/kotlin/androidPacketTests/serverToClient.kt
...d/src/jvmTest/kotlin/androidPacketTests/serverToClient.kt
+3
-0
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt
View file @
0b01fd7b
package
net.mamoe.mirai.qqandroid.network
package
net.mamoe.mirai.qqandroid.network
import
io.ktor.client.HttpClient
import
kotlinx.atomicfu.AtomicRef
import
kotlinx.atomicfu.AtomicRef
import
kotlinx.atomicfu.atomic
import
kotlinx.atomicfu.atomic
import
kotlinx.coroutines.*
import
kotlinx.coroutines.*
...
@@ -98,6 +99,7 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
...
@@ -98,6 +99,7 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
suspend
fun
doInit
()
{
suspend
fun
doInit
()
{
//start updating friend/group list
//start updating friend/group list
bot
.
logger
.
info
(
"Start updating friend/group list"
)
bot
.
logger
.
info
(
"Start updating friend/group list"
)
/*
/*
val data = FriendList.GetFriendGroupList(
val data = FriendList.GetFriendGroupList(
bot.client,
bot.client,
...
@@ -106,11 +108,14 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
...
@@ -106,11 +108,14 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
0,
0,
2
2
).sendAndExpect<FriendList.GetFriendGroupList.Response>()
).sendAndExpect<FriendList.GetFriendGroupList.Response>()
*/
*/
val
data
=
FriendList
.
GetTroopList
(
val
data
=
FriendList
.
GetTroopListSimplify
(
bot
.
client
bot
.
client
).
sendAndExpect
<
FriendList
.
Get
FriendGroupList
.
Response
>(
)
).
sendAndExpect
<
FriendList
.
Get
TroopListSimplify
.
Response
>(
100000
)
println
(
data
.
contentToString
())
println
(
data
.
contentToString
())
}
}
doLogin
()
doLogin
()
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/http/HttpRequest.kt
0 → 100644
View file @
0b01fd7b
package
net.mamoe.mirai.qqandroid.network.http
import
io.ktor.client.HttpClient
import
io.ktor.client.request.*
import
io.ktor.client.response.HttpResponse
import
io.ktor.http.ContentType
import
io.ktor.http.URLProtocol
import
io.ktor.http.setCookie
import
io.ktor.http.userAgent
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.io.readRemaining
import
kotlinx.coroutines.withContext
import
net.mamoe.mirai.qqandroid.QQAndroidBot
import
net.mamoe.mirai.qqandroid.network.QQAndroidClient
import
net.mamoe.mirai.utils.cryptor.contentToString
import
net.mamoe.mirai.utils.currentTimeMillis
import
net.mamoe.mirai.utils.io.readRemainingBytes
import
net.mamoe.mirai.utils.io.toUHexString
/**
* 好像不需要了
*/
object
HttpRequest
{
private
lateinit
var
cookie
:
String
}
internal
suspend
fun
HttpClient
.
getPTLoginCookies
(
client
:
QQAndroidClient
):
String
{
//$"https://ssl.ptlogin2.qq.com/jump?pt_clientver=5593&pt_src=1&keyindex=9&ptlang=2052&clientuin={QQ}&clientkey={Util.ToHex(TXProtocol.BufServiceTicketHttp, "", "{0}")}&u1=https:%2F%2Fuser.qzone.qq.com%2F417085811%3FADUIN=417085811%26ADSESSION={Util.GetTimeMillis(DateTime.Now)}%26ADTAG=CLIENT.QQ.5593_MyTip.0%26ADPUBNO=26841&source=namecardhoverstar"
// "https://ssl.ptlogin2.qq.com/jump?pt_clientver=5509&pt_src=1&keyindex=9&clientuin={0}&clientkey={1}&u1=http%3A%2F%2Fqun.qq.com%2Fmember.html%23gid%3D168209441",
val
res
=
post
<
HttpResponse
>
{
println
(
client
.
wLoginSigInfo
.
userStWebSig
.
data
.
toUHexString
().
replace
(
" "
,
""
).
toLowerCase
())
url
{
protocol
=
URLProtocol
.
HTTPS
host
=
"ssl.ptlogin2.qq.com"
path
(
"/jump?pt_clientver=5509&pt_src=1&keyindex=9&clientuin=${client.uin}&clientkey=${client.wLoginSigInfo.userStWebSig.data.toUHexString().replace(
" "
,
""
)}&
u1
=
http
%
3
A
%
2F
%
2F
qun
.
qq
.
com
%
2F
member
.
html
%
23
gid
%
3
D168209441
&
FADUIN
=
417085811
&
ADSESSION
=
$
{
currentTimeMillis
}&
source
=
namecardhoverstar
"
)
}
headers
{
userAgent
(
"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36"
)
}
}
println
(
res
.
status
)
println
(
res
.
setCookie
())
println
(
res
.
content
.
readRemaining
().
readRemainingBytes
().
toUHexString
())
return
"done"
;
}
internal
suspend
fun
HttpClient
.
getGroupList
(
client
:
QQAndroidClient
):
String
{
// "https://ssl.ptlogin2.qq.com/jump?pt_clientver=5509&pt_src=1&keyindex=9&clientuin={0}&clientkey={1}&u1=http%3A%2F%2Fqun.qq.com%2Fmember.html%23gid%3D168209441",
val
res
=
get
<
HttpResponse
>
{
url
{
protocol
=
URLProtocol
.
HTTPS
host
=
"ssl.ptlogin2.qq.com"
path
(
"jump"
)
parameters
[
"pt_clientver"
]
=
"5509"
parameters
[
"pt_src"
]
=
"1"
parameters
[
"keyindex"
]
=
"9"
parameters
[
"u1"
]
=
"http%3A%2F%2Fqun.qq.com%2Fmember.html%23gid%3D168209441"
parameters
[
"clientuin"
]
=
client
.
uin
.
toString
()
parameters
[
"clientkey"
]
=
client
.
wLoginSigInfo
.
userStWebSig
.
data
.
toUHexString
()
}
headers
{
userAgent
(
"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36"
)
}
}
println
(
res
.
status
)
println
(
res
.
setCookie
())
return
"done"
;
}
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/PacketFactory.kt
View file @
0b01fd7b
...
@@ -67,7 +67,7 @@ internal object KnownPacketFactories : List<PacketFactory<*>> by mutableListOf(
...
@@ -67,7 +67,7 @@ internal object KnownPacketFactories : List<PacketFactory<*>> by mutableListOf(
MessageSvc
.
PushForceOffline
,
MessageSvc
.
PushForceOffline
,
MessageSvc
.
PbSendMsg
,
MessageSvc
.
PbSendMsg
,
FriendList
.
GetFriendGroupList
,
FriendList
.
GetFriendGroupList
,
FriendList
.
GetTroopList
FriendList
.
GetTroopList
Simplify
)
{
)
{
// SvcReqMSFLoginNotify 自己的其他设备上限
// SvcReqMSFLoginNotify 自己的其他设备上限
// MessageSvc.PushReaded 电脑阅读了别人的消息, 告知手机
// MessageSvc.PushReaded 电脑阅读了别人的消息, 告知手机
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/list/FriendListPacket.kt
View file @
0b01fd7b
...
@@ -15,7 +15,6 @@ import net.mamoe.mirai.qqandroid.network.protocol.packet.OutgoingPacket
...
@@ -15,7 +15,6 @@ 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.utils.cryptor.contentToString
import
net.mamoe.mirai.utils.cryptor.contentToString
import
net.mamoe.mirai.utils.io.debugPrint
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.readRemainingBytes
import
net.mamoe.mirai.utils.io.toUHexString
import
net.mamoe.mirai.utils.io.toUHexString
...
@@ -23,8 +22,9 @@ import net.mamoe.mirai.utils.io.toUHexString
...
@@ -23,8 +22,9 @@ import net.mamoe.mirai.utils.io.toUHexString
internal
class
FriendList
{
internal
class
FriendList
{
internal
object
GetTroopList
:
PacketFactory
<
GetTroopList
.
Response
>(
"friendlist.GetTroopListReqV2"
)
{
internal
object
GetTroopListSimplify
:
override
suspend
fun
ByteReadPacket
.
decode
(
bot
:
QQAndroidBot
):
GetTroopList
.
Response
{
PacketFactory
<
GetTroopListSimplify
.
Response
>(
"friendlist.GetTroopListReqV2"
)
{
override
suspend
fun
ByteReadPacket
.
decode
(
bot
:
QQAndroidBot
):
GetTroopListSimplify
.
Response
{
println
(
"获取到了GetTroopList的回信"
)
println
(
"获取到了GetTroopList的回信"
)
println
(
this
.
readRemainingBytes
().
toUHexString
())
println
(
this
.
readRemainingBytes
().
toUHexString
())
return
Response
()
return
Response
()
...
@@ -65,7 +65,6 @@ internal class FriendList {
...
@@ -65,7 +65,6 @@ internal class FriendList {
}
}
}
}
}
}
internal
object
GetFriendGroupList
:
PacketFactory
<
GetFriendGroupList
.
Response
>(
"friendlist.getFriendGroupList"
)
{
internal
object
GetFriendGroupList
:
PacketFactory
<
GetFriendGroupList
.
Response
>(
"friendlist.getFriendGroupList"
)
{
class
Response
:
Packet
{
class
Response
:
Packet
{
...
...
mirai-core-qqandroid/src/jvmTest/kotlin/androidPacketTests/clientToServer.kt
View file @
0b01fd7b
...
@@ -276,6 +276,9 @@ fun ByteReadPacket.decodeUni() {
...
@@ -276,6 +276,9 @@ fun ByteReadPacket.decodeUni() {
//return
//return
readBytes
(
readInt
()
-
4
).
debugPrint
(
"head"
).
toReadPacket
().
apply
{
readBytes
(
readInt
()
-
4
).
debugPrint
(
"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
...
...
mirai-core-qqandroid/src/jvmTest/kotlin/androidPacketTests/serverToClient.kt
View file @
0b01fd7b
...
@@ -219,6 +219,9 @@ private fun parseSsoFrame(input: ByteReadPacket): KnownPacketFactories.IncomingP
...
@@ -219,6 +219,9 @@ private fun parseSsoFrame(input: ByteReadPacket): KnownPacketFactories.IncomingP
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()}")
...
...
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