Skip to content

Commit 6087d8c

Browse files
committed
feat: 统一 Trojan/VMess/VLESS network 逻辑
1 parent 182e712 commit 6087d8c

5 files changed

Lines changed: 16 additions & 10 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.66",
3+
"version": "2.20.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/index.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -442,22 +442,20 @@ function lastParse(proxy) {
442442
// network¶
443443
// 传输层,支持 ws/grpc,不配置或配置其他值则为 tcp
444444
if (proxy.type === 'trojan') {
445-
if (proxy.network === 'tcp') {
446-
delete proxy.network;
447-
}
445+
proxy.network = proxy.network || 'tcp';
448446
}
449447
// network¶
450448
// 传输层,支持 ws/http/h2/grpc,不配置或配置其他值则为 tcp
451449
if (['vmess'].includes(proxy.type)) {
450+
proxy.network = proxy.network || 'tcp';
451+
452452
proxy.cipher = proxy.cipher || 'none';
453453
proxy.alterId = proxy.alterId || 0;
454454
}
455455
// network¶
456456
// 传输层,支持 ws/http/h2/grpc,不配置或配置其他值则为 tcp
457457
if (['vless'].includes(proxy.type)) {
458-
if (!proxy.network) {
459-
proxy.network = 'tcp';
460-
}
458+
proxy.network = proxy.network || 'tcp';
461459
}
462460
if (
463461
[

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ function trojan(proxy) {
242242
`,obfs-host=${proxy['ws-opts']?.headers?.Host}`,
243243
'ws-opts.headers.Host',
244244
);
245-
} else {
245+
} else if (!['tcp'].includes(proxy.network)) {
246246
throw new Error(`network ${proxy.network} is unsupported`);
247247
}
248248
}
@@ -326,7 +326,7 @@ function vmess(proxy) {
326326
else append(`,obfs=ws`);
327327
} else if (proxy.network === 'http') {
328328
append(`,obfs=http`);
329-
} else {
329+
} else if (!['tcp'].includes(proxy.network)) {
330330
throw new Error(`network ${proxy.network} is unsupported`);
331331
}
332332
let transportPath = proxy[`${proxy.network}-opts`]?.path;
@@ -401,7 +401,8 @@ function vmess(proxy) {
401401
return result.toString();
402402
}
403403
function vless(proxy) {
404-
if (proxy.encryption && proxy.encryption !== 'none') throw new Error(`VLESS encryption is not supported`);
404+
if (proxy.encryption && proxy.encryption !== 'none')
405+
throw new Error(`VLESS encryption is not supported`);
405406
const result = new Result(proxy);
406407
const append = result.append.bind(result);
407408
const appendIfPresent = result.appendIfPresent.bind(result);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ function handleTransport(result, proxy) {
219219
}
220220
}
221221
}
222+
} else if (['tcp'].includes(proxy.network) && proxy['reality-opts']) {
223+
throw new Error(`reality is unsupported`);
222224
} else if (!['tcp'].includes(proxy.network)) {
223225
throw new Error(`network ${proxy.network} is unsupported`);
224226
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,11 @@ function handleTransport(result, proxy, includeUnsupportedProxy) {
12261226
$.info(
12271227
`Include Unsupported Proxy: network ${proxy.network} -> tcp`,
12281228
);
1229+
} else if (
1230+
['tcp'].includes(proxy.network) &&
1231+
proxy['reality-opts']
1232+
) {
1233+
throw new Error(`reality is unsupported`);
12291234
} else if (!['tcp'].includes(proxy.network)) {
12301235
throw new Error(`network ${proxy.network} is unsupported`);
12311236
}

0 commit comments

Comments
 (0)