diff --git a/backend/package.json b/backend/package.json index 9543c0ccc..666be9146 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.14.399", + "version": "2.14.400", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.", "main": "src/main.js", "scripts": { diff --git a/backend/src/core/proxy-utils/producers/surgemac.js b/backend/src/core/proxy-utils/producers/surgemac.js index b52b5a4f3..c1baef63e 100644 --- a/backend/src/core/proxy-utils/producers/surgemac.js +++ b/backend/src/core/proxy-utils/producers/surgemac.js @@ -20,10 +20,12 @@ export default function SurgeMac_Producer() { try { return surge_Producer.produce(proxy, type, opts); } catch (e) { - $.log( - `${proxy.name} is not supported on ${targetPlatform}, try to use Mihomo(SurgeMac - External Proxy Program) instead`, - ); - return mihomo(proxy, type, opts); + if (opts.useMihomoExternal) { + $.log( + `${proxy.name} is not supported on ${targetPlatform}, try to use Mihomo(SurgeMac - External Proxy Program) instead`, + ); + return mihomo(proxy, type, opts); + } } } } diff --git a/backend/src/products/cron-sync-artifacts.js b/backend/src/products/cron-sync-artifacts.js index a3fadf947..41c8f8b61 100644 --- a/backend/src/products/cron-sync-artifacts.js +++ b/backend/src/products/cron-sync-artifacts.js @@ -130,6 +130,15 @@ async function doSync() { try { if (artifact.sync && artifact.source) { $.info(`正在同步云配置:${artifact.name}...`); + + const useMihomoExternal = + artifact.platform === 'SurgeMac'; + + if (useMihomoExternal) { + $.info( + `手动指定了 target 为 SurgeMac, 将使用 Mihomo External`, + ); + } const output = await produceArtifact({ type: artifact.type, name: artifact.source, @@ -137,6 +146,7 @@ async function doSync() { produceOpts: { 'include-unsupported-proxy': artifact.includeUnsupportedProxy, + useMihomoExternal, }, }); diff --git a/backend/src/restful/download.js b/backend/src/restful/download.js index bb24f9764..655d2e758 100644 --- a/backend/src/restful/download.js +++ b/backend/src/restful/download.js @@ -52,6 +52,8 @@ async function downloadSubscription(req, res) { name = decodeURIComponent(name); nezhaIndex = decodeURIComponent(nezhaIndex); + const useMihomoExternal = req.query.target === 'SurgeMac'; + const platform = req.query.target || getPlatformFromHeaders(req.headers) || 'JSON'; @@ -122,6 +124,10 @@ async function downloadSubscription(req, res) { $.info(`包含不支持的节点: ${includeUnsupportedProxy}`); } + if (useMihomoExternal) { + $.info(`手动指定了 target 为 SurgeMac, 将使用 Mihomo External`); + } + const allSubs = $.read(SUBS_KEY); const sub = findByName(allSubs, name); if (sub) { @@ -138,6 +144,7 @@ async function downloadSubscription(req, res) { produceType, produceOpts: { 'include-unsupported-proxy': includeUnsupportedProxy, + useMihomoExternal, }, $options, proxy, @@ -253,6 +260,8 @@ async function downloadCollection(req, res) { name = decodeURIComponent(name); nezhaIndex = decodeURIComponent(nezhaIndex); + const useMihomoExternal = req.query.target === 'SurgeMac'; + const platform = req.query.target || getPlatformFromHeaders(req.headers) || 'JSON'; @@ -310,6 +319,9 @@ async function downloadCollection(req, res) { includeUnsupportedProxy = decodeURIComponent(includeUnsupportedProxy); $.info(`包含不支持的节点: ${includeUnsupportedProxy}`); } + if (useMihomoExternal) { + $.info(`手动指定了 target 为 SurgeMac, 将使用 Mihomo External`); + } if (collection) { try { @@ -321,6 +333,7 @@ async function downloadCollection(req, res) { produceType, produceOpts: { 'include-unsupported-proxy': includeUnsupportedProxy, + useMihomoExternal, }, $options, proxy, diff --git a/backend/src/restful/sync.js b/backend/src/restful/sync.js index 67633713b..b28057aa7 100644 --- a/backend/src/restful/sync.js +++ b/backend/src/restful/sync.js @@ -559,6 +559,16 @@ async function syncArtifacts() { try { if (artifact.sync && artifact.source) { $.info(`正在同步云配置:${artifact.name}...`); + + const useMihomoExternal = + artifact.platform === 'SurgeMac'; + + if (useMihomoExternal) { + $.info( + `手动指定了 target 为 SurgeMac, 将使用 Mihomo External`, + ); + } + const output = await produceArtifact({ type: artifact.type, name: artifact.source, @@ -566,6 +576,7 @@ async function syncArtifacts() { produceOpts: { 'include-unsupported-proxy': artifact.includeUnsupportedProxy, + useMihomoExternal, }, }); @@ -681,12 +692,18 @@ async function syncArtifact(req, res) { } try { + const useMihomoExternal = artifact.platform === 'SurgeMac'; + + if (useMihomoExternal) { + $.info(`手动指定了 target 为 SurgeMac, 将使用 Mihomo External`); + } const output = await produceArtifact({ type: artifact.type, name: artifact.source, platform: artifact.platform, produceOpts: { 'include-unsupported-proxy': artifact.includeUnsupportedProxy, + useMihomoExternal, }, });