diff --git a/server.js b/server.js index 7dd4598..5e919dd 100644 --- a/server.js +++ b/server.js @@ -567,39 +567,6 @@ app.post('/api/jms/check-line', requireAuth, jmsCheckLimiter, async (req, res) = } }); -// 代为请求JMS订阅地址,解析 Subscription-Userinfo 响应头拿到流量信息—— -// 浏览器直接fetch会被CORS挡住,服务器端发请求没有这个限制 -app.post('/api/jms/fetch-traffic', requireAuth, async (req, res) => { - const url = ((req.body && req.body.subscriptionUrl) || '').trim(); - if (!url) return res.status(400).json({ error: '请先填写标准订阅地址' }); - let parsed; - try { - parsed = new URL(url); - if (!/^https?:$/.test(parsed.protocol)) throw new Error('invalid protocol'); - } catch (e) { - return res.status(400).json({ error: '订阅地址格式不对' }); - } - try { - const response = await fetch(url, { headers: { 'User-Agent': 'Mozilla/5.0' } }); - const header = response.headers.get('subscription-userinfo'); - if (!header) return res.json({ ok: false, error: '这个订阅地址没有返回流量信息(Subscription-Userinfo),可能服务商不支持或者地址不对' }); - const info = {}; - header.split(';').forEach(part => { - const [k, v] = part.trim().split('='); - if (k && v !== undefined) info[k.trim()] = Number(v.trim()); - }); - res.json({ - ok: true, - upload: info.upload || 0, - download: info.download || 0, - total: info.total || 0, - expire: info.expire || null, - }); - } catch (e) { - res.status(400).json({ error: '获取订阅信息失败:' + e.message }); - } -}); - const aiLimiter = rateLimit({ windowMs: 10 * 60 * 1000,