mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-19 17:14:42 +08:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
913ecd60de
14
README.md
14
README.md
@ -7,6 +7,20 @@
|
|||||||
协议来自网络的易语言开源软件
|
协议来自网络的易语言开源软件
|
||||||
一切开发旨在学习, 请勿用于非法用途
|
一切开发旨在学习, 请勿用于非法用途
|
||||||
|
|
||||||
|
### 我们会坚持开发, 但是,
|
||||||
|
![LV7_YX10AQ5TW@E~308_0JN.png](https://i.loli.net/2019/08/24/oQIzhaLvyJOeW1f.png)
|
||||||
|
|
||||||
|
### 代码结构
|
||||||
|
Network部分使用 Kotlin 完成(因为kt有对 unsigned byte 的支持), 与插件相关性强(或任何其他在二次开发中容易接触的部分)均使用 Java 完成.
|
||||||
|
|
||||||
|
### TODO
|
||||||
|
- [x] 事件(Event)模块
|
||||||
|
- [ ] 插件(Plugin)模块 **(Working on)**
|
||||||
|
- [x] Network - Touch
|
||||||
|
- [ ] Network - Login **(Working on)**
|
||||||
|
- [ ] Network - Message
|
||||||
|
- [ ] Network - Events
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
A JAVA(+Kotlin) powered open-sources project under GPL license<br>
|
A JAVA(+Kotlin) powered open-sources project under GPL license<br>
|
||||||
|
@ -21,7 +21,10 @@ public class MiraiUDPClient {
|
|||||||
this.listener = new LocalUDPListener(new LocalUDPSocketProvider(
|
this.listener = new LocalUDPListener(new LocalUDPSocketProvider(
|
||||||
address,localPort,serverPort,null
|
address,localPort,serverPort,null
|
||||||
));
|
));
|
||||||
|
this.listener.startup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,8 +6,13 @@ import net.mamoe.mirai.network.Protocol;
|
|||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.concurrent.atomic.LongAdder;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This could be used to check packet encoding..
|
* This could be used to check packet encoding..
|
||||||
@ -29,6 +34,10 @@ public class HexComparator {
|
|||||||
|
|
||||||
private static final String BLUE = "\033[34m";
|
private static final String BLUE = "\033[34m";
|
||||||
|
|
||||||
|
public static final List<HexReader> consts = new LinkedList<>(){{
|
||||||
|
add(new HexReader("90 5E 39 DF 00 02 76 E4 B8 DD 00"));
|
||||||
|
}};
|
||||||
|
|
||||||
private static class ConstMatcher {
|
private static class ConstMatcher {
|
||||||
private static final List<Field> CONST_FIELDS = new LinkedList<>() {{
|
private static final List<Field> CONST_FIELDS = new LinkedList<>() {{
|
||||||
List.of(Protocol.class).forEach(aClass -> Arrays.stream(aClass.getDeclaredFields()).peek(this::add).forEach(Field::trySetAccessible));
|
List.of(Protocol.class).forEach(aClass -> Arrays.stream(aClass.getDeclaredFields()).peek(this::add).forEach(Field::trySetAccessible));
|
||||||
@ -151,6 +160,9 @@ public class HexComparator {
|
|||||||
if (isDif) {
|
if (isDif) {
|
||||||
++dif;
|
++dif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//doConstReplacement(hex1b);
|
||||||
|
//doConstReplacement(hex2b);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (builder.append(" ").append(dif).append(" 个不同").append("\n")
|
return (builder.append(" ").append(dif).append(" 个不同").append("\n")
|
||||||
@ -158,8 +170,38 @@ public class HexComparator {
|
|||||||
.append(hex1b).append("\n")
|
.append(hex1b).append("\n")
|
||||||
.append(hex2b))
|
.append(hex2b))
|
||||||
.toString();
|
.toString();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static void doConstReplacement(StringBuilder builder){
|
||||||
|
String mirror = builder.toString();
|
||||||
|
HexReader hexs = new HexReader(mirror);
|
||||||
|
for (AtomicInteger i=new AtomicInteger(0);i.get()<builder.length();i.addAndGet(1)){
|
||||||
|
hexs.setTo(i.get());
|
||||||
|
consts.forEach(a -> {
|
||||||
|
hexs.setTo(i.get());
|
||||||
|
List<Integer> posToPlaceColor = new LinkedList<>();
|
||||||
|
AtomicBoolean is = new AtomicBoolean(false);
|
||||||
|
|
||||||
|
a.readFully((c,d) -> {
|
||||||
|
if(c.equals(hexs.readHex())){
|
||||||
|
posToPlaceColor.add(d);
|
||||||
|
}else{
|
||||||
|
is.set(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if(is.get()){
|
||||||
|
AtomicInteger adder = new AtomicInteger();
|
||||||
|
posToPlaceColor.forEach(e -> {
|
||||||
|
builder.insert(e + adder.getAndAdd(BLUE.length()),BLUE);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
private static String getNumber(int number) {
|
private static String getNumber(int number) {
|
||||||
if (number < 10) {
|
if (number < 10) {
|
||||||
return "00" + number;
|
return "00" + number;
|
||||||
@ -171,6 +213,7 @@ public class HexComparator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
/*
|
||||||
System.out.println(HexComparator.compare(
|
System.out.println(HexComparator.compare(
|
||||||
//mirai
|
//mirai
|
||||||
|
|
||||||
@ -179,6 +222,7 @@ public class HexComparator {
|
|||||||
//e
|
//e
|
||||||
"01 12 00 38 56 3A E4 8B B4 64 D2 72 60 FE 01 54 FC B1 5F 88 E0 BA 64 1A 55 F2 84 FC 97 D0 BF 5F 47 A8 D9 76 BB FB 4A 7A F3 5E 0E A4 8E CA 8F 27 C2 02 6E 5D E7 68 9F 7C CF 91 83 F4 03 0F 00 11 00 0F 44 45 53 4B 54 4F 50 2D 4D 31 37 4A 52 45 55 00 05 00 06 00 02 76 E4 B8 DD 00 06 00 78 0D DF 92 9C 5A 08 D1 67 FD 7D D6 DE CE D0 92 39 79 17 53 57 41 9B D6 D3 F9 F8 9A 3B E1 C2 3A E7 CF 02 6E 5E 36 B7 6D CF 33 66 77 FE AC 58 93 A3 85 E7 AF 6F 2D A2 74 E2 60 28 4B 29 17 04 79 95 39 D4 BF 4D C1 ED 61 49 13 23 9D 71 62 29 AF 87 D7 E3 42 49 88 3F D8 5C DB 9F 9E 5A 2A EA 02 F6 4F 2B D3 5B AF BE 0C B2 54 46 AE 99 1B 07 0B BE 6A C2 29 18 25 6A 95 0A 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 00 1A 00 40 26 2B FE EB 21 8E 08 16 BA 42 B3 A3 C5 6A 5B 31 33 A9 B3 F0 EB 16 80 BE F0 58 D3 51 98 2F A7 23 27 7C 06 97 F4 85 01 77 5C 5B D6 A2 82 54 06 A0 07 53 39 E2 E7 62 E5 09 1A 25 79 6F D9 E0 ED B6 00 18 00 16 00 01 00 00 04 53 00 00 00 01 00 00 15 85 76 E4 B8 DD 00 00 00 00 01 03 00 14 00 01 00 10 60 C9 5D A7 45 70 04 7F 21 7D 84 50 5C 66 A5 C6 01 10 00 3C 00 01 00 38 57 3A 37 C3 FB A0 C3 E5 AE F3 0E B6 03 DE BF 9E E2 B5 C5 FE A0 F0 03 4F F7 8A 5C 29 5C E0 5A A2 89 D5 3F 60 E2 B2 81 FE D4 16 04 D4 E3 C6 4A D7 A9 D9 E6 FC 2E 7E 0C F3 03 12 00 05 01 00 00 00 01 05 08 00 05 01 00 00 00 00 03 13 00 19 01 01 02 00 10 04 EA 78 D1 A4 FF CD CC 7C B8 D4 12 7D BB 03 AA 00 00 00 00 01 02 00 62 00 01 04 EB B7 C1 86 F9 08 96 ED 56 84 AB 50 85 2E 48 00 38 E9 AA 2B 4D 26 4C 76 18 FE 59 D5 A9 82 6A 0C 04 B4 49 50 D7 9B B1 FE 5D 97 54 8D 82 F3 22 C2 48 B9 C9 22 69 CA 78 AD 3E 2D E9 C9 DF A8 9E 7D 8C 8D 6B DF 4C D7 34 D0 D3 00 14 4C 97 73 32 83 1A 6F C4 94 91 0A 7A D8 21 81 58 73 3D 24 F6"
|
"01 12 00 38 56 3A E4 8B B4 64 D2 72 60 FE 01 54 FC B1 5F 88 E0 BA 64 1A 55 F2 84 FC 97 D0 BF 5F 47 A8 D9 76 BB FB 4A 7A F3 5E 0E A4 8E CA 8F 27 C2 02 6E 5D E7 68 9F 7C CF 91 83 F4 03 0F 00 11 00 0F 44 45 53 4B 54 4F 50 2D 4D 31 37 4A 52 45 55 00 05 00 06 00 02 76 E4 B8 DD 00 06 00 78 0D DF 92 9C 5A 08 D1 67 FD 7D D6 DE CE D0 92 39 79 17 53 57 41 9B D6 D3 F9 F8 9A 3B E1 C2 3A E7 CF 02 6E 5E 36 B7 6D CF 33 66 77 FE AC 58 93 A3 85 E7 AF 6F 2D A2 74 E2 60 28 4B 29 17 04 79 95 39 D4 BF 4D C1 ED 61 49 13 23 9D 71 62 29 AF 87 D7 E3 42 49 88 3F D8 5C DB 9F 9E 5A 2A EA 02 F6 4F 2B D3 5B AF BE 0C B2 54 46 AE 99 1B 07 0B BE 6A C2 29 18 25 6A 95 0A 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 00 1A 00 40 26 2B FE EB 21 8E 08 16 BA 42 B3 A3 C5 6A 5B 31 33 A9 B3 F0 EB 16 80 BE F0 58 D3 51 98 2F A7 23 27 7C 06 97 F4 85 01 77 5C 5B D6 A2 82 54 06 A0 07 53 39 E2 E7 62 E5 09 1A 25 79 6F D9 E0 ED B6 00 18 00 16 00 01 00 00 04 53 00 00 00 01 00 00 15 85 76 E4 B8 DD 00 00 00 00 01 03 00 14 00 01 00 10 60 C9 5D A7 45 70 04 7F 21 7D 84 50 5C 66 A5 C6 01 10 00 3C 00 01 00 38 57 3A 37 C3 FB A0 C3 E5 AE F3 0E B6 03 DE BF 9E E2 B5 C5 FE A0 F0 03 4F F7 8A 5C 29 5C E0 5A A2 89 D5 3F 60 E2 B2 81 FE D4 16 04 D4 E3 C6 4A D7 A9 D9 E6 FC 2E 7E 0C F3 03 12 00 05 01 00 00 00 01 05 08 00 05 01 00 00 00 00 03 13 00 19 01 01 02 00 10 04 EA 78 D1 A4 FF CD CC 7C B8 D4 12 7D BB 03 AA 00 00 00 00 01 02 00 62 00 01 04 EB B7 C1 86 F9 08 96 ED 56 84 AB 50 85 2E 48 00 38 E9 AA 2B 4D 26 4C 76 18 FE 59 D5 A9 82 6A 0C 04 B4 49 50 D7 9B B1 FE 5D 97 54 8D 82 F3 22 C2 48 B9 C9 22 69 CA 78 AD 3E 2D E9 C9 DF A8 9E 7D 8C 8D 6B DF 4C D7 34 D0 D3 00 14 4C 97 73 32 83 1A 6F C4 94 91 0A 7A D8 21 81 58 73 3D 24 F6"
|
||||||
));
|
));
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
System.out.println(HexComparator.compare(
|
System.out.println(HexComparator.compare(
|
||||||
@ -188,4 +232,66 @@ public class HexComparator {
|
|||||||
"6F 0B DF 92 00 02 76 E4 B8 DD 00 00 04 53 00 00 00 01 00 00 15 85 00 00 01 55 35 05 8E C9 BA 16 D0 01 63 5B 59 4B 59 52 31 01 B9 00 00 00 00 00 00 00 00 00 00 00 00 00 E9 E9 E9 E9 00 00 00 00 00 00 00 00 00 10 15 74 C4 89 85 7A 19 F5 5E A9 C9 A3 5E 8A 5A 9B AA BB CC DD EE FF AA BB CC\n\n\n"
|
"6F 0B DF 92 00 02 76 E4 B8 DD 00 00 04 53 00 00 00 01 00 00 15 85 00 00 01 55 35 05 8E C9 BA 16 D0 01 63 5B 59 4B 59 52 31 01 B9 00 00 00 00 00 00 00 00 00 00 00 00 00 E9 E9 E9 E9 00 00 00 00 00 00 00 00 00 10 15 74 C4 89 85 7A 19 F5 5E A9 C9 A3 5E 8A 5A 9B AA BB CC DD EE FF AA BB CC\n\n\n"
|
||||||
));*/
|
));*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class HexReader{
|
||||||
|
private String s;
|
||||||
|
private int pos = 0;
|
||||||
|
private int lastHaxPos = 0;
|
||||||
|
|
||||||
|
|
||||||
|
public HexReader(String s){
|
||||||
|
this.s = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String readHex(){
|
||||||
|
boolean isStr = false;
|
||||||
|
String next = "";
|
||||||
|
for (;pos<s.length()-2;++pos){
|
||||||
|
|
||||||
|
char s1 = ' ';
|
||||||
|
if(pos != 0){
|
||||||
|
s1 = this.s.charAt(0);
|
||||||
|
}
|
||||||
|
char s2 = this.s.charAt(pos+1);
|
||||||
|
char s3 = this.s.charAt(pos+2);
|
||||||
|
char s4 = ' ';
|
||||||
|
if(this.s.length() != (this.pos+3)){
|
||||||
|
s4 = this.s.charAt(pos+3);
|
||||||
|
}
|
||||||
|
if(
|
||||||
|
Character.isSpaceChar(s1) && Character.isSpaceChar(s4)
|
||||||
|
&&
|
||||||
|
(Character.isDigit(s2) || Character.isAlphabetic(s2))
|
||||||
|
&&
|
||||||
|
(Character.isDigit(s3) || Character.isAlphabetic(s3))
|
||||||
|
){
|
||||||
|
this.pos+=2;
|
||||||
|
this.lastHaxPos = this.pos+1;
|
||||||
|
return String.valueOf(s2) + String.valueOf(s3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void readFully(BiConsumer<String, Integer> processor){
|
||||||
|
this.reset();
|
||||||
|
String nextHax = this.readHex();
|
||||||
|
while (!nextHax.equals(" ")){
|
||||||
|
processor.accept(nextHax,this.lastHaxPos);
|
||||||
|
nextHax = this.readHex();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTo(int pos){
|
||||||
|
this.pos = pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset(){
|
||||||
|
this.pos = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user