feat: 统一 Trojan/VMess/VLESS network 逻辑

This commit is contained in:
xream committed 2026-01-02 15:21:15 +08:00
1 parent 182e712e67
commit 6087d8cc4a
5 files changed
+16 -10

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.20.66",
"version": "2.20.68",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
"main": "src/main.js",
"scripts": {
+4 -6
View File
@@ -442,22 +442,20 @@ function lastParse(proxy) {
// network¶
// 传输层,支持 ws/grpc,不配置或配置其他值则为 tcp
if (proxy.type === 'trojan') {
if (proxy.network === 'tcp') {
delete proxy.network;
}
proxy.network = proxy.network || 'tcp';
}
// network¶
// 传输层,支持 ws/http/h2/grpc,不配置或配置其他值则为 tcp
if (['vmess'].includes(proxy.type)) {
proxy.network = proxy.network || 'tcp';
proxy.cipher = proxy.cipher || 'none';
proxy.alterId = proxy.alterId || 0;
}
// network¶
// 传输层,支持 ws/http/h2/grpc,不配置或配置其他值则为 tcp
if (['vless'].includes(proxy.type)) {
if (!proxy.network) {
proxy.network = 'tcp';
}
proxy.network = proxy.network || 'tcp';
}
if (
[
+4 -3
View File
@@ -242,7 +242,7 @@ function trojan(proxy) {
`,obfs-host=${proxy['ws-opts']?.headers?.Host}`,
'ws-opts.headers.Host',
);
} else {
} else if (!['tcp'].includes(proxy.network)) {
throw new Error(`network ${proxy.network} is unsupported`);
}
}
@@ -326,7 +326,7 @@ function vmess(proxy) {
else append(`,obfs=ws`);
} else if (proxy.network === 'http') {
append(`,obfs=http`);
} else {
} else if (!['tcp'].includes(proxy.network)) {
throw new Error(`network ${proxy.network} is unsupported`);
}
let transportPath = proxy[`${proxy.network}-opts`]?.path;
@@ -401,7 +401,8 @@ function vmess(proxy) {
return result.toString();
}
function vless(proxy) {
if (proxy.encryption && proxy.encryption !== 'none') throw new Error(`VLESS encryption is not supported`);
if (proxy.encryption && proxy.encryption !== 'none')
throw new Error(`VLESS encryption is not supported`);
const result = new Result(proxy);
const append = result.append.bind(result);
const appendIfPresent = result.appendIfPresent.bind(result);
@@ -219,6 +219,8 @@ function handleTransport(result, proxy) {
}
}
}
} else if (['tcp'].includes(proxy.network) && proxy['reality-opts']) {
throw new Error(`reality is unsupported`);
} else if (!['tcp'].includes(proxy.network)) {
throw new Error(`network ${proxy.network} is unsupported`);
}
@@ -1226,6 +1226,11 @@ function handleTransport(result, proxy, includeUnsupportedProxy) {
$.info(
`Include Unsupported Proxy: network ${proxy.network} -> tcp`,
);
} else if (
['tcp'].includes(proxy.network) &&
proxy['reality-opts']
) {
throw new Error(`reality is unsupported`);
} else if (!['tcp'].includes(proxy.network)) {
throw new Error(`network ${proxy.network} is unsupported`);
}