Files
TankIC/3DTank/tools/dump_codec_src.js
T
TermiNexus b083d27165 fix(protocol): TankState 按 23 字节定长 blob(T5)解码,修复 TankCC 后续字节错位
- codec_fields:module_87072::T5 记为单字段 bytes23;pq.tankState 的 TypeCodec 由 85183::jq 改指 87072::T5
- 生成器支持 bytes<N>(ByteArray / R.ReadRaw(N) / W.WriteRaw),重生成 Module87072、Module85183
- 审计链:lib_space_codec 新增 bytes<N>;audit_pt_boundaries / audit_bit_budget 支持 --body/--plain;semantic 暴露 Out.Bits
- 新增工具:audit_bit_budget(nullmap 位预算)、probe_pt_record(pt 项级)、analyze_item_trace(客户端项级打点对照)、dump_codec_src
- wss_server 新增 --dump-plain:把解密+解压后的裸帧体落到 plain/,供离线审计
- 镜像打点:opt 全量位位置、pt 项级字节/位区间、TankCC 逐字段区间;重新打包 unpacked.pack.json
2026-10-21 15:21:10 +08:00

41 lines
1.5 KiB
JavaScript

// _dump_codec_src.js —— 打印指定 codec 的 u7h / t7h 源码体(临时诊断用)
// 用法: node _dump_codec_src.js 85183::Tl 85183::Rl ...
'use strict';
const fs = require('fs');
const path = require('path');
const SRC = path.join(__dirname, '..', 'src');
function MatchBrace(Src, Start) {
let Depth = 0;
for (let I = Start; I < Src.length; I++) {
if (Src[I] === '{') Depth++;
else if (Src[I] === '}') { Depth--; if (Depth === 0) return I; }
}
return -1;
}
function ClassMethod(Src, Cls, Kind) {
const Head = new RegExp('\\(\\s*' + Cls.replace(/\$/g, '\\$') + '\\s*\\)\\.' + Kind + '\\s*=\\s*function\\s*\\([^)]*\\)\\s*\\{', 'g');
const Out = [];
let M;
while ((M = Head.exec(Src))) {
const Start = M.index + M[0].length - 1;
const End = MatchBrace(Src, Start);
if (End > 0) Out.push(Src.slice(Start, End + 1));
}
return Out;
}
for (const Key of process.argv.slice(2)) {
const [Mod, Cls] = Key.split('::');
const File = path.join(SRC, (Mod.startsWith('module_') ? Mod : 'module_' + Mod) + '.js');
if (!fs.existsSync(File)) { console.log('!! 无源码 ' + File); continue; }
const Src = fs.readFileSync(File, 'utf8');
console.log('=== ' + Key + ' ===');
for (const Kind of ['u7h', 't7h']) {
const Bodies = ClassMethod(Src, Cls, Kind);
if (!Bodies.length) { console.log(' [' + Kind + '] 未找到'); continue; }
Bodies.forEach((B, I) => console.log(' [' + Kind + '#' + I + '] ' + B.replace(/\s+/g, ' ')));
}
}