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
2fa99f22
Commit
2fa99f22
authored
Aug 17, 2019
by
Him188moe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
5a8899bd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
4 deletions
+18
-4
mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/ClientPacket.kt
...ava/net/mamoe/mirai/network/packet/client/ClientPacket.kt
+1
-1
mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/Server0825Packet.kt
...net/mamoe/mirai/network/packet/server/Server0825Packet.kt
+4
-2
mirai-core/src/main/java/net/mamoe/mirai/util/Utils.kt
mirai-core/src/main/java/net/mamoe/mirai/util/Utils.kt
+13
-1
No files found.
mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/ClientPacket.kt
View file @
2fa99f22
...
@@ -39,7 +39,7 @@ abstract class ClientPacket : ByteArrayDataOutputStream(), Packet {
...
@@ -39,7 +39,7 @@ abstract class ClientPacket : ByteArrayDataOutputStream(), Packet {
*
*
*
*
* Before sending the packet, an [tail][Protocol.tail] will be added.
* Before sending the packet, an [tail][Protocol.tail] will be added.
*/
// TODO: 2019/8/9 添加 tail
*/
@Throws
(
IOException
::
class
)
@Throws
(
IOException
::
class
)
abstract
fun
encode
()
abstract
fun
encode
()
...
...
mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/Server0825Packet.kt
View file @
2fa99f22
...
@@ -2,6 +2,7 @@ package net.mamoe.mirai.network.packet.server
...
@@ -2,6 +2,7 @@ package net.mamoe.mirai.network.packet.server
import
net.mamoe.mirai.network.Protocol
import
net.mamoe.mirai.network.Protocol
import
net.mamoe.mirai.util.TEACryptor
import
net.mamoe.mirai.util.TEACryptor
import
net.mamoe.mirai.util.getRandomKey
import
java.io.DataInputStream
import
java.io.DataInputStream
/**
/**
...
@@ -22,6 +23,7 @@ class Server0825Packet(private val type: Type, inputStream: DataInputStream) : S
...
@@ -22,6 +23,7 @@ class Server0825Packet(private val type: Type, inputStream: DataInputStream) : S
TYPE_08_25_31_02
,
TYPE_08_25_31_02
,
}
}
@ExperimentalUnsignedTypes
override
fun
decode
()
{
override
fun
decode
()
{
input
.
skip
(
43
-
11
)
//todo: check
input
.
skip
(
43
-
11
)
//todo: check
val
data
=
DataInputStream
(
TEACryptor
.
decrypt
(
input
.
readAllBytes
().
let
{
it
.
copyOfRange
(
0
,
it
.
size
-
2
)
},
when
(
type
)
{
//todo: check array range
val
data
=
DataInputStream
(
TEACryptor
.
decrypt
(
input
.
readAllBytes
().
let
{
it
.
copyOfRange
(
0
,
it
.
size
-
2
)
},
when
(
type
)
{
//todo: check array range
...
@@ -38,10 +40,10 @@ class Server0825Packet(private val type: Type, inputStream: DataInputStream) : S
...
@@ -38,10 +40,10 @@ class Server0825Packet(private val type: Type, inputStream: DataInputStream) : S
token
=
data
.
readNBytes
(
167
-
(
16
-
2
))
token
=
data
.
readNBytes
(
167
-
(
16
-
2
))
loginTime
=
data
.
readLong
()
//todo check
loginTime
=
data
.
readLong
()
//todo check
loginIP
=
data
.
readIP
()
loginIP
=
data
.
readIP
()
tgtgtKey
=
getRandomKey
(
16
);
TODO
(
"从易语言抄协议来"
)
}
}
else
->
{
else
->
{
throw
IllegalStateException
()
}
}
}
}
}
}
...
...
mirai-core/src/main/java/net/mamoe/mirai/util/Utils.kt
View file @
2fa99f22
...
@@ -3,6 +3,8 @@ package net.mamoe.mirai.util
...
@@ -3,6 +3,8 @@ package net.mamoe.mirai.util
import
net.mamoe.mirai.network.Protocol
import
net.mamoe.mirai.network.Protocol
import
java.io.ByteArrayOutputStream
import
java.io.ByteArrayOutputStream
import
java.io.DataOutputStream
import
java.io.DataOutputStream
import
java.util.*
import
java.util.zip.CRC32
/**
/**
* @author Him188moe @ Mirai Project
* @author Him188moe @ Mirai Project
...
@@ -32,6 +34,7 @@ fun UByteArray.toHexString(separator: String = ", "): String = Utils.toHexString
...
@@ -32,6 +34,7 @@ fun UByteArray.toHexString(separator: String = ", "): String = Utils.toHexString
fun
Byte
.
toHexString
():
String
=
this
.
toString
(
16
)
fun
Byte
.
toHexString
():
String
=
this
.
toString
(
16
)
@ExperimentalUnsignedTypes
fun
String
.
hexToBytes
():
ByteArray
=
Protocol
.
hexToBytes
(
this
)
fun
String
.
hexToBytes
():
ByteArray
=
Protocol
.
hexToBytes
(
this
)
@ExperimentalUnsignedTypes
@ExperimentalUnsignedTypes
fun
String
.
hexToUBytes
():
UByteArray
=
Protocol
.
hexToUBytes
(
this
)
fun
String
.
hexToUBytes
():
UByteArray
=
Protocol
.
hexToUBytes
(
this
)
...
@@ -40,4 +43,13 @@ open class ByteArrayDataOutputStream : DataOutputStream(ByteArrayOutputStream())
...
@@ -40,4 +43,13 @@ open class ByteArrayDataOutputStream : DataOutputStream(ByteArrayOutputStream())
open
fun
toByteArray
():
ByteArray
=
(
out
as
ByteArrayOutputStream
).
toByteArray
()
open
fun
toByteArray
():
ByteArray
=
(
out
as
ByteArrayOutputStream
).
toByteArray
()
@ExperimentalUnsignedTypes
@ExperimentalUnsignedTypes
open
fun
toUByteArray
():
UByteArray
=
(
out
as
ByteArrayOutputStream
).
toByteArray
().
toUByteArray
();
open
fun
toUByteArray
():
UByteArray
=
(
out
as
ByteArrayOutputStream
).
toByteArray
().
toUByteArray
();
}
}
\ No newline at end of file
@ExperimentalUnsignedTypes
fun
getRandomKey
(
length
:
Int
):
ByteArray
{
val
bytes
=
LinkedList
<
Byte
>();
for
(
i
in
0
..
length
)
bytes
.
add
((
Math
.
random
()
*
255
).
toByte
())
return
bytes
.
toByteArray
();
}
fun
getCrc32
(
key
:
ByteArray
):
Long
=
with
(
CRC32
())
{
update
(
key
);
return
@
with
this
.
value
};
\ 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