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
6a291e8c
Commit
6a291e8c
authored
Dec 30, 2019
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add docs
parent
9140fb89
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
76 deletions
+38
-76
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/OutgoingPacketAndroid.kt
...qandroid/network/protocol/packet/OutgoingPacketAndroid.kt
+38
-76
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/OutgoingPacketAndroid.kt
View file @
6a291e8c
...
...
@@ -26,73 +26,9 @@ class OutgoingPacket constructor(
}
}
/*
private open fun writeHead(
always_8001: Int,
command: Int,
uin: Long,
encryptType: Int,
const8_always_0: Int,
appClientVersion: Int,
constp_always_0: Int,
bodyLength: Int
) {
val j: Int = this.j + 1
this.j = j
this.pos = 0
util.int8_to_buf(this.buffer, this.pos, 2)
++this.pos
util.int16_to_buf(this.buffer, this.pos, this.d + 2 + bodyLength)
this.pos += 2
util.int16_to_buf(this.buffer, this.pos, always_8001)
this.pos += 2
util.int16_to_buf(this.buffer, this.pos, command)
this.pos += 2
util.int16_to_buf(this.buffer, this.pos, j)
this.pos += 2
util.int32_to_buf(this.buffer, this.pos, uin.toInt())
this.pos += 4
util.int8_to_buf(this.buffer, this.pos, 3)
++this.pos
util.int8_to_buf(this.buffer, this.pos, encryptType)
++this.pos
util.int8_to_buf(this.buffer, this.pos, const8_always_0)
++this.pos
util.int32_to_buf(this.buffer, this.pos, 2)
this.pos += 4
util.int32_to_buf(this.buffer, this.pos, appClientVersion)
this.pos += 4
util.int32_to_buf(this.buffer, this.pos, constp_always_0)
this.pos += 4
}
*/
@UseExperimental
(
ExperimentalUnsignedTypes
::
class
)
private
fun
BytePacketBuilder
.
writeHead
(
always_8001
:
Short
=
8001
,
command
:
Short
,
uin
:
Long
,
encryptType
:
Int
,
//
sequenceId
:
UShort
=
PacketFactory
.
atomicNextSequenceId
(),
const8_always_0
:
Byte
=
0
,
appClientVersion
:
Int
,
constp_always_0
:
Int
=
0
,
bodyLength
:
Int
)
{
writeByte
(
2
)
writeShort
((
27
+
2
+
bodyLength
).
toShort
())
writeShort
(
always_8001
)
writeShort
(
command
)
writeUShort
(
sequenceId
)
writeInt
(
uin
.
toInt
())
writeByte
(
3
)
writeByte
(
encryptType
.
toByte
())
writeByte
(
const8_always_0
)
writeInt
(
2
)
writeInt
(
appClientVersion
)
writeInt
(
constp_always_0
)
}
/**
* Encryption method to be used for packet body.
*/
@UseExperimental
(
ExperimentalUnsignedTypes
::
class
)
inline
class
EncryptMethod
(
val
value
:
UByte
)
{
companion
object
{
...
...
@@ -103,6 +39,30 @@ inline class EncryptMethod(val value: UByte) {
}
}
/**
* Builds a outgoing packet.
* [OutgoingPacket] is the **outermost** packet structure.
* This packet will be sent to the server.
*
*
* **Packet Structure**
* byte 2 // head
* short 27 + 2 + body.size
* ushort client.protocolVersion // const 8001
* ushort sequenceId
* uint client.account.id
* byte 3 // const
* ubyte encryptMethod.value // [EncryptMethod]
* byte 0 // const
* int 2 // const
* int client.appClientVersion
* int 0 // const
* bodyBlock()
* byte 3 // tail
*
* @param name optional name to be displayed in logs
*
*/
@UseExperimental
(
ExperimentalUnsignedTypes
::
class
,
MiraiInternalAPI
::
class
)
internal
inline
fun
PacketFactory
<*,
*>.
buildOutgoingPacket
(
client
:
QQAndroidClient
,
...
...
@@ -137,15 +97,17 @@ internal inline fun PacketFactory<*, *>.buildOutgoingPacket(
}
/**
* buildPacket{
* byte 1
* byte 1
* fully privateKey
* short 258
* short publicKey.length
* fully publicKey
* encryptAndWrite(shareKey, body)
* }
* Encrypt the [body] by [ECDH.shareKey], then write encryption arguments stuff.
* This is **the second outermost** packet structure
*
* **Packet Structure**
* byte 1
* byte 1
* byte[] [ECDH.privateKey]
* short 258
* short [ECDH.publicKey].size
* byte[] [ECDH.publicKey]
* byte[] encrypted `body()` by [ECDH.shareKey]
*/
inline
fun
BytePacketBuilder
.
writeECDHEncryptedPacket
(
ecdh
:
ECDH
,
...
...
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