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
52857fad
Commit
52857fad
authored
Aug 17, 2019
by
Him188moe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
bbc1f717
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
50 additions
and
10 deletions
+50
-10
mirai-core/src/main/java/module-info.java
mirai-core/src/main/java/module-info.java
+6
-0
mirai-core/src/main/java/net/mamoe/mirai/network/Robot.kt
mirai-core/src/main/java/net/mamoe/mirai/network/Robot.kt
+6
-4
mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/Client0825ResponsePacket.kt
...e/mirai/network/packet/client/Client0825ResponsePacket.kt
+2
-1
mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/ClientLoginPacket.java
.../mamoe/mirai/network/packet/client/ClientLoginPacket.java
+18
-1
mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/ClientPacket.java
...a/net/mamoe/mirai/network/packet/client/ClientPacket.java
+2
-4
mirai-core/src/main/java/net/mamoe/mirai/util/Utils.kt
mirai-core/src/main/java/net/mamoe/mirai/util/Utils.kt
+16
-0
No files found.
mirai-core/src/main/java/module-info.java
0 → 100644
View file @
52857fad
module
mirai_core
{
requires
kotlin
.
stdlib
;
requires
lombok
;
exports
net
.
mamoe
.
mirai
;
}
\ No newline at end of file
mirai-core/src/main/java/net/mamoe/mirai/network/Robot.kt
View file @
52857fad
...
...
@@ -22,20 +22,21 @@ import java.net.InetSocketAddress
* @author Him188moe @ Mirai Project
*/
class
Robot
(
val
number
:
Long
)
{
private
lateinit
var
ctx
:
ChannelHandlerContext
;
internal
fun
onPacketReceived
(
packet
:
Packet
)
{
if
(
packet
!
is
ServerPacket
)
{
return
;
return
}
packet
.
decode
()
if
(
packet
is
Server0825Packet
)
{
//todo 检查是否需要修改 UDP 连接???
sendPacket
(
Client0825ResponsePacket
(
packet
.
serverIP
,
number
))
;
sendPacket
(
Client0825ResponsePacket
(
packet
.
serverIP
,
number
))
}
}
private
fun
sendPacket
(
packet
:
Packet
)
{
TODO
()
}
@Throws
(
InterruptedException
::
class
)
...
...
@@ -53,8 +54,9 @@ class Robot(val number: Long) {
ch
.
pipeline
().
addLast
(
ByteArrayEncoder
())
ch
.
pipeline
().
addLast
(
ByteArrayDecoder
())
ch
.
pipeline
().
addLast
(
object
:
SimpleChannelInboundHandler
<
ByteArray
>()
{
override
fun
channelRead0
(
ctx
:
ChannelHandlerContext
?
,
bytes
:
ByteArray
)
{
override
fun
channelRead0
(
ctx
:
ChannelHandlerContext
,
bytes
:
ByteArray
)
{
try
{
this
@Robot
.
ctx
=
ctx
;
/*val remaining = Reader.read(bytes);
if (Reader.isPacketAvailable()) {
robot.onPacketReceived(Reader.toServerPacket())
...
...
mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/Client0825ResponsePacket.kt
View file @
52857fad
...
...
@@ -3,6 +3,7 @@ package net.mamoe.mirai.network.packet.client
import
net.mamoe.mirai.network.Protocol
import
net.mamoe.mirai.network.packet.PacketId
import
net.mamoe.mirai.util.TEAEncryption
import
net.mamoe.mirai.util.hexToBytes
import
java.io.IOException
/**
...
...
@@ -27,6 +28,6 @@ class Client0825ResponsePacket(private val serverIP: String, private val qq: Lon
this
.
writeHex
(
"01 6F A1 58 22 01 00 36 00 12 00 02 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 14 00 1D 01 03 00 19"
)
this
.
writeHex
(
Protocol
.
publicKey
)
}
}.
encodeToByteArray
(),
Protocol
.
hexToBytes
(
Protocol
.
redirectionKey
)))
}.
encodeToByteArray
(),
Protocol
.
redirectionKey
.
hexToBytes
(
)))
}
}
\ No newline at end of file
mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/ClientLoginPacket.java
View file @
52857fad
...
...
@@ -5,8 +5,10 @@ import lombok.EqualsAndHashCode;
import
net.mamoe.mirai.network.Protocol
;
import
net.mamoe.mirai.network.packet.PacketId
;
import
net.mamoe.mirai.util.TEAEncryption
;
import
net.mamoe.mirai.util.Utils
;
import
java.io.IOException
;
import
java.util.Arrays
;
/**
* @author Him188moe @ Mirai Project
...
...
@@ -32,10 +34,25 @@ public class ClientLoginPacket extends ClientPacket {
this
.
writeHex
(
Protocol
.
_0825data2
);
this
.
writeQQ
(
qq
);
this
.
writeHex
(
"00 00 00 00 03 09 00 08 00 01"
);
this
.
writeIp
(
Protocol
.
SERVER_IP
.
get
(
2
));
//this.writeIp(Protocol.SERVER_IP.get(2));
this
.
writeIp
(
"123456789"
);
this
.
writeHex
(
"00 02 00 36 00 12 00 02 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 14 00 1D 01 02 00 19"
);
this
.
writeHex
(
Protocol
.
publicKey
);
}
}.
encodeToByteArray
(),
Protocol
.
hexToBytes
(
Protocol
.
_0825key
)));
}
public
static
void
main
(
String
[]
args
)
throws
IOException
{
try
{
var
pk
=
new
ClientLoginPacket
();
pk
.
qq
=
1994701021
;
pk
.
encode
();
pk
.
writeHex
(
Protocol
.
tail
);
System
.
out
.
println
(
"pk.toByteArray() = "
+
Arrays
.
toString
(
pk
.
toByteArray
()));
System
.
out
.
println
(
Utils
.
INSTANCE
.
toHexString
(
pk
.
toByteArray
()));
}
catch
(
Throwable
e
)
{
e
.
printStackTrace
();
}
}
}
mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/ClientPacket.java
View file @
52857fad
...
...
@@ -13,14 +13,12 @@ import java.io.IOException;
* @author Him188moe @ Mirai Project
*/
public
abstract
class
ClientPacket
extends
DataOutputStream
implements
Packet
{
public
ClientPacket
()
{
super
(
new
ByteArrayOutputStream
());
}
@Getter
private
final
int
packageId
;
{
public
ClientPacket
()
{
super
(
new
ByteArrayOutputStream
());
var
annotation
=
this
.
getClass
().
getAnnotation
(
PacketId
.
class
);
packageId
=
annotation
.
value
();
...
...
mirai-core/src/main/java/net/mamoe/mirai/util/Utils.kt
0 → 100644
View file @
52857fad
package
net.mamoe.mirai.util
import
net.mamoe.mirai.network.Protocol
/**
* @author Him188moe @ Mirai Project
*/
object
Utils
{
fun
toHexString
(
byteArray
:
ByteArray
):
String
=
byteArray
.
joinToString
(
" "
)
{
it
.
toString
(
16
)
}
}
fun
ByteArray
.
toHexString
():
String
=
Utils
.
toHexString
(
this
)
fun
Byte
.
toHexString
():
String
=
this
.
toString
(
16
)
fun
String
.
hexToBytes
():
ByteArray
=
Protocol
.
hexToBytes
(
this
)
\ 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