Skip to content

Commit

Permalink
feat: Stash/clash.meta(mihomo) 支持 interface-name 字段
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Mar 4, 2024
1 parent a4384f4 commit 739100c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 12 deletions.
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.14.235",
"version": "2.14.236",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
"main": "src/main.js",
"scripts": {
Expand Down
4 changes: 4 additions & 0 deletions backend/src/core/proxy-utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@ function safeMatch(parser, line) {
}

function lastParse(proxy) {
if (proxy.interface) {
proxy['interface-name'] = proxy.interface;
delete proxy.interface;
}
if (isValidPortNumber(proxy.port)) {
proxy.port = parseInt(proxy.port, 10);
}
Expand Down
55 changes: 44 additions & 11 deletions backend/src/core/proxy-utils/producers/surge.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ function shadowsocks(proxy) {
`,allow-other-interface=${proxy['allow-other-interface']}`,
'allow-other-interface',
);
result.appendIfPresent(`,interface=${proxy['interface']}`, 'interface');
result.appendIfPresent(
`,interface=${proxy['interface-name']}`,
'interface-name',
);

// shadow-tls
if (isPresent(proxy, 'shadow-tls-password')) {
Expand Down Expand Up @@ -229,7 +232,10 @@ function trojan(proxy) {
`,allow-other-interface=${proxy['allow-other-interface']}`,
'allow-other-interface',
);
result.appendIfPresent(`,interface=${proxy['interface']}`, 'interface');
result.appendIfPresent(
`,interface=${proxy['interface-name']}`,
'interface-name',
);

// shadow-tls
if (isPresent(proxy, 'shadow-tls-password')) {
Expand Down Expand Up @@ -315,7 +321,10 @@ function vmess(proxy) {
`,allow-other-interface=${proxy['allow-other-interface']}`,
'allow-other-interface',
);
result.appendIfPresent(`,interface=${proxy['interface']}`, 'interface');
result.appendIfPresent(
`,interface=${proxy['interface-name']}`,
'interface-name',
);

// shadow-tls
if (isPresent(proxy, 'shadow-tls-password')) {
Expand Down Expand Up @@ -385,7 +394,10 @@ function ssh(proxy) {
`,allow-other-interface=${proxy['allow-other-interface']}`,
'allow-other-interface',
);
result.appendIfPresent(`,interface=${proxy['interface']}`, 'interface');
result.appendIfPresent(
`,interface=${proxy['interface-name']}`,
'interface-name',
);

// block-quic
result.appendIfPresent(`,block-quic=${proxy['block-quic']}`, 'block-quic');
Expand Down Expand Up @@ -445,7 +457,10 @@ function http(proxy) {
`,allow-other-interface=${proxy['allow-other-interface']}`,
'allow-other-interface',
);
result.appendIfPresent(`,interface=${proxy['interface']}`, 'interface');
result.appendIfPresent(
`,interface=${proxy['interface-name']}`,
'interface-name',
);

// shadow-tls
if (isPresent(proxy, 'shadow-tls-password')) {
Expand Down Expand Up @@ -522,7 +537,10 @@ function socks5(proxy) {
`,allow-other-interface=${proxy['allow-other-interface']}`,
'allow-other-interface',
);
result.appendIfPresent(`,interface=${proxy['interface']}`, 'interface');
result.appendIfPresent(
`,interface=${proxy['interface-name']}`,
'interface-name',
);

// shadow-tls
if (isPresent(proxy, 'shadow-tls-password')) {
Expand Down Expand Up @@ -597,7 +615,10 @@ function snell(proxy) {
`,allow-other-interface=${proxy['allow-other-interface']}`,
'allow-other-interface',
);
result.appendIfPresent(`,interface=${proxy['interface']}`, 'interface');
result.appendIfPresent(
`,interface=${proxy['interface-name']}`,
'interface-name',
);

// shadow-tls
if (isPresent(proxy, 'shadow-tls-password')) {
Expand Down Expand Up @@ -687,7 +708,10 @@ function tuic(proxy) {
`,allow-other-interface=${proxy['allow-other-interface']}`,
'allow-other-interface',
);
result.appendIfPresent(`,interface=${proxy['interface']}`, 'interface');
result.appendIfPresent(
`,interface=${proxy['interface-name']}`,
'interface-name',
);

// shadow-tls
if (isPresent(proxy, 'shadow-tls-password')) {
Expand Down Expand Up @@ -761,7 +785,10 @@ ${proxy.name}=wireguard`);
`,allow-other-interface=${proxy['allow-other-interface']}`,
'allow-other-interface',
);
result.appendIfPresent(`,interface=${proxy['interface']}`, 'interface');
result.appendIfPresent(
`,interface=${proxy['interface-name']}`,
'interface-name',
);

// shadow-tls
if (isPresent(proxy, 'shadow-tls-password')) {
Expand Down Expand Up @@ -860,7 +887,10 @@ function wireguard_surge(proxy) {
`,allow-other-interface=${proxy['allow-other-interface']}`,
'allow-other-interface',
);
result.appendIfPresent(`,interface=${proxy['interface']}`, 'interface');
result.appendIfPresent(
`,interface=${proxy['interface-name']}`,
'interface-name',
);

// shadow-tls
if (isPresent(proxy, 'shadow-tls-password')) {
Expand Down Expand Up @@ -936,7 +966,10 @@ function hysteria2(proxy) {
`,allow-other-interface=${proxy['allow-other-interface']}`,
'allow-other-interface',
);
result.appendIfPresent(`,interface=${proxy['interface']}`, 'interface');
result.appendIfPresent(
`,interface=${proxy['interface-name']}`,
'interface-name',
);

// shadow-tls
if (isPresent(proxy, 'shadow-tls-password')) {
Expand Down

0 comments on commit 739100c

Please sign in to comment.