feat: 处理非字符串的 ports 字段

This commit is contained in:
xream
2024-09-04 13:39:26 +08:00
parent 3b4c14e7d0
commit 72bc9b9456
3 changed files with 13 additions and 9 deletions

View File

@@ -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);
@@ -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(
@@ -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(