V3修复: XSS防护(HTML转义), LLM路由器路径修复, context长度限制, deploy grep/sed一致性

Agent-Logs-Url: https://github.com/qinfendebingshuo/guanghulab/sessions/226aae4f-48b7-4668-850c-7858729e6aa0

Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-04-05 15:52:35 +00:00 committed by GitHub
parent 7d33e49101
commit 0bac15c1e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 13 deletions

View File

@ -598,8 +598,8 @@ switch_v3() {
echo " ✅ 已备份Nginx配置到 ${NGINX_CONF}.v2-backup"
# 将 /api/proxy-v2/ 的 proxy_pass 从 3803 改为 3805
if grep -q "proxy_pass.*127\.0\.0\.1:3803" "$NGINX_CONF" 2>/dev/null; then
sed -i 's|proxy_pass[[:space:]]*http://127\.0\.0\.1:3803|proxy_pass http://127.0.0.1:3805|g' "$NGINX_CONF"
if grep -q "127\.0\.0\.1:3803" "$NGINX_CONF" 2>/dev/null; then
sed -i 's|127\.0\.0\.1:3803|127.0.0.1:3805|g' "$NGINX_CONF"
echo " ✅ /api/proxy-v2/ 已切换到V3 (3803→3805)"
else
echo " ⚠️ 未找到3803端口配置可能已切换"

View File

@ -132,12 +132,13 @@ function _callSingleModel(baseUrl, apiKey, model, prompt, systemPrompt, maxToken
temperature: 0.3
});
// 构建路径如果baseUrl包含路径则使用否则追加 /v1/chat/completions
// 构建路径如果baseUrl已包含chat/completions路径则使用
// 否则追加 /v1/chat/completions
let apiPath = urlObj.pathname;
if (apiPath === '/' || apiPath === '') {
if (!apiPath || apiPath === '/') {
apiPath = '/v1/chat/completions';
} else if (!apiPath.endsWith('/chat/completions')) {
apiPath = apiPath.replace(/\/$/, '') + '/v1/chat/completions';
} else if (!apiPath.includes('/chat/completions')) {
apiPath = apiPath.replace(/\/+$/, '') + '/chat/completions';
}
const options = {
@ -161,7 +162,7 @@ function _callSingleModel(baseUrl, apiKey, model, prompt, systemPrompt, maxToken
res.on('end', () => {
try {
if (res.statusCode >= 400) {
reject(new Error(`HTTP ${res.statusCode}: ${data.slice(0, 200)}`));
reject(new Error(`HTTP ${res.statusCode}: 请求失败`));
return;
}
const json = JSON.parse(data);

View File

@ -694,7 +694,8 @@ mode: direct
const poolStatus = userManager.getPoolStatus();
const userUsedGB = ((user.traffic.upload_bytes + user.traffic.download_bytes) / (1024 ** 3)).toFixed(2);
const nodes = buildVpnNodes();
const poolPct = Math.min(poolStatus.pool_percentage, 100).toFixed(1);
const poolUsedGB = (typeof poolStatus.pool_used_gb === 'number' ? poolStatus.pool_used_gb : 0).toFixed(1);
const poolPct = Math.min(typeof poolStatus.pool_percentage === 'number' ? poolStatus.pool_percentage : 0, 100).toFixed(1);
// 读取反向加速状态
let boostStatus = '未检测';
@ -715,12 +716,15 @@ mode: direct
const poolBarColor = poolPct > 90 ? '#e74c3c' : poolPct > 70 ? '#f39c12' : '#2ecc71';
// HTML转义防止XSS
const esc = (s) => String(s).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
const html = `<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>光湖语言世界 · ${user.label}</title>
<title>光湖语言世界 · ${esc(user.label)}</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, "PingFang SC", sans-serif; background: #0a0e27; color: #e0e0e0; padding: 20px; min-height: 100vh; }
@ -743,14 +747,14 @@ mode: direct
<body>
<div class="header">
<h1>🌐 光湖语言世界</h1>
<p>${user.label} 的专属仪表盘 冰朔开发维护</p>
<p>${esc(user.label)} 的专属仪表盘 冰朔开发维护</p>
</div>
<div class="card">
<h3>📊 流量概览</h3>
<div class="stat-row"><span class="stat-label">今日用量</span><span class="stat-value">${todayGB} GB</span></div>
<div class="stat-row"><span class="stat-label">个人本月</span><span class="stat-value">${userUsedGB} GB</span></div>
<div class="stat-row"><span class="stat-label">流量池</span><span class="stat-value">${poolStatus.pool_used_gb.toFixed(1)} / ${poolStatus.pool_total_gb} GB</span></div>
<div class="stat-row"><span class="stat-label">流量池</span><span class="stat-value">${poolUsedGB} / ${poolStatus.pool_total_gb} GB</span></div>
<div class="pool-bar">
<div class="pool-fill" style="width: ${poolPct}%; background: ${poolBarColor};">${poolPct}%</div>
</div>
@ -759,7 +763,7 @@ mode: direct
<div class="card">
<h3>🔌 节点状态 (${nodes.length})</h3>
${nodes.map(n => `<div class="node"><span>${n.name}</span><span class="online">${n.latency_ms ? n.latency_ms + 'ms' : '在线'}</span></div>`).join('\n ')}
${nodes.map(n => `<div class="node"><span>${esc(n.name)}</span><span class="online">${n.latency_ms ? n.latency_ms + 'ms' : '在线'}</span></div>`).join('\n ')}
</div>
<div class="card">

View File

@ -752,7 +752,7 @@ class ZyCloudVpn extends LivingModule {
- 连续错误: ${this._consecutiveErrors}
问题上下文:
${JSON.stringify(context, null, 2)}
${JSON.stringify(context, null, 2).slice(0, 2000)}
请分析问题原因并给出具体的修复建议要求:
1. 判断是网络层面还是服务层面的问题