diff --git a/server/nginx/zhuyuan-sovereign.conf b/server/nginx/zhuyuan-sovereign.conf
index e77bbbbf..cbbfea31 100644
--- a/server/nginx/zhuyuan-sovereign.conf
+++ b/server/nginx/zhuyuan-sovereign.conf
@@ -153,6 +153,24 @@ server {
try_files $uri $uri/ /index.html;
}
+ # ─── 带宽授权短路径 · 邮件引导用户手动输入此地址 ───
+ # 邮件不含可点击链接 (QQ邮箱反拦截),引导用户在浏览器中输入 guanghulab.online/auth
+ # 自动代理到V3订阅服务的公开授权页面
+ location = /auth {
+ proxy_pass http://ZY_BRAIN_HOST_PLACEHOLDER/api/proxy-v3/bandwidth-auth-open;
+ proxy_http_version 1.1;
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Forwarded-Proto $scheme;
+ proxy_connect_timeout 10s;
+ proxy_read_timeout 30s;
+ proxy_send_timeout 30s;
+ add_header X-Content-Type-Options nosniff always;
+ add_header X-Frame-Options DENY always;
+ add_header Cache-Control "no-store, no-cache, must-revalidate" always;
+ }
+
# ─── 光湖语言世界V3 · 带宽授权桥接 (大脑服务器反向代理) ───
# QQ邮箱拦截大脑服务器域名链接,此桥接通过guanghulab.online域名
# 将V3授权/订阅请求透传到大脑服务器的V3订阅服务 (端口3805)
diff --git a/server/proxy/service/email-hub.js b/server/proxy/service/email-hub.js
index 8a0a8dc9..1a8bcd33 100644
--- a/server/proxy/service/email-hub.js
+++ b/server/proxy/service/email-hub.js
@@ -53,8 +53,9 @@ const EMAIL_LOG_FILE = path.join(DATA_DIR, 'email-hub-log.json');
const RELEASE_NOTES_FILE = path.join(__dirname, '../config/release-notes.json');
// ── 带宽授权页面域名 ─────────────────────────
-// QQ邮箱拦截guanghulab.com域名链接,使用guanghulab.online桥接
-// guanghulab.online通过Nginx反向代理桥接到大脑服务器V3订阅服务
+// QQ邮箱拦截所有可点击链接,邮件中仅含验证码+纯文本网址引导
+// 用户在浏览器中手动输入 guanghulab.online/auth 访问公开授权页面
+// guanghulab.online/auth 通过Nginx代理到大脑服务器V3订阅服务 /bandwidth-auth-open
const BW_AUTH_HOST = process.env.ZY_BW_AUTH_HOST || 'guanghulab.online';
// ── 加载版本更新说明 ────────────────────────────
@@ -601,10 +602,13 @@ function generateFeedbackAckEmail(config) {
// ═══════════════════════════════════════════════
// 📧 邮件类型 6: 带宽共享验证码 (∞+1)
// ═══════════════════════════════════════════════
-function generateBandwidthAuthEmail(code, authPageUrl, config) {
+function generateBandwidthAuthEmail(code, config) {
const releaseNotes = loadReleaseNotesObj();
const vpnIntro = getVpnSystemIntroHtml(releaseNotes);
+ // 授权页面网址 (纯文本,不插入可点击链接,防止QQ邮箱拦截)
+ const authSiteUrl = `https://${BW_AUTH_HOST}/auth`;
+
const content = `
@@ -732,7 +744,7 @@ function generateThreatClearedEmail(config) {
// ═══════════════════════════════════════════════
// 📧 邮件类型 9: V3订阅链接 (含系统介绍 + 带宽共享邀请)
// ═══════════════════════════════════════════════
-function generateSubscriptionV3Email(subUrl, dashboardUrl, bwAuthUrl, config) {
+function generateSubscriptionV3Email(subUrl, dashboardUrl, config) {
const releaseNotes = loadReleaseNotesObj();
const vpnIntro = getVpnSystemIntroHtml(releaseNotes);
@@ -801,7 +813,7 @@ function generateSubscriptionV3Email(subUrl, dashboardUrl, bwAuthUrl, config) {
-
+
🌊 带宽共享加速计划 · 自愿参与
@@ -809,14 +821,12 @@ function generateSubscriptionV3Email(subUrl, dashboardUrl, bwAuthUrl, config) {
提升所有用户的连接速度与稳定性。此功能为自愿参与机制,
不参与不影响正常服务使用。
- ${bwAuthUrl ? `
-
` : ''}
+
+
请在谷歌浏览器中手动输入以下网址访问授权页面:
+
https://${escapeHtml(BW_AUTH_HOST)}/auth
+
- 点击上方按钮进入授权页面,在页面中申请验证码完成授权。
+ 在授权页面中输入您的邮箱和系统发送的验证码,点击「我同意授权」完成操作。
如暂不参与,无需任何操作。此邮件仅为系统通知,不参与不产生任何影响。
@@ -1000,13 +1010,13 @@ function listUserEmails() {
/**
* 发送带宽共享验证码给单个用户 (∞+1)
+ * 邮件仅含验证码 + 纯文本网址引导,不含可点击链接 (QQ邮箱反拦截)
* @param {string} email 目标邮箱
* @param {string} code 6位验证码
- * @param {string} [authPageUrl] 授权页面URL
*/
-async function sendBandwidthAuthEmail(email, code, authPageUrl) {
+async function sendBandwidthAuthEmail(email, code) {
const config = loadConfig();
- const html = generateBandwidthAuthEmail(code, authPageUrl, config);
+ const html = generateBandwidthAuthEmail(code, config);
try {
await sendEmail(email, '🌊 光湖语言世界 · 带宽共享授权验证码', html);
@@ -1063,9 +1073,8 @@ async function sendSubscriptionV3Email(email) {
const host = config.server_host || 'guanghulab.com';
const subUrl = `https://${host}/api/proxy-v3/sub/${user.token}`;
const dashboardUrl = `https://${host}/api/proxy-v3/dashboard/${user.token}`;
- const bwAuthUrl = `https://${BW_AUTH_HOST}/api/proxy-v3/bandwidth-auth/${user.token}`;
- const html = generateSubscriptionV3Email(subUrl, dashboardUrl, bwAuthUrl, config);
+ const html = generateSubscriptionV3Email(subUrl, dashboardUrl, config);
try {
await sendEmail(email, '🌐 光湖语言世界 · V3专属订阅链接', html);
@@ -1111,13 +1120,8 @@ async function sendBandwidthAuthAllEmail() {
// 为每位用户生成独立验证码
const authCode = bwPool.createAuthCode(user.email);
- // 构建用户专属授权页面URL (使用guanghulab.online桥接域名)
- let authPageUrl;
- if (user.token) {
- authPageUrl = `https://${BW_AUTH_HOST}/api/proxy-v3/bandwidth-auth/${user.token}`;
- }
-
- const html = generateBandwidthAuthEmail(authCode, authPageUrl, config);
+ // 邮件仅含验证码 + 纯文本网址引导,不含可点击链接 (QQ邮箱反拦截)
+ const html = generateBandwidthAuthEmail(authCode, config);
await sendEmail(user.email, '🌊 光湖语言世界 · 带宽共享授权验证码', html);
sent++;
console.log(` ✅ ${user.email}`);
@@ -1251,15 +1255,8 @@ async function main() {
const bwPool = require('./bandwidth-pool-agent');
const authCode = bwPool.createAuthCode(arg1);
- // 查找用户token以构建授权页面URL (使用guanghulab.online桥接域名)
- let bwAuthPageUrl;
- const bwUsers = getEnabledUsers();
- const bwUser = bwUsers.find(u => u.email === arg1);
- if (bwUser && bwUser.token) {
- bwAuthPageUrl = `https://${BW_AUTH_HOST}/api/proxy-v3/bandwidth-auth/${bwUser.token}`;
- }
-
- const result = await sendBandwidthAuthEmail(arg1, authCode, bwAuthPageUrl);
+ // 邮件仅含验证码 + 纯文本网址引导,不含可点击链接 (QQ邮箱反拦截)
+ const result = await sendBandwidthAuthEmail(arg1, authCode);
console.log(`📧 带宽验证码: ${result.sent}成功 / ${result.failed}失败`);
break;
}
diff --git a/server/proxy/service/subscription-server-v3.js b/server/proxy/service/subscription-server-v3.js
index 26a0ff2d..1bdcc930 100644
--- a/server/proxy/service/subscription-server-v3.js
+++ b/server/proxy/service/subscription-server-v3.js
@@ -36,6 +36,41 @@ const LIVE_NODES_FRESHNESS_MS = parseInt(process.env.ZY_CLOUD_HB_EXPIRY_MS || '6
// 引入用户管理器
const userManager = require('./user-manager');
+// ── 操作快照文件 ──────────────────────────────
+const AUTH_SNAPSHOT_FILE = path.join(DATA_DIR, 'bandwidth-auth-snapshots.json');
+const MAX_SNAPSHOTS = 500; // 最多保留500条快照记录
+
+/**
+ * 保存用户操作快照
+ * 记录用户授权操作详情,用于审计追溯
+ * @param {Object} snapshot 快照数据
+ */
+function saveAuthSnapshot(snapshot) {
+ try {
+ let snapshots = [];
+ try {
+ const raw = JSON.parse(fs.readFileSync(AUTH_SNAPSHOT_FILE, 'utf8'));
+ if (Array.isArray(raw)) snapshots = raw;
+ } catch { /* 文件不存在或格式错误,使用空数组 */ }
+
+ snapshots.push({
+ ...snapshot,
+ timestamp: new Date().toISOString(),
+ timestamp_ms: Date.now()
+ });
+
+ // 保留最近MAX_SNAPSHOTS条记录
+ if (snapshots.length > MAX_SNAPSHOTS) {
+ snapshots = snapshots.slice(-MAX_SNAPSHOTS);
+ }
+
+ fs.mkdirSync(DATA_DIR, { recursive: true });
+ fs.writeFileSync(AUTH_SNAPSHOT_FILE, JSON.stringify(snapshots, null, 2));
+ } catch (err) {
+ console.error('[操作快照] 保存失败:', err.message);
+ }
+}
+
// ── 加载密钥 ────────────────────────────────
function loadKeys() {
const keys = {};
@@ -809,6 +844,412 @@ mode: direct
return;
}
+ // ── ∞+1 公开带宽共享授权页面: /bandwidth-auth-open ──
+ // 用户通过邮件中纯文本网址引导访问,输入邮箱+验证码完成授权
+ // 不需要token,通过邮箱+验证码双重验证身份
+ if (pathname === '/bandwidth-auth-open') {
+
+ // POST: 提交邮箱+验证码
+ if (req.method === 'POST') {
+ let body = '';
+ req.on('data', chunk => { body += chunk; });
+ req.on('end', () => {
+ try {
+ let code = '';
+ let email = '';
+ // 支持 JSON 和 form-urlencoded
+ if (req.headers['content-type']?.includes('application/json')) {
+ const json = JSON.parse(body);
+ code = String(json.code || '').trim();
+ email = String(json.email || '').trim().toLowerCase();
+ } else {
+ const params = new URLSearchParams(body);
+ code = String(params.get('code') || '').trim();
+ email = String(params.get('email') || '').trim().toLowerCase();
+ }
+
+ if (!email || !email.includes('@')) {
+ res.writeHead(400, { 'Content-Type': 'application/json; charset=utf-8' });
+ res.end(JSON.stringify({ success: false, message: '请输入有效的邮箱地址' }));
+ return;
+ }
+
+ if (!code || code.length !== 6) {
+ res.writeHead(400, { 'Content-Type': 'application/json; charset=utf-8' });
+ res.end(JSON.stringify({ success: false, message: '请输入6位验证码' }));
+ return;
+ }
+
+ // 采集用户IP
+ const userIP = req.headers['x-forwarded-for']?.split(',')[0]?.trim()
+ || req.headers['x-real-ip']
+ || req.socket.remoteAddress
+ || '0.0.0.0';
+
+ // 验证码校验 (邮箱+验证码交叉验证)
+ const bwPool = require('./bandwidth-pool-agent');
+ const verifyResult = bwPool.verifyAuthCode(code, email);
+
+ if (!verifyResult.valid) {
+ // 保存失败操作快照
+ saveAuthSnapshot({
+ email,
+ action: 'bandwidth-auth-consent',
+ result: 'failed',
+ error: verifyResult.error,
+ ip: userIP,
+ user_agent: req.headers['user-agent'] || 'unknown',
+ auth_type: 'public-open'
+ });
+ res.writeHead(400, { 'Content-Type': 'application/json; charset=utf-8' });
+ res.end(JSON.stringify({ success: false, message: verifyResult.error }));
+ return;
+ }
+
+ // 注册为带宽贡献者
+ const regResult = bwPool.registerContributor(email, userIP);
+
+ // 保存用户操作快照 (授权记录)
+ saveAuthSnapshot({
+ email,
+ action: 'bandwidth-auth-consent',
+ result: 'authorized',
+ ip: userIP,
+ user_agent: req.headers['user-agent'] || 'unknown',
+ auth_type: 'public-open',
+ contributor_id: regResult.contributor_id
+ });
+
+ // 激活用户守护Agent
+ try {
+ const guardian = require('./user-guardian-agent');
+ guardian.activateGuardian(email);
+ } catch { /* guardian not loaded */ }
+
+ res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8' });
+ res.end(JSON.stringify({
+ success: true,
+ message: '授权成功!您的带宽已加入加速池,感谢支持。',
+ contributor_id: regResult.contributor_id
+ }));
+ } catch (err) {
+ res.writeHead(500, { 'Content-Type': 'application/json; charset=utf-8' });
+ res.end(JSON.stringify({ success: false, message: '系统异常,请稍后重试' }));
+ }
+ });
+ return;
+ }
+
+ // GET: 渲染公开授权页面 (邮箱+验证码输入)
+ const esc2 = (s) => String(s).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"');
+
+ // 读取带宽池状态
+ let poolInfo2 = { active_contributors: 0, total_contributed_gb: 0 };
+ try {
+ poolInfo2 = JSON.parse(fs.readFileSync(path.join(DATA_DIR, 'bandwidth-pool-status.json'), 'utf8'));
+ } catch { /* ignore */ }
+
+ const openAuthHtml = `
+
+
+
+
+
+
光湖语言世界 · 带宽共享授权
+
+
+
+
+
+
+
+
📊 加速池状态
+
+
${poolInfo2.active_contributors || 0}
活跃贡献者
+
${poolInfo2.total_contributed_gb || 0}
总贡献 (GB)
+
+
+
+
+
🔑 授权验证
+
请输入您的邮箱地址和邮件中收到的6位验证码。如尚未收到验证码,请联系管理员申请。
+
+
+
+
+
+
+
+ ✅ 授权确认 · 提交验证码
+ 您的闲置带宽将纳入光湖语言世界加速网络。参与带宽共享的用户越多,全网加速效能越高,您的连接速度将同步提升。
+
+
+
+ ❌ 暂不参与 · 关闭此页面
+ 本功能为自愿参与机制,不影响您的正常服务使用。未参与带宽共享的用户将通过系统默认带宽通道连接,服务质量不受影响。
+
+
+
+ 🔒 安全机制说明
+ 本系统为内部授权用户专用,所有参与者均为受邀成员。您的IP地址仅用于带宽加速调度,系统采用 SHA256 + 盐值 加密存储,外部无法访问。当系统检测到安全风险时,将自动切断所有共享通道并格式化全部共享记录,确保无痕清除。风险解除后,系统将自动重新分配订阅链接。您的隐私安全由铸渊守护体系全程保障。
+
+
+
+
+
+
+
+`;
+
+ res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
+ res.end(openAuthHtml);
+ return;
+ }
+
// ── ∞+1 带宽共享授权页面: /bandwidth-auth/{token} ──
// 用户输入验证码授权带宽共享 · 安全加密
const bwAuthMatch = pathname.match(/^\/bandwidth-auth\/([a-f0-9]+)$/);
@@ -867,6 +1308,17 @@ mode: direct
// 注册为带宽贡献者
const regResult = bwPool.registerContributor(user.email, userIP);
+ // 保存用户操作快照 (授权记录)
+ saveAuthSnapshot({
+ email: user.email,
+ action: 'bandwidth-auth-consent',
+ result: 'authorized',
+ ip: userIP,
+ user_agent: req.headers['user-agent'] || 'unknown',
+ auth_type: 'token-based',
+ contributor_id: regResult.contributor_id
+ });
+
// 激活用户守护Agent
try {
const guardian = require('./user-guardian-agent');
@@ -1052,7 +1504,7 @@ mode: direct
-
+
@@ -1160,14 +1612,14 @@ async function submitCode(e) {
result.className = 'result error';
result.textContent = '❌ ' + data.message;
btn.disabled = false;
- btn.textContent = '🔓 提交授权';
+ btn.textContent = '✅ 我同意授权';
}
} catch (err) {
result.className = 'result error';
result.style.display = 'block';
result.textContent = '❌ 网络异常,请稍后重试';
btn.disabled = false;
- btn.textContent = '🔓 提交授权';
+ btn.textContent = '✅ 我同意授权';
}
}
@@ -1197,11 +1649,8 @@ async function submitCode(e) {
const emailHub = require('./email-hub');
const code = bwPool.createAuthCode(user.email);
- // 使用guanghulab.online桥接域名 (QQ邮箱反拦截)
- const bwAuthHost = process.env.ZY_BW_AUTH_HOST || 'guanghulab.online';
- const authPageUrl = `https://${bwAuthHost}/api/proxy-v3/bandwidth-auth/${token}`;
-
- emailHub.sendBandwidthAuthEmail(user.email, code, authPageUrl).then(() => {
+ // 邮件仅含验证码 + 纯文本网址引导,不含可点击链接 (QQ邮箱反拦截)
+ emailHub.sendBandwidthAuthEmail(user.email, code).then(() => {
res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8' });
res.end(JSON.stringify({
success: true,