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
e129719d
Commit
e129719d
authored
Sep 05, 2019
by
Him188moe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated robot & network structure
parent
c353e8e8
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
450 additions
and
365 deletions
+450
-365
mirai-core/src/main/java/net/mamoe/mirai/contact/Group.kt
mirai-core/src/main/java/net/mamoe/mirai/contact/Group.kt
+1
-1
mirai-core/src/main/java/net/mamoe/mirai/contact/QQ.kt
mirai-core/src/main/java/net/mamoe/mirai/contact/QQ.kt
+1
-1
mirai-core/src/main/java/net/mamoe/mirai/network/Protocol.kt
mirai-core/src/main/java/net/mamoe/mirai/network/Protocol.kt
+68
-70
mirai-core/src/main/java/net/mamoe/mirai/network/RobotNetworkHandler.kt
.../main/java/net/mamoe/mirai/network/RobotNetworkHandler.kt
+359
-275
mirai-core/src/main/java/net/mamoe/mirai/network/packet/AccountInfo.kt
...c/main/java/net/mamoe/mirai/network/packet/AccountInfo.kt
+1
-0
mirai-core/src/main/java/net/mamoe/mirai/network/packet/ServerPacket.kt
.../main/java/net/mamoe/mirai/network/packet/ServerPacket.kt
+3
-12
mirai-core/src/main/java/net/mamoe/mirai/network/packet/login/LoginState.kt
...n/java/net/mamoe/mirai/network/packet/login/LoginState.kt
+3
-1
mirai-core/src/main/java/net/mamoe/mirai/utils/TEA.java
mirai-core/src/main/java/net/mamoe/mirai/utils/TEA.java
+2
-3
mirai-core/src/main/java/net/mamoe/mirai/utils/Utils.kt
mirai-core/src/main/java/net/mamoe/mirai/utils/Utils.kt
+12
-2
No files found.
mirai-core/src/main/java/net/mamoe/mirai/contact/Group.kt
View file @
e129719d
...
@@ -10,7 +10,7 @@ class Group(robot: Robot, number: Long) : Contact(robot, number), Closeable {
...
@@ -10,7 +10,7 @@ class Group(robot: Robot, number: Long) : Contact(robot, number), Closeable {
val
members
=
ContactList
<
QQ
>()
val
members
=
ContactList
<
QQ
>()
override
fun
sendMessage
(
message
:
Message
)
{
override
fun
sendMessage
(
message
:
Message
)
{
robot
.
network
.
packetSystem
.
sendGroupMessage
(
this
,
message
)
robot
.
network
.
messageHandler
.
sendGroupMessage
(
this
,
message
)
}
}
override
fun
sendXMLMessage
(
message
:
String
)
{
override
fun
sendXMLMessage
(
message
:
String
)
{
...
...
mirai-core/src/main/java/net/mamoe/mirai/contact/QQ.kt
View file @
e129719d
...
@@ -12,7 +12,7 @@ import net.mamoe.mirai.message.defaults.At
...
@@ -12,7 +12,7 @@ import net.mamoe.mirai.message.defaults.At
*/
*/
class
QQ
(
robot
:
Robot
,
number
:
Long
)
:
Contact
(
robot
,
number
)
{
class
QQ
(
robot
:
Robot
,
number
:
Long
)
:
Contact
(
robot
,
number
)
{
override
fun
sendMessage
(
message
:
Message
)
{
override
fun
sendMessage
(
message
:
Message
)
{
robot
.
network
.
packetSystem
.
sendFriendMessage
(
this
,
message
)
robot
.
network
.
messageHandler
.
sendFriendMessage
(
this
,
message
)
}
}
override
fun
sendXMLMessage
(
message
:
String
)
{
override
fun
sendXMLMessage
(
message
:
String
)
{
...
...
mirai-core/src/main/java/net/mamoe/mirai/network/Protocol.kt
View file @
e129719d
...
@@ -7,88 +7,86 @@ import java.util.stream.Collectors
...
@@ -7,88 +7,86 @@ import java.util.stream.Collectors
/**
/**
* @author Him188moe
* @author Him188moe
*/
*/
interface
Protocol
{
object
Protocol
{
companion
object
{
val
SERVER_IP
:
List
<
String
>
=
object
:
ArrayList
<
String
>()
{
val
SERVER_IP
:
ArrayList
<
String
>
=
object
:
ArrayList
<
String
>()
{
init
{
init
{
add
(
"183.60.56.29"
)
add
(
"183.60.56.29"
)
arrayOf
(
arrayOf
(
"sz2.tencent.com"
,
"sz2.tencent.com"
,
"sz3.tencent.com"
,
"sz3.tencent.com"
,
"sz4.tencent.com"
,
"sz4.tencent.com"
,
"sz5.tencent.com"
,
"sz5.tencent.com"
,
"sz6.tencent.com"
,
"sz6.tencent.com"
,
"sz8.tencent.com"
,
"sz8.tencent.com"
,
"sz9.tencent.com"
"sz9.tencent.com"
).
forEach
{
this
.
add
(
InetAddress
.
getByName
(
it
).
hostAddress
)
}
).
forEach
{
this
.
add
(
InetAddress
.
getByName
(
it
).
hostAddress
)
}
}
}
}
}
get
()
=
Collections
.
unmodifiableList
(
field
)
const
val
head
=
"02"
const
val
ver
=
"37 13"
const
val
fixVer
=
"03 00 00 00 01 2E 01 00 00 68 52 00 00 00 00"
const
val
tail
=
"03"
/**
* _fixVer
*/
const
val
fixVer2
=
"02 00 00 00 01 01 01 00 00 68 20"
/**
* 0825data1
*/
const
val
constantData0
=
"00 18 00 16 00 01 "
/**
* 0825data2
*/
const
val
constantData1
=
"00 00 04 53 00 00 00 01 00 00 15 85 "
const
val
key0825
=
"A4 F1 91 88 C9 82 14 99 0C 9E 56 55 91 23 C8 3D"
const
val
redirectionKey
=
"A8 F2 14 5F 58 12 60 AF 07 63 97 D6 76 B2 1A 3B"
const
val
publicKey
=
"02 6D 28 41 D2 A5 6F D2 FC 3E 2A 1F 03 75 DE 6E 28 8F A8 19 3E 5F 16 49 D3"
const
val
shareKey
=
"1A E9 7F 7D C9 73 75 98 AC 02 E0 80 5F A9 C6 AF"
const
val
fix0836
=
"06 A9 12 97 B7 F8 76 25 AF AF D3 EA B4 C8 BC E7 "
const
val
head
=
"02"
const
val
key00BA
=
"C1 9C B8 C8 7B 8C 81 BA 9E 9E 7A 89 E1 7A EC 94"
const
val
ver
=
"37 13"
const
val
key00BAFix
=
"69 20 D1 14 74 F5 B3 93 E4 D5 02 B3 71 1A CD 2A"
const
val
fixVer
=
"03 00 00 00 01 2E 01 00 00 68 52 00 00 00 00"
const
val
tail
=
"03"
/**
* _fixVer
*/
const
val
fixVer2
=
"02 00 00 00 01 01 01 00 00 68 20"
/**
* 0825data1
*/
const
val
constantData0
=
"00 18 00 16 00 01 "
/**
* 0825data2
*/
const
val
constantData1
=
"00 00 04 53 00 00 00 01 00 00 15 85 "
const
val
key0825
=
"A4 F1 91 88 C9 82 14 99 0C 9E 56 55 91 23 C8 3D"
const
val
redirectionKey
=
"A8 F2 14 5F 58 12 60 AF 07 63 97 D6 76 B2 1A 3B"
const
val
publicKey
=
"02 6D 28 41 D2 A5 6F D2 FC 3E 2A 1F 03 75 DE 6E 28 8F A8 19 3E 5F 16 49 D3"
const
val
shareKey
=
"1A E9 7F 7D C9 73 75 98 AC 02 E0 80 5F A9 C6 AF"
const
val
fix0836
=
"06 A9 12 97 B7 F8 76 25 AF AF D3 EA B4 C8 BC E7 "
const
val
key00BA
=
"C1 9C B8 C8 7B 8C 81 BA 9E 9E 7A 89 E1 7A EC 94"
const
val
key00BAFix
=
"69 20 D1 14 74 F5 B3 93 E4 D5 02 B3 71 1A CD 2A"
const
val
encryptKey
=
"“BA 42 FF 01 CF B4 FF D2 12 F0 6E A7 1B 7C B3 08”"
const
val
encryptKey
=
"“BA 42 FF 01 CF B4 FF D2 12 F0 6E A7 1B 7C B3 08”"
/**
/**
* 0836_622_fix2
* 0836_622_fix2
*/
*/
const
val
passwordSubmissionKey2
=
"00 15 00 30 00 01 01 27 9B C7 F5 00 10 65 03 FD 8B 00 00 00 00 00 00 00 00 00 00 00 00 02 90 49 55 33 00 10 15 74 C4 89 85 7A 19 F5 5E A9 C9 A3 5E 8A 5A 9B"
;
const
val
passwordSubmissionKey2
=
"00 15 00 30 00 01 01 27 9B C7 F5 00 10 65 03 FD 8B 00 00 00 00 00 00 00 00 00 00 00 00 02 90 49 55 33 00 10 15 74 C4 89 85 7A 19 F5 5E A9 C9 A3 5E 8A 5A 9B"
;
/**
/**
* 0836_622_fix1
* 0836_622_fix1
*/
*/
const
val
passwordSubmissionKey1
=
"03 00 00 00 01 01 01 00 00 68 20 00 00 00 00 00 01 01 03 00 19"
;
const
val
passwordSubmissionKey1
=
"03 00 00 00 01 01 01 00 00 68 20 00 00 00 00 00 01 01 03 00 19"
;
/**
/**
* fix_0836_1
* fix_0836_1
*/
*/
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"
private
val
hexToByteArrayCacheMap
:
MutableMap
<
Int
,
ByteArray
>
=
mutableMapOf
()
private
val
hexToByteArrayCacheMap
:
MutableMap
<
Int
,
ByteArray
>
=
mutableMapOf
()
@ExperimentalUnsignedTypes
@ExperimentalUnsignedTypes
fun
hexToBytes
(
hex
:
String
):
ByteArray
{
fun
hexToBytes
(
hex
:
String
):
ByteArray
{
hex
.
hashCode
().
let
{
id
->
hex
.
hashCode
().
let
{
id
->
if
(
hexToByteArrayCacheMap
.
containsKey
(
id
))
{
if
(
hexToByteArrayCacheMap
.
containsKey
(
id
))
{
return
hexToByteArrayCacheMap
[
id
]
!!
.
clone
()
return
hexToByteArrayCacheMap
[
id
]
!!
.
clone
()
}
else
{
}
else
{
hexToUBytes
(
hex
).
toByteArray
().
let
{
hexToUBytes
(
hex
).
toByteArray
().
let
{
hexToByteArrayCacheMap
[
id
]
=
it
.
clone
();
hexToByteArrayCacheMap
[
id
]
=
it
.
clone
();
return
it
return
it
}
}
}
}
}
}
}
}
@ExperimentalUnsignedTypes
@ExperimentalUnsignedTypes
fun
hexToUBytes
(
hex
:
String
):
UByteArray
=
Arrays
fun
hexToUBytes
(
hex
:
String
):
UByteArray
=
Arrays
.
stream
(
hex
.
split
(
" "
.
toRegex
()).
dropLastWhile
{
it
.
isEmpty
()
}.
toTypedArray
())
.
stream
(
hex
.
split
(
" "
.
toRegex
()).
dropLastWhile
{
it
.
isEmpty
()
}.
toTypedArray
())
.
map
{
value
->
value
.
trim
{
it
<=
' '
}
}
.
map
{
value
->
value
.
trim
{
it
<=
' '
}
}
.
map
{
s
->
s
.
toUByte
(
16
)
}
.
map
{
s
->
s
.
toUByte
(
16
)
}
.
collect
(
Collectors
.
toList
()).
toUByteArray
()
.
collect
(
Collectors
.
toList
()).
toUByteArray
()
}
}
}
mirai-core/src/main/java/net/mamoe/mirai/network/RobotNetworkHandler.kt
View file @
e129719d
This diff is collapsed.
Click to expand it.
mirai-core/src/main/java/net/mamoe/mirai/network/packet/AccountInfo.kt
View file @
e129719d
...
@@ -17,6 +17,7 @@ class ClientAccountInfoRequestPacket(
...
@@ -17,6 +17,7 @@ class ClientAccountInfoRequestPacket(
)
:
ClientPacket
()
{
)
:
ClientPacket
()
{
override
fun
encode
()
{
override
fun
encode
()
{
this
.
writeRandom
(
2
)
//part of packet id
this
.
writeRandom
(
2
)
//part of packet id
this
.
writeQQ
(
qq
)
this
.
writeQQ
(
qq
)
this
.
writeHex
(
Protocol
.
fixVer2
)
this
.
writeHex
(
Protocol
.
fixVer2
)
this
.
encryptAndWrite
(
sessionKey
)
{
this
.
encryptAndWrite
(
sessionKey
)
{
...
...
mirai-core/src/main/java/net/mamoe/mirai/network/packet/ServerPacket.kt
View file @
e129719d
...
@@ -53,11 +53,13 @@ abstract class ServerPacket(val input: DataInputStream) : Packet {
...
@@ -53,11 +53,13 @@ abstract class ServerPacket(val input: DataInputStream) : Packet {
551
,
487
->
LoginState
.
DEVICE_LOCK
551
,
487
->
LoginState
.
DEVICE_LOCK
359
->
LoginState
.
TAKEN_BACK
359
->
LoginState
.
TAKEN_BACK
else
->
LoginState
.
UNKNOWN
/*
//unknown
//unknown
63 -> throw IllegalArgumentException(bytes.size.toString() + " (Unknown error)")
63 -> throw IllegalArgumentException(bytes.size.toString() + " (Unknown error)")
351 -> throw IllegalArgumentException(bytes.size.toString() + " (Illegal package data or Unknown error)")//包数据有误
351 -> throw IllegalArgumentException(bytes.size.toString() + " (Illegal package data or Unknown error)")//包数据有误
else
->
throw
IllegalArgumentException
(
bytes
.
size
.
toString
())
else -> throw IllegalArgumentException(bytes.size.toString())
*/
},
stream
)
},
stream
)
}
}
...
@@ -112,17 +114,6 @@ abstract class ServerPacket(val input: DataInputStream) : Packet {
...
@@ -112,17 +114,6 @@ abstract class ServerPacket(val input: DataInputStream) : Packet {
}
}
fun
DataInputStream
.
readUntil
(
byte
:
Byte
):
ByteArray
{
var
buff
=
byteArrayOf
()
var
b
:
Byte
b
=
readByte
()
while
(
b
!=
byte
)
{
buff
+=
b
b
=
readByte
()
}
return
buff
}
@ExperimentalUnsignedTypes
@ExperimentalUnsignedTypes
fun
DataInputStream
.
readIP
():
String
{
fun
DataInputStream
.
readIP
():
String
{
var
buff
=
""
var
buff
=
""
...
...
mirai-core/src/main/java/net/mamoe/mirai/network/packet/login/LoginState.kt
View file @
e129719d
...
@@ -14,5 +14,7 @@ enum class LoginState {
...
@@ -14,5 +14,7 @@ enum class LoginState {
DEVICE_LOCK
,
//设备锁
DEVICE_LOCK
,
//设备锁
TAKEN_BACK
,
//被回收
TAKEN_BACK
,
//被回收
// VERIFICATION_CODE,//需要验证码
// VERIFICATION_CODE,//需要验证码
// SUCCEED,
UNKNOWN
,
}
}
\ No newline at end of file
mirai-core/src/main/java/net/mamoe/mirai/utils/TEA.java
View file @
e129719d
...
@@ -11,9 +11,8 @@ import java.util.Random;
...
@@ -11,9 +11,8 @@ import java.util.Random;
* @author iweiz https://github.com/iweizime/StepChanger/blob/master/app/src/main/java/me/iweizi/stepchanger/qq/Cryptor.java
* @author iweiz https://github.com/iweizime/StepChanger/blob/master/app/src/main/java/me/iweizi/stepchanger/qq/Cryptor.java
*/
*/
public
final
class
TEA
{
public
final
class
TEA
{
public
static
final
TEA
CRYPTOR_SHARE_KEY
=
new
TEA
(
Protocol
.
Companion
.
hexToBytes
(
Protocol
.
shareKey
));
public
static
final
TEA
CRYPTOR_SHARE_KEY
=
new
TEA
(
Protocol
.
INSTANCE
.
hexToBytes
(
Protocol
.
shareKey
));
public
static
final
TEA
CRYPTOR_0825KEY
=
new
TEA
(
Protocol
.
Companion
.
hexToBytes
(
Protocol
.
key0825
));
public
static
final
TEA
CRYPTOR_0825KEY
=
new
TEA
(
Protocol
.
INSTANCE
.
hexToBytes
(
Protocol
.
key0825
));
public
static
final
TEA
CRYPTOR_00BAKEY
=
new
TEA
(
Protocol
.
Companion
.
hexToBytes
(
Protocol
.
key00BA
));
private
static
final
long
UINT32_MASK
=
0xffffffff
L
;
private
static
final
long
UINT32_MASK
=
0xffffffff
L
;
private
final
long
[]
mKey
;
private
final
long
[]
mKey
;
...
...
mirai-core/src/main/java/net/mamoe/mirai/utils/Utils.kt
View file @
e129719d
...
@@ -79,7 +79,7 @@ operator fun File.plus(child: String): File = File(this, child)
...
@@ -79,7 +79,7 @@ operator fun File.plus(child: String): File = File(this, child)
private
const
val
GTK_BASE_VALUE
:
Int
=
5381
private
const
val
GTK_BASE_VALUE
:
Int
=
5381
fun
getGTK
(
sKey
:
String
):
Int
{
internal
fun
getGTK
(
sKey
:
String
):
Int
{
var
value
=
GTK_BASE_VALUE
var
value
=
GTK_BASE_VALUE
for
(
c
in
sKey
.
toCharArray
())
{
for
(
c
in
sKey
.
toCharArray
())
{
value
+=
(
value
shl
5
)
+
c
.
toInt
()
value
+=
(
value
shl
5
)
+
c
.
toInt
()
...
@@ -89,7 +89,7 @@ fun getGTK(sKey: String): Int {
...
@@ -89,7 +89,7 @@ fun getGTK(sKey: String): Int {
return
value
return
value
}
}
fun
getCrc32
(
key
:
ByteArray
):
Int
=
CRC32
().
let
{
it
.
update
(
key
);
it
.
value
.
toInt
()
}
internal
fun
getCrc32
(
key
:
ByteArray
):
Int
=
CRC32
().
let
{
it
.
update
(
key
);
it
.
value
.
toInt
()
}
/**
/**
...
@@ -122,3 +122,13 @@ fun Any.getAllDeclaredFields(): List<Field> {
...
@@ -122,3 +122,13 @@ fun Any.getAllDeclaredFields(): List<Field> {
return
list
return
list
}
}
private
const
val
ZERO_BYTE
:
Byte
=
0
fun
ByteArray
.
removeZeroTail
():
ByteArray
{
var
i
=
this
.
size
-
1
while
(
this
[
i
]
==
ZERO_BYTE
)
{
--
i
}
return
this
.
copyOfRange
(
0
,
i
+
1
)
}
\ 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