diff --git a/3DTank/tools/serve.js b/3DTank/tools/serve.js
index 435dae7..fc29736 100644
--- a/3DTank/tools/serve.js
+++ b/3DTank/tools/serve.js
@@ -399,12 +399,19 @@ const Server = http.createServer((Req, Res) => {
}
const Ext = path.extname(File).toLowerCase();
const Type = MIME[Ext] || 'application/octet-stream';
- // --ws-hook:HTML 里注入抓包脚本(在主脚本之前 → 先于游戏创建 WebSocket)
- if (WS_HOOK && (Ext === '.html' || Ext === '.htm')) {
- const Html = fs.readFileSync(File, 'utf8').replace(/<\/head>/i, '');
+ // HTML 注入:
+ // ① window.__HORNET_SRV__ —— 当前配置的目标服务器编号(ClientInfo 里显示 SRV: CN1 / CN2)
+ // ② --ws-hook 时再注入抓包脚本(必须排在游戏主脚本之前)
+ if (Ext === '.html' || Ext === '.htm') {
+ const SrvMatch = /c([12])\.3dtank\.com/.exec(CONFIG_UPSTREAM);
+ const Srv = SrvMatch ? SrvMatch[1] : '1';
+ let Head = '';
+ if (WS_HOOK) Head += '';
+ let Html = fs.readFileSync(File, 'utf8');
+ Html = /<\/head>/i.test(Html) ? Html.replace(/<\/head>/i, Head + '') : (Head + Html);
const Buf = Buffer.from(Html, 'utf8');
Res.writeHead(200, { 'Content-Type': Type, 'Content-Length': Buf.length, 'Cache-Control': 'no-cache' });
- if (VERBOSE) console.log('[200] ' + Buf.length + '\t' + UrlPath + ' (已注入 ws_hook)');
+ if (VERBOSE) console.log('[200] ' + Buf.length + '\t' + UrlPath + ' (已注入 SRV=' + Srv + (WS_HOOK ? ' + ws_hook' : '') + ')');
Res.end(Buf);
return;
}
@@ -427,6 +434,6 @@ Server.listen(PORT, () => {
console.log(' 404 记录 : ' + MISSING_LOG);
console.log(' config.xml: ' + (RELAY_PORT > 0
? ('中继改写 → ws://localhost:' + RELAY_PORT + '/(动态生成,不落盘)')
- : (!REAL_CONFIG && fs.existsSync(LOCAL_CONFIG) ? '本地覆盖 ' + LOCAL_CONFIG : '回源 c1.3dtank.com(--real-config)')));
+ : (!REAL_CONFIG && fs.existsSync(LOCAL_CONFIG) ? '本地覆盖 ' + LOCAL_CONFIG : '回源 ' + CONFIG_UPSTREAM + '(--real-config)')));
console.log(' ws 抓包 : ' + (WS_HOOK ? '已开启(HTML 注入 /ws_hook.js;保存用 __ws_save__())' : '关闭(要抓包加 --ws-hook,勿用 URL hash)'));
});