feat: add new NapCat config key: packetBackend
- Acceptable values: `native`, `frida`, `auto`, `disable` - Default value is set to `auto`
This commit is contained in:
5 files changed
+25
-5
No files matched your search
@@ -23,11 +23,26 @@ export class PacketSession {
|
||||
|
||||
constructor(core: NapCatCore) {
|
||||
this.logger = core.context.logger;
|
||||
this.client = this.judgeClient(core);
|
||||
this.client = this.newClient(core);
|
||||
this.packer = new PacketPacker(this.logger, this.client);
|
||||
this.highwaySession = new PacketHighwaySession(this.logger, this.client, this.packer);
|
||||
}
|
||||
|
||||
private newClient(core: NapCatCore): PacketClient {
|
||||
const prefer = core.configLoader.configData.packetBackend;
|
||||
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},请检查配置文件!`);
|
||||
}
|
||||
}
|
||||
|
||||
private judgeClient(core: NapCatCore): PacketClient {
|
||||
const sortedClients = Object.entries(clientPriority)
|
||||
.map(([priority, clientFactory]) => {
|
||||
|
||||
Reference in new issue
Block a user