26 包 monorepo(TS 全源码): - snowcat-core: NT 内核 API 封装 + listener(含 9.9.37 六回调适配)+ Packet 发包 - snowcat-onebot: OneBot v11 全动作 + MCP Streamable HTTP 适配器 + 稳定线 - snowcat-webui-frontend/backend: 雪猫控制台(React+HeroUI) - snowcat-shell: 单文件 bundle 出口(vite inlineDynamicImports) - snowcat-native: napi2native / MoeHoo / ffmpeg / pty 运行时 - 56 项 SnowLuma 独门动作移植(qzone 全家桶/群相册/装扮/闪照/收藏) - 工具件: 解包器/启动器/便携制作器/doctor GitHub 关联已全量指向 DandanLLab/SnowCatQQ
65 lines
1.9 KiB
TypeScript
65 lines
1.9 KiB
TypeScript
// import * as tea from '@/snowcat-core/packet/utils/crypto/tea';
|
|
import { NapProtoMsg } from 'snowcat-protobuf';
|
|
import { PacketHighwayTrans } from '@/snowcat-core/packet/highway/client';
|
|
import { PacketLogger } from '@/snowcat-core/packet/context/loggerContext';
|
|
import * as proto from '@/snowcat-core/packet/transformer/proto';
|
|
|
|
export abstract class IHighwayUploader {
|
|
readonly trans: PacketHighwayTrans;
|
|
readonly logger: PacketLogger;
|
|
|
|
constructor (trans: PacketHighwayTrans, logger: PacketLogger) {
|
|
this.trans = trans;
|
|
this.logger = logger;
|
|
}
|
|
|
|
// TODO: 没用到的加密方法先注释掉
|
|
// private encryptTransExt (key: Uint8Array) {
|
|
// if (!this.trans.encrypt) return;
|
|
// this.trans.ext = tea.encrypt(Buffer.from(this.trans.ext), Buffer.from(key));
|
|
// }
|
|
|
|
protected timeout (): Promise<void> {
|
|
return new Promise<void>((_resolve, reject) => {
|
|
setTimeout(() => {
|
|
reject(new Error(`[Highway] timeout after ${this.trans.timeout}s`));
|
|
}, (this.trans.timeout ?? Infinity) * 1000
|
|
);
|
|
});
|
|
}
|
|
|
|
buildPicUpHead (offset: number, bodyLength: number, bodyMd5: Uint8Array): Uint8Array {
|
|
return new NapProtoMsg(proto.ReqDataHighwayHead).encode({
|
|
msgBaseHead: {
|
|
version: 1,
|
|
uin: this.trans.uin,
|
|
command: 'PicUp.DataUp',
|
|
seq: 0,
|
|
retryTimes: 0,
|
|
appId: 1600001604,
|
|
dataFlag: 16,
|
|
commandId: this.trans.cmd,
|
|
},
|
|
msgSegHead: {
|
|
serviceId: 0,
|
|
filesize: BigInt(this.trans.size),
|
|
dataOffset: BigInt(offset),
|
|
dataLength: bodyLength,
|
|
serviceTicket: this.trans.ticket,
|
|
md5: bodyMd5,
|
|
fileMd5: this.trans.sum,
|
|
cacheAddr: 0,
|
|
cachePort: 0,
|
|
},
|
|
bytesReqExtendInfo: this.trans.ext,
|
|
timestamp: BigInt(0),
|
|
msgLoginSigHead: {
|
|
uint32LoginSigType: 8,
|
|
appId: 1600001604,
|
|
},
|
|
});
|
|
}
|
|
|
|
abstract upload (): Promise<void>;
|
|
}
|