diff --git a/server/proxy/deploy-brain-proxy.sh b/server/proxy/deploy-brain-proxy.sh index 87dffd56..cc538543 100644 --- a/server/proxy/deploy-brain-proxy.sh +++ b/server/proxy/deploy-brain-proxy.sh @@ -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端口配置,可能已切换" diff --git a/server/proxy/service/llm-router.js b/server/proxy/service/llm-router.js index c38fa446..a0f2cac6 100644 --- a/server/proxy/service/llm-router.js +++ b/server/proxy/service/llm-router.js @@ -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); diff --git a/server/proxy/service/subscription-server-v3.js b/server/proxy/service/subscription-server-v3.js index 7c616559..abec1379 100644 --- a/server/proxy/service/subscription-server-v3.js +++ b/server/proxy/service/subscription-server-v3.js @@ -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, '&').replace(//g, '>').replace(/"/g, '"'); + const html = `
-