From dea88520fe8a4a2dc34c742b5857786040d49140 Mon Sep 17 00:00:00 2001 From: xream Date: Tue, 31 Mar 2026 15:56:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20Surge=20for=20macOS=20=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E8=8A=82=E7=82=B9=E5=AD=97=E6=AE=B5=20`=5FmihomoExter?= =?UTF-8?q?nal`=20=E4=B8=BA=20`true`=20=E5=8F=AF=E5=BC=BA=E5=88=B6?= =?UTF-8?q?=E6=8C=87=E5=AE=9A=E4=BD=BF=E7=94=A8=20mihomo=20External=20Prox?= =?UTF-8?q?y=20Program=20=E8=BE=93=E5=87=BA=E8=AF=A5=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package.json | 2 +- .../core/proxy-utils/producers/surgemac.js | 3 +++ backend/src/test/proxy-producers/text.spec.js | 22 +++++++++++++++++++ scripts/demo.js | 1 + 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/backend/package.json b/backend/package.json index 46aa90c2..2c25f309 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.21.67", + "version": "2.21.68", "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 1c8a013a..ffe513eb 100644 --- a/backend/src/core/proxy-utils/producers/surgemac.js +++ b/backend/src/core/proxy-utils/producers/surgemac.js @@ -11,6 +11,9 @@ const surge_Producer = Surge_Producer(); export default function SurgeMac_Producer() { const produce = (proxy, type, opts = {}) => { + if (proxy._mihomoExternal) { + return mihomo(proxy, type, opts); + } switch (proxy.type) { case 'external': return external(proxy); diff --git a/backend/src/test/proxy-producers/text.spec.js b/backend/src/test/proxy-producers/text.spec.js index 526a928a..6f51052e 100644 --- a/backend/src/test/proxy-producers/text.spec.js +++ b/backend/src/test/proxy-producers/text.spec.js @@ -219,6 +219,28 @@ describe('Proxy text producers', function () { expect(output).to.include('udp-relay=true'); }); + it('forces SurgeMac nodes with _mihomoExternal to use Mihomo external mode', function () { + const output = produceExternal( + 'SurgeMac', + { + type: 'tuic', + name: 'Forced Mihomo', + server: 'tuic.example.com', + port: 443, + uuid: UUID, + password: 'secret', + sni: 'sni.example.com', + _mihomoExternal: true, + }, + { localPort: 17777 }, + ); + + expect(output).to.include( + 'Forced Mihomo=external,exec="/usr/local/bin/mihomo",local-port=17777', + ); + expect(output).to.not.include('Forced Mihomo=tuic-v5'); + }); + it('produces URI VLESS reality websocket links', function () { const output = produceExternal('URI', { type: 'vless', diff --git a/scripts/demo.js b/scripts/demo.js index 82dc5769..3d8d4f0c 100644 --- a/scripts/demo.js +++ b/scripts/demo.js @@ -35,6 +35,7 @@ function operator(proxies = [], targetPlatform, context) { // 21. 2.21.59 开始, `sing-box` 支持使用 `ech-opts` 结构设置 `tls` 的 `ech`. 参考 https://github.com/sub-store-org/Sub-Store/pull/563/changes 基本沿用 mihomo 风格, mihomo 部分字段自动转换 // 22. `sing-box` 支持使用完整的 `_curve_preferences` 结构设置 `tls` 的 `curve_preferences` // 23. `interface-name` 指定流量出站接口 只给 Surge 用的话, `interface` 也可以 + // 24. Surge for macOS 可手动指定链接参数 target=SurgeMac 或在 同步配置 中指定 SurgeMac 来启用 mihomo 支援 Surge 本身不支持的协议. 设置节点字段 `_mihomoExternal` 为 `true` 可强制指定使用 mihomo External Proxy Program 输出该节点 // require 为 Node.js 的 require, 在 Node.js 运行环境下 可以用来引入模块 // 例如在 Node.js 环境下, 将文件内容写入 /tmp/1.txt 文件