feat: Surge 支持 TrustTunnel. 根据请求的 User-Agent 中的版本号自动开启, 或使用 includeUnsupportedProxy 参数或开启 包含官方/商店版不支持的协议 开关

This commit is contained in:
xream committed 2026-01-27 16:05:44 +08:00
1 parent a63bf54dc7
commit bffe230785
11 files changed
+107 -5

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.21.16",
"version": "2.21.17",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
"main": "src/main.js",
"scripts": {
+1
View File
@@ -465,6 +465,7 @@ function lastParse(proxy) {
'hysteria2',
'juicity',
'anytls',
'trust-tunnel',
'naive',
].includes(proxy.type)
) {
@@ -1264,6 +1264,7 @@ function Clash_All() {
}
if (
![
'trust-tunnel',
'naive',
'anytls',
'mieru',
@@ -1597,6 +1598,14 @@ function Surge_Anytls() {
const parse = (line) => getSurgeParser().parse(line);
return { name, test, parse };
}
function Surge_TrustTunnel() {
const name = 'Surge TrustTunnel Parser';
const test = (line) => {
return /^.*=\s*trust-tunnel/.test(line.split(',')[0]);
};
const parse = (line) => getSurgeParser().parse(line);
return { name, test, parse };
}
function Surge_SSH() {
const name = 'Surge SSH Parser';
const test = (line) => {
@@ -1791,6 +1800,7 @@ export default [
Clash_All(),
Surge_Direct(),
Surge_Anytls(),
Surge_TrustTunnel(),
Surge_SSH(),
Surge_SS(),
Surge_VMess(),
@@ -37,7 +37,7 @@ const grammars = String.raw`
}
}
start = (anytls/shadowsocks/vmess/trojan/https/http/snell/socks5/socks5_tls/tuic/tuic_v5/wireguard/hysteria2/ssh/direct) {
start = (anytls/shadowsocks/vmess/trojan/https/http/snell/socks5/socks5_tls/tuic/tuic_v5/wireguard/hysteria2/ssh/trust_tunnel/direct) {
return proxy;
}
@@ -122,6 +122,11 @@ anytls = tag equals "anytls" address (passwordk/reuse/ip_version/underlying_prox
proxy.type = "anytls";
proxy.tls = true;
}
trust_tunnel = tag equals "trust-tunnel" address (usernamek/passwordk/reuse/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/sni/fast_open/tfo/block_quic/others)* {
proxy.type = "trust-tunnel";
proxy.tls = true;
}
direct = tag equals "direct" (udp_relay/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/block_quic/others)* {
proxy.type = "direct";
}
@@ -35,7 +35,7 @@
}
}
start = (anytls/shadowsocks/vmess/trojan/https/http/snell/socks5/socks5_tls/tuic/tuic_v5/wireguard/hysteria2/ssh/direct) {
start = (anytls/shadowsocks/vmess/trojan/https/http/snell/socks5/socks5_tls/tuic/tuic_v5/wireguard/hysteria2/ssh/trust_tunnel/direct) {
return proxy;
}
@@ -120,6 +120,10 @@ anytls = tag equals "anytls" address (passwordk/reuse/ip_version/underlying_prox
proxy.type = "anytls";
proxy.tls = true;
}
trust_tunnel = tag equals "trust-tunnel" address (usernamek/passwordk/reuse/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/sni/fast_open/tfo/block_quic/others)* {
proxy.type = "trust-tunnel";
proxy.tls = true;
}
direct = tag equals "direct" (udp_relay/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/block_quic/others)* {
proxy.type = "direct";
}
@@ -174,6 +174,7 @@ export default function Clash_Producer() {
'hysteria2',
'juicity',
'anytls',
'trust-tunnel',
'naive',
].includes(proxy.type)
) {
@@ -16,7 +16,9 @@ export default function ClashMeta_Producer() {
if (opts['include-unsupported-proxy']) return true;
if (proxy.type === 'snell' && proxy.version >= 4) {
return false;
} else if (['juicity', 'naive'].includes(proxy.type)) {
} else if (
['trust-tunnel', 'juicity', 'naive'].includes(proxy.type)
) {
return false;
} else if (
['ss'].includes(proxy.type) &&
@@ -249,6 +251,7 @@ export default function ClashMeta_Producer() {
'hysteria2',
'juicity',
'anytls',
'trust-tunnel',
'naive',
].includes(proxy.type)
) {
@@ -9,7 +9,11 @@ export default function Shadowrocket_Producer() {
if (opts['include-unsupported-proxy']) return true;
if (proxy.type === 'snell' && proxy.version >= 4) {
return false;
} else if (['mieru', 'sudoku', 'naive'].includes(proxy.type)) {
} else if (
['trust-tunnel', 'mieru', 'sudoku', 'naive'].includes(
proxy.type,
)
) {
return false;
} else if (
proxy.encryption &&
@@ -219,6 +223,7 @@ export default function Shadowrocket_Producer() {
'hysteria2',
'juicity',
'anytls',
'trust-tunnel',
'naive',
].includes(proxy.type)
) {
@@ -300,6 +300,7 @@ export default function Stash_Producer() {
'hysteria2',
'juicity',
'anytls',
'trust-tunnel',
'naive',
].includes(proxy.type)
) {
@@ -67,6 +67,12 @@ export default function Surge_Producer() {
return anytls(proxy);
}
if (
opts['include-unsupported-proxy'] &&
proxy.type === 'trust-tunnel'
) {
return trust_tunnel(proxy);
}
throw new Error(
`Platform ${targetPlatform} does not support proxy type: ${proxy.type}`,
);
@@ -366,6 +372,71 @@ function anytls(proxy) {
return result.toString();
}
function trust_tunnel(proxy) {
const result = new Result(proxy);
result.append(`${proxy.name}=${proxy.type},${proxy.server},${proxy.port}`);
result.appendIfPresent(`,password="${proxy.password}"`, 'password');
const ip_version = ipVersions[proxy['ip-version']] || proxy['ip-version'];
result.appendIfPresent(`,ip-version=${ip_version}`, 'ip-version');
result.appendIfPresent(
`,no-error-alert=${proxy['no-error-alert']}`,
'no-error-alert',
);
// tls fingerprint
result.appendIfPresent(
`,server-cert-fingerprint-sha256=${proxy['tls-fingerprint']}`,
'tls-fingerprint',
);
// tls verification
result.appendIfPresent(`,sni=${proxy.sni}`, 'sni');
result.appendIfPresent(
`,skip-cert-verify=${proxy['skip-cert-verify']}`,
'skip-cert-verify',
);
// tfo
result.appendIfPresent(`,tfo=${proxy.tfo}`, 'tfo');
// udp
result.appendIfPresent(`,udp-relay=${proxy.udp}`, 'udp');
// test-url
result.appendIfPresent(`,test-url=${proxy['test-url']}`, 'test-url');
result.appendIfPresent(
`,test-timeout=${proxy['test-timeout']}`,
'test-timeout',
);
result.appendIfPresent(`,test-udp=${proxy['test-udp']}`, 'test-udp');
result.appendIfPresent(`,hybrid=${proxy['hybrid']}`, 'hybrid');
result.appendIfPresent(`,tos=${proxy['tos']}`, 'tos');
result.appendIfPresent(
`,allow-other-interface=${proxy['allow-other-interface']}`,
'allow-other-interface',
);
result.appendIfPresent(
`,interface=${proxy['interface-name']}`,
'interface-name',
);
result.appendIfPresent(`,interface=${proxy['interface']}`, 'interface');
// block-quic
result.appendIfPresent(`,block-quic=${proxy['block-quic']}`, 'block-quic');
// underlying-proxy
result.appendIfPresent(
`,underlying-proxy=${proxy['underlying-proxy']}`,
'underlying-proxy',
);
// reuse
result.appendIfPresent(`,reuse=${proxy['reuse']}`, 'reuse');
return result.toString();
}
function vmess(proxy, includeUnsupportedProxy) {
const result = new Result(proxy);
@@ -157,6 +157,7 @@ export default function URI_Producer() {
'hysteria2',
'juicity',
'anytls',
'trust-tunnel',
].includes(proxy.type)
) {
delete proxy.tls;