mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
Compare commits
24 Commits
e46d274a75
...
v3.5.0
Author | SHA1 | Date | |
---|---|---|---|
![]() |
2a2328b029 | ||
![]() |
efc9064abb | ||
![]() |
dd70adf071 | ||
![]() |
0f427375cb | ||
![]() |
4001270b93 | ||
![]() |
e7f5ed3bcc | ||
![]() |
05cdc37d0a | ||
![]() |
27920e0bee | ||
![]() |
ae409b7249 | ||
![]() |
8276258348 | ||
![]() |
1bf96a97a5 | ||
![]() |
d672680c4c | ||
![]() |
b89f2805e7 | ||
![]() |
78b4aa9295 | ||
![]() |
0a06637e78 | ||
![]() |
13afa2c7ab | ||
![]() |
51d34d17cc | ||
![]() |
18a99341d5 | ||
![]() |
f01c8f0110 | ||
![]() |
d8070eee2a | ||
![]() |
8519b7f4df | ||
![]() |
591ab1b1df | ||
![]() |
393815b11e | ||
![]() |
341a397bc4 |
BIN
external/LiteLoaderWrapper.zip
vendored
BIN
external/LiteLoaderWrapper.zip
vendored
Binary file not shown.
@@ -4,7 +4,7 @@
|
||||
"name": "NapCatQQ",
|
||||
"slug": "NapCat.Framework",
|
||||
"description": "高性能的 OneBot 11 协议实现",
|
||||
"version": "3.4.7",
|
||||
"version": "3.4.11",
|
||||
"icon": "./logo.png",
|
||||
"authors": [
|
||||
{
|
||||
|
@@ -2,7 +2,7 @@
|
||||
"name": "napcat",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"version": "3.4.7",
|
||||
"version": "3.4.11",
|
||||
"scripts": {
|
||||
"build:framework": "vite build --mode framework",
|
||||
"build:shell": "vite build --mode shell",
|
||||
@@ -40,7 +40,7 @@
|
||||
"typescript": "^5.3.3",
|
||||
"vite": "^5.2.6",
|
||||
"vite-plugin-cp": "^4.0.8",
|
||||
"vite-tsconfig-paths": "^4.3.2"
|
||||
"vite-tsconfig-paths": "^5.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"express": "^5.0.0",
|
||||
|
@@ -1 +1 @@
|
||||
export const napCatVersion = '3.4.7';
|
||||
export const napCatVersion = '3.4.11';
|
||||
|
@@ -53,18 +53,14 @@ export abstract class PacketClient {
|
||||
|
||||
private async registerCallback(trace_id: string, type: string, callback: (json: RecvPacketData) => Promise<void>): Promise<void> {
|
||||
this.cb.put(createHash('md5').update(trace_id).digest('hex') + type, callback);
|
||||
console.log(this.cb.cache);
|
||||
}
|
||||
|
||||
private async sendCommand(cmd: string, data: string, trace_id: string, rsp: boolean = false, timeout: number = 20000, sendcb: (json: RecvPacketData) => void = () => {
|
||||
}): Promise<RecvPacketData> {
|
||||
return new Promise<RecvPacketData>((resolve, reject) => {
|
||||
if (rsp) {
|
||||
this.registerCallback(trace_id, 'recv', async (json: RecvPacketData) => {
|
||||
clearTimeout(timeoutHandle);
|
||||
resolve(json);
|
||||
});
|
||||
}
|
||||
const timeoutHandle = setTimeout(() => {
|
||||
reject(new Error(`sendCommand timed out after ${timeout} ms for ${cmd} with trace_id ${trace_id}`));
|
||||
}, timeout);
|
||||
this.registerCallback(trace_id, 'send', async (json: RecvPacketData) => {
|
||||
sendcb(json);
|
||||
if (!rsp) {
|
||||
@@ -72,10 +68,13 @@ export abstract class PacketClient {
|
||||
resolve(json);
|
||||
}
|
||||
});
|
||||
if (rsp) {
|
||||
this.registerCallback(trace_id, 'recv', async (json: RecvPacketData) => {
|
||||
clearTimeout(timeoutHandle);
|
||||
resolve(json);
|
||||
});
|
||||
}
|
||||
this.sendCommandImpl(cmd, data, trace_id);
|
||||
const timeoutHandle = setTimeout(() => {
|
||||
reject(new Error(`sendCommand timed out after ${timeout} ms for ${cmd} with trace_id ${trace_id}`));
|
||||
}, timeout);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -90,7 +89,7 @@ export abstract class PacketClient {
|
||||
const trace_id = (this.randText(4) + md5 + data).slice(0, data.length / 2);
|
||||
|
||||
this.sendCommand(cmd, data, trace_id, rsp, 20000, async () => {
|
||||
console.log('sendPacket:', cmd, data, trace_id);
|
||||
//console.log('sendPacket:', cmd, data, trace_id);
|
||||
await this.napCatCore.context.session.getMsgService().sendSsoCmdReqByContend(cmd, trace_id);
|
||||
}).then((res) => resolve(res)).catch((e: Error) => reject(e));
|
||||
});
|
||||
|
@@ -12,7 +12,7 @@ export interface NativePacketExportType {
|
||||
SendPacket?: (cmd: string, data: string, trace_id: string) => void;
|
||||
}
|
||||
export class NativePacketClient extends PacketClient {
|
||||
private readonly supportedPlatforms = ['win32.x64'];
|
||||
private readonly supportedPlatforms = ['win32.x64', 'linux.x64', 'linux.arm64'];
|
||||
private MoeHooExport: { exports: NativePacketExportType } = { exports: {} };
|
||||
private sendEvent = new LRUCache<number, string>(500);//seq->trace_id
|
||||
constructor(core: NapCatCore) {
|
||||
@@ -41,8 +41,6 @@ export class NativePacketClient extends PacketClient {
|
||||
const platform = process.platform + '.' + process.arch;
|
||||
const moehoo_path = path.join(dirname(fileURLToPath(import.meta.url)), './moehoo/MoeHoo.' + platform + '.node');
|
||||
process.dlopen(this.MoeHooExport, moehoo_path, constants.dlopen.RTLD_LAZY);
|
||||
console.log('MoeHooExport:', this.MoeHooExport);
|
||||
console.log('recv:', recv, 'send:',);
|
||||
this.MoeHooExport.exports.InitHook?.(send, recv, (type: number, uin: string, cmd: string, seq: number, hex_data: string) => {
|
||||
const trace_id = createHash('md5').update(Buffer.from(hex_data, 'hex')).digest('hex');
|
||||
if (type === 0 && this.cb.get(trace_id + 'recv')) {
|
||||
@@ -53,7 +51,7 @@ export class NativePacketClient extends PacketClient {
|
||||
//此时为recv 调用callback
|
||||
const trace_id = this.sendEvent.get(seq);
|
||||
const callback = this.cb.get(trace_id + 'recv');
|
||||
console.log('callback:', callback, trace_id);
|
||||
// console.log('callback:', callback, trace_id);
|
||||
callback?.({ seq, cmd, hex_data });
|
||||
}
|
||||
|
||||
@@ -63,14 +61,14 @@ export class NativePacketClient extends PacketClient {
|
||||
// } else {
|
||||
// this.logger.logError(`Callback not found for hex_data: ${hex_data}`);
|
||||
// }
|
||||
console.log('type:', type, 'cmd:', cmd, 'trace_id:', trace_id);
|
||||
//console.log('type:', type, 'cmd:', cmd, 'trace_id:', trace_id);
|
||||
});
|
||||
this.isAvailable = true;
|
||||
}
|
||||
|
||||
sendCommandImpl(cmd: string, data: string, trace_id: string): void {
|
||||
const trace_id_md5 = createHash('md5').update(trace_id).digest('hex');
|
||||
console.log('sendCommandImpl:', cmd, data, trace_id_md5);
|
||||
//console.log('sendCommandImpl:', cmd, data, trace_id_md5);
|
||||
this.MoeHooExport.exports.SendPacket?.(cmd, data, trace_id_md5);
|
||||
this.cb.get(trace_id_md5 + 'send')?.({ seq: 0, cmd, hex_data: '' });
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@ const clientPriority: clientPriority = {
|
||||
|
||||
export class PacketSession {
|
||||
readonly logger: LogWrapper;
|
||||
readonly client: PacketClient;
|
||||
readonly client: PacketClient ;
|
||||
readonly packer: PacketPacker;
|
||||
readonly highwaySession: PacketHighwaySession;
|
||||
|
||||
@@ -30,17 +30,28 @@ export class PacketSession {
|
||||
|
||||
private newClient(core: NapCatCore): PacketClient {
|
||||
const prefer = core.configLoader.configData.packetBackend;
|
||||
let client: PacketClient | null;
|
||||
switch (prefer) {
|
||||
case "native":
|
||||
return new NativePacketClient(core);
|
||||
case "frida":
|
||||
return new wsPacketClient(core);
|
||||
case "auto":
|
||||
case undefined:
|
||||
return this.judgeClient(core);
|
||||
default:
|
||||
throw new Error(`[Core] [Packet] 未知的Packet后端类型 ${prefer},请检查配置文件!`);
|
||||
case "native":
|
||||
this.logger.log("[Core] [Packet] 使用指定的 NativePacketClient 作为后端");
|
||||
client = new NativePacketClient(core);
|
||||
break;
|
||||
case "frida":
|
||||
this.logger.log("[Core] [Packet] 使用指定的 FridaPacketClient 作为后端");
|
||||
client = new wsPacketClient(core);
|
||||
break;
|
||||
case "auto":
|
||||
case undefined:
|
||||
client = this.judgeClient(core);
|
||||
break;
|
||||
default:
|
||||
this.logger.logError(`[Core] [Packet] 未知的Packet后端类型 ${prefer},请检查配置文件!`);
|
||||
client = null;
|
||||
}
|
||||
if (!(client && client.check(core))) {
|
||||
throw new Error("[Core] [Packet] 无可用的后端,NapCat.Packet将不会加载!");
|
||||
}
|
||||
return client;
|
||||
}
|
||||
|
||||
private judgeClient(core: NapCatCore): PacketClient {
|
||||
|
BIN
src/native/packet/MoeHoo.linux.arm64.node
Normal file
BIN
src/native/packet/MoeHoo.linux.arm64.node
Normal file
Binary file not shown.
BIN
src/native/packet/MoeHoo.linux.x64.node
Normal file
BIN
src/native/packet/MoeHoo.linux.x64.node
Normal file
Binary file not shown.
Binary file not shown.
@@ -164,7 +164,7 @@ async function onSettingWindowCreated(view) {
|
||||
SettingItem(
|
||||
'<span id="napcat-update-title">Napcat</span>',
|
||||
void 0,
|
||||
SettingButton("V3.4.7", "napcat-update-button", "secondary")
|
||||
SettingButton("V3.4.11", "napcat-update-button", "secondary")
|
||||
)
|
||||
]),
|
||||
SettingList([
|
||||
|
Reference in New Issue
Block a user