Skip to content

Commit 64c7f33

Browse files
committed
feat: URI 逻辑调整. AnyTLS URI/sing-box 支持传输层(mihomo, Shadowrocket 中自动过滤此类节点)
1 parent f8213a1 commit 64c7f33

6 files changed

Lines changed: 196 additions & 137 deletions

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.20.10",
3+
"version": "2.20.12",
44
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
55
"main": "src/main.js",
66
"scripts": {

backend/src/core/proxy-utils/parsers/index.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,8 @@ function URI_AnyTLS() {
753753
return /^anytls:\/\//.test(line);
754754
};
755755
const parse = (line) => {
756+
const parsed = URI_VLESS().parse(line.replace('anytls', 'vless'));
757+
// 偷个懒
756758
line = line.split(/anytls:\/\//)[1];
757759
// eslint-disable-next-line no-unused-vars
758760
let [__, password, server, port, addons = '', name] =
@@ -769,6 +771,8 @@ function URI_AnyTLS() {
769771
name = name ?? `AnyTLS ${server}:${port}`;
770772

771773
const proxy = {
774+
...parsed,
775+
uuid: undefined,
772776
type: 'anytls',
773777
name,
774778
server,
@@ -786,11 +790,14 @@ function URI_AnyTLS() {
786790
proxy['skip-cert-verify'] = /(TRUE)|1/i.test(value);
787791
} else if (['udp'].includes(key)) {
788792
proxy[key] = /(TRUE)|1/i.test(value);
789-
} else {
793+
} else if (!Object.keys(proxy).includes(key)) {
790794
proxy[key] = value;
791795
}
792796
}
793-
797+
if (['tcp'].includes(proxy.network) && !proxy['reality-opts']) {
798+
delete proxy.network;
799+
delete proxy.security;
800+
}
794801
return proxy;
795802
};
796803
return { name, test, parse };
@@ -940,7 +947,7 @@ function URI_Hysteria() {
940947
proxy['_obfs'] = value || '';
941948
} else if (['fast-open', 'peer'].includes(key)) {
942949
params[key] = value;
943-
} else {
950+
} else if (!Object.keys(proxy).includes(key)) {
944951
proxy[key] = value;
945952
}
946953
}
@@ -1007,7 +1014,7 @@ function URI_TUIC() {
10071014
} else if (key === 'congestion-control') {
10081015
proxy['congestion-controller'] = value;
10091016
delete proxy[key];
1010-
} else {
1017+
} else if (!Object.keys(proxy).includes(key)) {
10111018
proxy[key] = value;
10121019
}
10131020
}
@@ -1090,7 +1097,7 @@ function URI_WireGuard() {
10901097
proxy['private-key'] = value;
10911098
} else if (['udp'].includes(key)) {
10921099
proxy[key] = /(TRUE)|1/i.test(value);
1093-
} else if (!['flag'].includes(key)) {
1100+
} else if (![...Object.keys(proxy), 'flag'].includes(key)) {
10941101
proxy[key] = value;
10951102
}
10961103
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ export default function ClashMeta_Producer() {
5959
) {
6060
// https://wiki.metacubex.one/config/proxies/ss/#cipher
6161
return false;
62+
} else if (
63+
['anytls'].includes(proxy.type) &&
64+
proxy.network &&
65+
(!['tcp'].includes(proxy.network) ||
66+
(['tcp'].includes(proxy.network) &&
67+
proxy['reality-opts']))
68+
) {
69+
return false;
6270
}
6371
return true;
6472
})

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ export default function Shadowrocket_Producer() {
126126
delete proxy['shadow-tls-sni'];
127127
delete proxy['shadow-tls-version'];
128128
}
129+
} else if (
130+
['anytls'].includes(proxy.type) &&
131+
proxy.network &&
132+
(!['tcp'].includes(proxy.network) ||
133+
(['tcp'].includes(proxy.network) &&
134+
proxy['reality-opts']))
135+
) {
136+
return false;
129137
}
130138

131139
if (

backend/src/core/proxy-utils/producers/sing-box.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,7 @@ const anytlsParser = (proxy = {}) => {
736736
`${proxy['min-idle-session']}`,
737737
10,
738738
);
739+
networkParser(proxy, parsedProxy);
739740
detourParser(proxy, parsedProxy);
740741
tlsParser(proxy, parsedProxy);
741742
ipVersionParser(proxy, parsedProxy);

0 commit comments

Comments
 (0)