Skip to content

Commit

Permalink
feat: 处理非字符串的 ports 字段
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Sep 4, 2024
1 parent 3b4c14e commit 72bc9b9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.14.376",
"version": "2.14.378",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
"main": "src/main.js",
"scripts": {
Expand Down
13 changes: 7 additions & 6 deletions backend/src/core/proxy-utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ function produce(proxies, targetPlatform, type, opts = {}) {

// 处理 端口跳跃
if (proxy.ports) {
proxy.ports = String(proxy.ports);
if (!['ClashMeta'].includes(targetPlatform)) {
proxy.ports = proxy.ports.replace(/\//g, ',');
}
Expand Down Expand Up @@ -420,13 +421,13 @@ function lastParse(proxy) {
proxy[`${proxy.network}-opts`].path = [transportPath];
}
}
if (['hysteria', 'hysteria2'].includes(proxy.type)) {
if (proxy.ports) {
proxy.ports = proxy.ports.replace(/\//g, ',');
} else {
delete proxy.ports;
}
// if (['hysteria', 'hysteria2', 'tuic'].includes(proxy.type)) {
if (proxy.ports) {
proxy.ports = String(proxy.ports).replace(/\//g, ',');
} else {
delete proxy.ports;
}
// }
if (
['hysteria2'].includes(proxy.type) &&
proxy.obfs &&
Expand Down
7 changes: 5 additions & 2 deletions backend/src/core/proxy-utils/producers/surge.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ const ipVersions = {
export default function Surge_Producer() {
const produce = (proxy, type, opts = {}) => {
proxy.name = proxy.name.replace(/=|,/g, '');
if (proxy.ports) {
proxy.ports = String(proxy.ports);
}
switch (proxy.type) {
case 'ss':
return shadowsocks(proxy);
Expand Down Expand Up @@ -676,7 +679,7 @@ function tuic(proxy) {
);

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

result.appendIfPresent(
Expand Down Expand Up @@ -945,7 +948,7 @@ function hysteria2(proxy) {
result.appendIfPresent(`,password=${proxy.password}`, 'password');

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

result.appendIfPresent(
Expand Down

0 comments on commit 72bc9b9

Please sign in to comment.