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
15de6f31
Commit
15de6f31
authored
Sep 11, 2019
by
Him188moe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated
parent
ece200d4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
7 deletions
+58
-7
README.md
README.md
+3
-2
mirai-core/src/main/java/net/mamoe/mirai/network/Protocol.kt
mirai-core/src/main/java/net/mamoe/mirai/network/Protocol.kt
+2
-1
mirai-core/src/main/java/net/mamoe/mirai/network/packet/action/AddContact.kt
.../java/net/mamoe/mirai/network/packet/action/AddContact.kt
+5
-4
mirai-core/src/main/java/net/mamoe/mirai/utils/ProtocolBuff.kt
...-core/src/main/java/net/mamoe/mirai/utils/ProtocolBuff.kt
+48
-0
No files found.
README.md
View file @
15de6f31
...
@@ -54,10 +54,11 @@ Network部分使用 Kotlin 完成(因为kt有对 unsigned byte 的支持).
...
@@ -54,10 +54,11 @@ Network部分使用 Kotlin 完成(因为kt有对 unsigned byte 的支持).
-
[X] Network - Verification Code
-
[X] Network - Verification Code
-
[X] Network - Message Receiving
-
[X] Network - Message Receiving
-
[X] Network - Message Sending
-
[X] Network - Message Sending
-
[ ] Network - Events
**(Working on)**
-
[ ] Network - Events
-
[ ] Bot - Friend/group list
-
[ ] Bot - Friend/group list
-
[ ] Bot - Actions(joining group, adding friend, etc.)
-
[ ] Bot - Actions(joining group, adding friend, etc.)
-
[ ] Message Section
**(Working on)**
-
[ ] Message Section
**(Working on)**
-
[ ] Image uploading
**(Working on)**
-
[ ] Contact
-
[ ] Contact
-
[ ] UI
-
[ ] UI
...
...
mirai-core/src/main/java/net/mamoe/mirai/network/Protocol.kt
View file @
15de6f31
...
@@ -65,7 +65,8 @@ object Protocol {
...
@@ -65,7 +65,8 @@ object Protocol {
const
val
key0836
=
"EF 4A 36 6A 16 A8 E6 3D 2E EA BD 1F 98 C1 3C DA"
const
val
key0836
=
"EF 4A 36 6A 16 A8 E6 3D 2E EA BD 1F 98 C1 3C DA"
/**
/**
* 发送/接受消息中的一个const
* 发送/接受消息中的一个const (?)
* length=15
*/
*/
const
val
friendMessageConst1
=
"00 00 0C E5 BE AE E8 BD AF E9 9B 85 E9 BB 91"
const
val
friendMessageConst1
=
"00 00 0C E5 BE AE E8 BD AF E9 9B 85 E9 BB 91"
...
...
mirai-core/src/main/java/net/mamoe/mirai/network/packet/action/AddContact.kt
View file @
15de6f31
...
@@ -55,10 +55,11 @@ class ServerCanAddFriendResponsePacket(input: DataInputStream) : ServerPacket(in
...
@@ -55,10 +55,11 @@ class ServerCanAddFriendResponsePacket(input: DataInputStream) : ServerPacket(in
return
return
}
}
state
=
when
(
data
[
data
.
size
-
1
].
toUInt
())
{
state
=
when
(
data
[
data
.
size
-
1
].
toUInt
())
{
0
u
->
State
.
NOT_REQUIRE_VERIFICATION
0
x00u
->
State
.
NOT_REQUIRE_VERIFICATION
1
u
->
State
.
REQUIRE_VERIFICATION
0
x01u
->
State
.
REQUIRE_VERIFICATION
99
u
->
State
.
ALREADY_ADDED
0
x99u
->
State
.
ALREADY_ADDED
3
u
,
4
u
->
State
.
FAILED
0
x03u
,
0
x04u
->
State
.
FAILED
else
->
throw
IllegalArgumentException
(
Arrays
.
toString
(
data
))
else
->
throw
IllegalArgumentException
(
Arrays
.
toString
(
data
))
}
}
}
}
...
...
mirai-core/src/main/java/net/mamoe/mirai/utils/ProtocolBuff.kt
0 → 100644
View file @
15de6f31
package
net.mamoe.mirai.utils
import
java.io.DataOutputStream
/**
* Google ProtocolBuff 的一些算法实现
*
* @author Him188moe
*/
/**
* 128(10000000) -> 0x7F (10000000_10000001)
*
* TODO improve
*/
@ExperimentalUnsignedTypes
fun
DataOutputStream
.
writeProtoFixedInt
(
int
:
Int
)
{
if
(
int
==
128
)
{
this
.
writeShort
(
0
x80_01
)
//unsigned//1000000010000001
return
}
this
.
writeByte
(
int
.
rem
(
128
)
+
128
)
this
.
writeByte
(
int
/
128
)
}
/**
* 127(1111111(7)) -> 0x7F (11111111(8))
*
* TODO improve
*/
@ExperimentalUnsignedTypes
fun
DataOutputStream
.
writeProtoInt
(
int
:
Int
)
{
if
(
int
<
128
)
{
this
.
writeByte
(
int
and
0
xFF
)
//10000000
return
}
this
.
writeProtoFixedInt
(
int
)
}
@ExperimentalUnsignedTypes
fun
main
()
{
println
()
println
(
lazyEncode
{
it
.
writeProtoInt
(
128
)
}.
toUHexString
())
}
\ No newline at end of file
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