diff --git a/backend/package.json b/backend/package.json index 95dbc16..60c99e8 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.14.242", + "version": "2.14.243", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.", "main": "src/main.js", "scripts": { diff --git a/backend/src/core/proxy-utils/parsers/index.js b/backend/src/core/proxy-utils/parsers/index.js index bd9cd26..ab1a768 100644 --- a/backend/src/core/proxy-utils/parsers/index.js +++ b/backend/src/core/proxy-utils/parsers/index.js @@ -722,6 +722,7 @@ function Clash_All() { 'hysteria', 'hysteria2', 'wireguard', + 'ssh', ].includes(proxy.type) ) { throw new Error( diff --git a/backend/src/restful/subscriptions.js b/backend/src/restful/subscriptions.js index 17d4f53..a798e7b 100644 --- a/backend/src/restful/subscriptions.js +++ b/backend/src/restful/subscriptions.js @@ -43,7 +43,10 @@ async function getFlowInfo(req, res) { ); return; } - if (sub.source === 'local') { + if ( + sub.source === 'local' && + !['localFirst', 'remoteFirst'].includes(sub.mergeSources) + ) { failed( res, new RequestInvalidError( @@ -55,7 +58,42 @@ async function getFlowInfo(req, res) { return; } try { - const flowHeaders = await getFlowHeaders(sub.url); + let url = `${sub.url}` + .split(/[\r\n]+/) + .map((i) => i.trim()) + .filter((i) => i.length)?.[0]; + + let $arguments = {}; + const rawArgs = url.split('#'); + url = url.split('#')[0]; + if (rawArgs.length > 1) { + try { + // 支持 `#${encodeURIComponent(JSON.stringify({arg1: "1"}))}` + $arguments = JSON.parse(decodeURIComponent(rawArgs[1])); + } catch (e) { + for (const pair of rawArgs[1].split('&')) { + const key = pair.split('=')[0]; + const value = pair.split('=')[1]; + // 部分兼容之前的逻辑 const value = pair.split('=')[1] || true; + $arguments[key] = + value == null || value === '' + ? true + : decodeURIComponent(value); + } + } + } + if ($arguments.noFlow) { + failed( + res, + new RequestInvalidError( + 'NO_FLOW_INFO', + 'N/A', + `Subscription ${name}: noFlow`, + ), + ); + return; + } + const flowHeaders = await getFlowHeaders(url); if (!flowHeaders) { failed( res,