Skip to content

Commit 72bc9b9

Browse files
committed
feat: 处理非字符串的 ports 字段
1 parent 3b4c14e commit 72bc9b9

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

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.14.376",
3+
"version": "2.14.378",
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: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ function produce(proxies, targetPlatform, type, opts = {}) {
231231

232232
// 处理 端口跳跃
233233
if (proxy.ports) {
234+
proxy.ports = String(proxy.ports);
234235
if (!['ClashMeta'].includes(targetPlatform)) {
235236
proxy.ports = proxy.ports.replace(/\//g, ',');
236237
}
@@ -420,13 +421,13 @@ function lastParse(proxy) {
420421
proxy[`${proxy.network}-opts`].path = [transportPath];
421422
}
422423
}
423-
if (['hysteria', 'hysteria2'].includes(proxy.type)) {
424-
if (proxy.ports) {
425-
proxy.ports = proxy.ports.replace(/\//g, ',');
426-
} else {
427-
delete proxy.ports;
428-
}
424+
// if (['hysteria', 'hysteria2', 'tuic'].includes(proxy.type)) {
425+
if (proxy.ports) {
426+
proxy.ports = String(proxy.ports).replace(/\//g, ',');
427+
} else {
428+
delete proxy.ports;
429429
}
430+
// }
430431
if (
431432
['hysteria2'].includes(proxy.type) &&
432433
proxy.obfs &&

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ const ipVersions = {
1515
export default function Surge_Producer() {
1616
const produce = (proxy, type, opts = {}) => {
1717
proxy.name = proxy.name.replace(/=|,/g, '');
18+
if (proxy.ports) {
19+
proxy.ports = String(proxy.ports);
20+
}
1821
switch (proxy.type) {
1922
case 'ss':
2023
return shadowsocks(proxy);
@@ -676,7 +679,7 @@ function tuic(proxy) {
676679
);
677680

678681
if (isPresent(proxy, 'ports')) {
679-
result.append(`,port-hopping=${proxy.ports.replace(/,/g, ';')}`);
682+
result.append(`,port-hopping="${proxy.ports.replace(/,/g, ';')}"`);
680683
}
681684

682685
result.appendIfPresent(
@@ -945,7 +948,7 @@ function hysteria2(proxy) {
945948
result.appendIfPresent(`,password=${proxy.password}`, 'password');
946949

947950
if (isPresent(proxy, 'ports')) {
948-
result.append(`,port-hopping=${proxy.ports.replace(/,/g, ';')}`);
951+
result.append(`,port-hopping="${proxy.ports.replace(/,/g, ';')}"`);
949952
}
950953

951954
result.appendIfPresent(

0 commit comments

Comments
 (0)