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
e4353e47
Commit
e4353e47
authored
Nov 11, 2019
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup
parent
368abbe1
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
14 additions
and
13 deletions
+14
-13
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/BotNetworkHandler.kt
...nMain/kotlin/net.mamoe.mirai/network/BotNetworkHandler.kt
+1
-2
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/BotSession.kt
...c/commonMain/kotlin/net.mamoe.mirai/network/BotSession.kt
+0
-1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/handler/ActionPacketHandler.kt
...mirai/network/protocol/tim/handler/ActionPacketHandler.kt
+0
-1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/packet/Packet.kt
...lin/net.mamoe.mirai/network/protocol/tim/packet/Packet.kt
+5
-1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/packet/action/SendGroupMessagePacket.kt
...work/protocol/tim/packet/action/SendGroupMessagePacket.kt
+3
-1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/packet/event/FriendOnlineStatusChanged.kt
...rk/protocol/tim/packet/event/FriendOnlineStatusChanged.kt
+2
-1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/packet/event/Unknown.kt
....mamoe.mirai/network/protocol/tim/packet/event/Unknown.kt
+2
-3
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/packet/login/SKey.kt
...net.mamoe.mirai/network/protocol/tim/packet/login/SKey.kt
+0
-1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/Calculation.kt
...rc/commonMain/kotlin/net.mamoe.mirai/utils/Calculation.kt
+1
-2
No files found.
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/BotNetworkHandler.kt
View file @
e4353e47
...
...
@@ -22,11 +22,10 @@ import net.mamoe.mirai.utils.io.PlatformDatagramChannel
*
* [BotNetworkHandler] 由 2 个模块构成:
* - [BotSocketAdapter]: 处理数据包底层的发送([ByteArray])
* - [PacketHandler]: 制作 [OutgoingPacket] 并传递给 [BotSocketAdapter] 发送; 分析 [
Server
Packet] 并处理
* - [PacketHandler]: 制作 [OutgoingPacket] 并传递给 [BotSocketAdapter] 发送; 分析 [Packet] 并处理
*
* 其中, [PacketHandler] 由 3 个子模块构成:
* - [LoginHandler] 处理 sendTouch/login/verification code 相关
* - [EventPacketHandler] 处理消息相关(群消息/好友消息)([ServerEventPacket])
* - [ActionPacketHandler] 处理动作相关(踢人/加入群/好友列表等)
*
*
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/BotSession.kt
View file @
e4353e47
...
...
@@ -56,7 +56,6 @@ class BotSession(
/**
* Web api 使用
*/
@ExperimentalStdlibApi
var
sKey
:
String
=
""
internal
set
(
value
)
{
field
=
value
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/handler/ActionPacketHandler.kt
View file @
e4353e47
...
...
@@ -27,7 +27,6 @@ class ActionPacketHandler(session: BotSession) : PacketHandler(session) {
private
var
sKeyRefresherJob
:
Job
?
=
null
@ExperimentalStdlibApi
override
suspend
fun
onPacketReceived
(
packet
:
Packet
):
Unit
=
with
(
session
)
{
when
(
packet
)
{
is
SKey
->
{
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/packet/Packet.kt
View file @
e4353e47
package
net.mamoe.mirai.network.protocol.tim.packet
import
kotlinx.io.core.ByteReadPacket
import
kotlinx.io.core.readBytes
import
net.mamoe.mirai.utils.io.toUHexString
/**
* 一个包的数据 (body)
...
...
@@ -12,7 +14,9 @@ object IgnoredPacket : Packet
/**
* 未知的包.
*/
class
UnknownPacket
(
val
id
:
PacketId
,
val
body
:
ByteReadPacket
)
:
Packet
class
UnknownPacket
(
val
id
:
PacketId
,
val
body
:
ByteReadPacket
)
:
Packet
{
override
fun
toString
():
String
=
"UnknownPacket(${id.value.toUHexString()})\nbody=${body.readBytes().toUHexString()}"
}
/**
* 仅用于替换类型应为 [Unit] 的情况
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/packet/action/SendGroupMessagePacket.kt
View file @
e4353e47
...
...
@@ -46,7 +46,9 @@ object SendGroupMessagePacket : SessionPacketFactory<SendGroupMessagePacket.Resp
}
@NoLog
object
Response
:
Packet
object
Response
:
Packet
{
override
fun
toString
():
String
=
"SendGroupMessagePacket.Response"
}
override
suspend
fun
ByteReadPacket
.
decode
(
id
:
PacketId
,
sequenceId
:
UShort
,
handler
:
BotNetworkHandler
<
*
>):
Response
=
Response
}
\ No newline at end of file
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/packet/event/FriendOnlineStatusChanged.kt
View file @
e4353e47
...
...
@@ -14,6 +14,7 @@ import net.mamoe.mirai.network.protocol.tim.packet.KnownPacketId
import
net.mamoe.mirai.network.protocol.tim.packet.PacketId
import
net.mamoe.mirai.network.protocol.tim.packet.SessionPacketFactory
import
net.mamoe.mirai.utils.OnlineStatus
import
net.mamoe.mirai.utils.io.toUHexString
data class
FriendStatusChanged
(
val
qq
:
QQ
,
...
...
@@ -30,7 +31,7 @@ object FriendOnlineStatusChangedPacket : SessionPacketFactory<FriendStatusChange
val
qq
=
readUInt
()
discardExact
(
8
)
val
statusId
=
readUByte
()
val
status
=
OnlineStatus
.
ofId
(
statusId
)
?:
error
(
"Unknown online status id
$statusId
"
)
val
status
=
OnlineStatus
.
ofId
(
statusId
)
?:
error
(
"Unknown online status id
0x${statusId.toByte().toUHexString()}u
"
)
return
FriendStatusChanged
(
handler
.
bot
.
getQQ
(
qq
),
status
)
}
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/packet/event/Unknown.kt
View file @
e4353e47
...
...
@@ -7,7 +7,6 @@ import kotlinx.io.core.readBytes
import
kotlinx.io.pool.useInstance
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.network.BotNetworkHandler
import
net.mamoe.mirai.utils.MiraiLogger
import
net.mamoe.mirai.utils.io.ByteArrayPool
import
net.mamoe.mirai.utils.io.toUHexString
...
...
@@ -16,14 +15,14 @@ data class UnknownEventPacket(
val
identity
:
EventPacketIdentity
,
val
body
:
ByteReadPacket
)
:
EventPacket
{
override
fun
toString
():
String
=
"UnknownEventPacket(id=${id.toUHexString()}, identity=$identity)"
override
fun
toString
():
String
=
"UnknownEventPacket(id=${id.toUHexString()}, identity=$identity)
\n = ${body.readBytes().toUHexString()}
"
}
//TODO This class should be declared with `inline`, but a CompilationException will be thrown
class
UnknownEventParserAndHandler
(
override
val
id
:
UShort
)
:
EventParserAndHandler
<
UnknownEventPacket
>
{
override
suspend
fun
ByteReadPacket
.
parse
(
bot
:
Bot
,
identity
:
EventPacketIdentity
):
UnknownEventPacket
{
MiraiLogger
.
debug
(
"UnknownEventPacket(${id.toUHexString()}) = ${readBytes().toUHexString()}"
)
//
MiraiLogger.debug("UnknownEventPacket(${id.toUHexString()}) = ${readBytes().toUHexString()}")
return
UnknownEventPacket
(
id
,
identity
,
this
)
//TODO the cause is that `this` reference.
}
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/packet/login/SKey.kt
View file @
e4353e47
...
...
@@ -32,7 +32,6 @@ object RequestSKeyPacket : SessionPacketFactory<SKey>() {
override
suspend
fun
ByteReadPacket
.
decode
(
id
:
PacketId
,
sequenceId
:
UShort
,
handler
:
BotNetworkHandler
<
*
>):
SKey
{
discardExact
(
4
)
// TODO: 2019/11/2 这里
return
SKey
(
readString
(
10
)).
also
{
DebugLogger
.
warning
(
"SKey 包后面${readRemainingBytes().toUHexString()}"
)
}
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/Calculation.kt
View file @
e4353e47
...
...
@@ -7,10 +7,9 @@ import net.mamoe.mirai.utils.io.getRandomByteArray
private
const
val
GTK_BASE_VALUE
:
Int
=
5381
@ExperimentalStdlibApi
internal
fun
getGTK
(
sKey
:
String
):
Int
{
var
value
=
GTK_BASE_VALUE
for
(
c
in
sKey
.
to
Char
Array
())
{
for
(
c
in
sKey
.
to
Byte
Array
())
{
value
+=
(
value
shl
5
)
+
c
.
toInt
()
}
...
...
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