diff --git a/tools/gatekeeper.js b/tools/gatekeeper.js index d8c314b..371b443 100644 --- a/tools/gatekeeper.js +++ b/tools/gatekeeper.js @@ -1,12 +1,12 @@ #!/usr/bin/env node /* ═══════════════════════════════════════ - 铸渊守门人 v2.0 · HLDP万能语言接口 - 新增 /hlpd 端点 — HLDP模块翻译执行 + 光湖驱动引擎 v2.0 · Guanghu Drive Engine + HLDP万能语言接口 — HLDP进,指令出 ═══════════════════════════════════════ */ const http=require('http'),fs=require('fs'),path=require('path'),crypto=require('crypto'),{exec}=require('child_process'),os=require('os'); -const PORT=parseInt(process.env.GATEKEEPER_PORT||process.argv[2]||'3910',10); +const PORT=parseInt(process.env.ENGINE_PORT||process.env.GATEKEEPER_PORT||process.argv[2]||'3910',10); const DATA_DIR=path.join(os.homedir(),'.gatekeeper'); const CMD_TIMEOUT=30000,MAX_OUTPUT=100000,RATE_LIMIT=60; @@ -21,7 +21,7 @@ if(!API_SECRET){ fs.writeFileSync(SECRET_FILE,API_SECRET,{mode:0o600}); console.log(''); console.log('══════════════════════════════════════════════'); - console.log(' 🔐 铸渊看门人 · 首次启动'); + console.log(' 🔐 光湖驱动引擎 · 首次启动'); console.log(''); console.log(' ╭─ API 密钥(请复制保存)'); console.log(' ├─ '+API_SECRET); @@ -37,7 +37,7 @@ function log(level,action,detail){ const ts=new Date().toISOString(); const line='['+ts+'] ['+level+'] '+action+(detail?' | '+detail:''); console.log(line); - try{const lf=path.join(DATA_DIR,'gatekeeper.log');fs.appendFileSync(lf,line+'\n');}catch(e){} + try{const lf=path.join(DATA_DIR,'engine.log');fs.appendFileSync(lf,line+'\n');}catch(e){} } const RC={}; @@ -74,7 +74,7 @@ function fmtBytes(b){if(b===0)return'0 B';const k=1024,sizes=['B','KB','MB','GB' /* ═══════════════════════════════════════ - HLDP 翻译层 v1.0 — 守门人 v2.0 新增 + HLDP 翻译层 v1.0 — 光湖驱动引擎 v2.0 ═══════════════════════════════════════ */ function parseHLDP(text){ @@ -150,11 +150,11 @@ const server=http.createServer(async(req,res)=>{ log('INFO','exec_result','exit='+r.code); jr(res,200,{ok:r.code===0,stdout:r.stdout,stderr:r.stderr,exitCode:r.code}); }else if(route==='/health'){ - jr(res,200,{ok:true,service:'zhuyuan-gatekeeper',version:'2.0.0',uptime:process.uptime().toFixed(0)+'s',timestamp:new Date().toISOString()}); + jr(res,200,{ok:true,service:'guanghu-engine',version:'2.0.0',uptime:process.uptime().toFixed(0)+'s',timestamp:new Date().toISOString()}); }else if(route==='/status'){ log('INFO','status',''); const total=os.totalmem(),free=os.freemem(); - jr(res,200,{ok:true,hostname:os.hostname(),platform:os.platform(),arch:os.arch(),cpus:os.cpus().length,uptime:os.uptime(),uptime_str:fmtUptime(os.uptime()),memory:{total:fmtBytes(total),free:fmtBytes(free),used:fmtBytes(total-free),usage:((total-free)/total*100).toFixed(1)+'%'},load:os.loadavg().map(n=>+n.toFixed(2)),gatekeeper:{version:'2.0.0',port:PORT,uptime:process.uptime().toFixed(0)+'s'}}); + jr(res,200,{ok:true,hostname:os.hostname(),platform:os.platform(),arch:os.arch(),cpus:os.cpus().length,uptime:os.uptime(),uptime_str:fmtUptime(os.uptime()),memory:{total:fmtBytes(total),free:fmtBytes(free),used:fmtBytes(total-free),usage:((total-free)/total*100).toFixed(1)+'%'},load:os.loadavg().map(n=>+n.toFixed(2)),engine:{version:'2.0.0',port:PORT,uptime:process.uptime().toFixed(0)+'s'}}); }else if(route==='/hlpd'){ const b=await parseBody(req); if(!b||!b.hlpd){jr(res,400,{error:'缺少 hlpd 参数'});return;} @@ -214,7 +214,7 @@ server.on('error',(e)=>{ server.listen(PORT,'0.0.0.0',()=>{ const h=os.hostname(); log('INFO','startup','host='+h+' port='+PORT+' v2.0'); - console.log(' ⚔️ 铸渊守门人 v2.0 · HLDP 已就绪'); + console.log(' ⚔️ 光湖驱动引擎 v2.0 · HLDP 已就绪'); console.log(' 主机名: '+h+' 端口: '+PORT); });