Skip to content

Commit dea8852

Browse files
committed
feat: Surge for macOS 设置节点字段 _mihomoExternaltrue 可强制指定使用 mihomo External Proxy Program 输出该节点
1 parent 1299764 commit dea8852

4 files changed

Lines changed: 27 additions & 1 deletion

File tree

backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sub-store",
3-
"version": "2.21.67",
3+
"version": "2.21.68",
44
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
55
"main": "src/main.js",
66
"scripts": {

backend/src/core/proxy-utils/producers/surgemac.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ const surge_Producer = Surge_Producer();
1111

1212
export default function SurgeMac_Producer() {
1313
const produce = (proxy, type, opts = {}) => {
14+
if (proxy._mihomoExternal) {
15+
return mihomo(proxy, type, opts);
16+
}
1417
switch (proxy.type) {
1518
case 'external':
1619
return external(proxy);

backend/src/test/proxy-producers/text.spec.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,28 @@ describe('Proxy text producers', function () {
219219
expect(output).to.include('udp-relay=true');
220220
});
221221

222+
it('forces SurgeMac nodes with _mihomoExternal to use Mihomo external mode', function () {
223+
const output = produceExternal(
224+
'SurgeMac',
225+
{
226+
type: 'tuic',
227+
name: 'Forced Mihomo',
228+
server: 'tuic.example.com',
229+
port: 443,
230+
uuid: UUID,
231+
password: 'secret',
232+
sni: 'sni.example.com',
233+
_mihomoExternal: true,
234+
},
235+
{ localPort: 17777 },
236+
);
237+
238+
expect(output).to.include(
239+
'Forced Mihomo=external,exec="/usr/local/bin/mihomo",local-port=17777',
240+
);
241+
expect(output).to.not.include('Forced Mihomo=tuic-v5');
242+
});
243+
222244
it('produces URI VLESS reality websocket links', function () {
223245
const output = produceExternal('URI', {
224246
type: 'vless',

scripts/demo.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ function operator(proxies = [], targetPlatform, context) {
3535
// 21. 2.21.59 开始, `sing-box` 支持使用 `ech-opts` 结构设置 `tls` 的 `ech`. 参考 https://github.com/sub-store-org/Sub-Store/pull/563/changes 基本沿用 mihomo 风格, mihomo 部分字段自动转换
3636
// 22. `sing-box` 支持使用完整的 `_curve_preferences` 结构设置 `tls` 的 `curve_preferences`
3737
// 23. `interface-name` 指定流量出站接口 只给 Surge 用的话, `interface` 也可以
38+
// 24. Surge for macOS 可手动指定链接参数 target=SurgeMac 或在 同步配置 中指定 SurgeMac 来启用 mihomo 支援 Surge 本身不支持的协议. 设置节点字段 `_mihomoExternal` 为 `true` 可强制指定使用 mihomo External Proxy Program 输出该节点
3839

3940
// require 为 Node.js 的 require, 在 Node.js 运行环境下 可以用来引入模块
4041
// 例如在 Node.js 环境下, 将文件内容写入 /tmp/1.txt 文件

0 commit comments

Comments
 (0)