diff --git a/backend/package.json b/backend/package.json index 2399c89..0bc242d 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.14.90", + "version": "2.14.91", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.", "main": "src/main.js", "scripts": { diff --git a/backend/src/restful/download.js b/backend/src/restful/download.js index 0bdc2e3..bf9e6d7 100644 --- a/backend/src/restful/download.js +++ b/backend/src/restful/download.js @@ -20,6 +20,16 @@ async function downloadSubscription(req, res) { req.query.target || getPlatformFromHeaders(req.headers) || 'JSON'; $.info(`正在下载订阅:${name}`); + const { url, ua, content } = req.query; + if (url) { + $.info(`指定 url: ${url}`); + } + if (ua) { + $.info(`指定 ua: ${ua}`); + } + if (content) { + $.info(`指定 content: ${content}`); + } const allSubs = $.read(SUBS_KEY); const sub = findByName(allSubs, name); @@ -29,12 +39,15 @@ async function downloadSubscription(req, res) { type: 'subscription', name, platform, + url, + ua, + content, }); - if (sub.source !== 'local') { + if (sub.source !== 'local' || url) { try { // forward flow headers - const flowInfo = await getFlowHeaders(sub.url); + const flowInfo = await getFlowHeaders(url || sub.url); if (flowInfo) { res.set('subscription-userinfo', flowInfo); } diff --git a/backend/src/restful/sync.js b/backend/src/restful/sync.js index 51a0932..fbff455 100644 --- a/backend/src/restful/sync.js +++ b/backend/src/restful/sync.js @@ -22,14 +22,18 @@ export default function register($app) { $app.get('/api/sync/artifact/:name', syncArtifact); } -async function produceArtifact({ type, name, platform }) { +async function produceArtifact({ type, name, platform, url, ua, content }) { platform = platform || 'JSON'; if (type === 'subscription') { const allSubs = $.read(SUBS_KEY); const sub = findByName(allSubs, name); let raw; - if (sub.source === 'local') { + if (url) { + raw = await download(url, ua); + } else if (content) { + raw = content; + } else if (sub.source === 'local') { raw = sub.content; } else { raw = await download(sub.url, sub.ua);