feat: 支持输出到 sing-box; 文件脚本支持 ` ; 脚本支持 ProxyUtils.yaml`

This commit is contained in:
xream
2024-01-13 10:28:07 +08:00
parent 5915416232
commit 3aacd26b79
11 changed files with 729 additions and 26 deletions

View File

@@ -1,3 +1,4 @@
import YAML from 'static-js-yaml';
import download from '@/utils/download';
import { isIPv4, isIPv6, isValidPortNumber } from '@/utils';
import PROXY_PROCESSORS, { ApplyProcessor } from './processors';
@@ -59,7 +60,6 @@ function parse(raw) {
$.error(`Failed to parse line: ${line}`);
}
}
return proxies;
}
@@ -193,6 +193,7 @@ export const ProxyUtils = {
isIPv4,
isIPv6,
isIP,
yaml: YAML,
};
function tryParse(parser, line) {
@@ -218,7 +219,7 @@ function lastParse(proxy) {
proxy.port = parseInt(proxy.port, 10);
}
if (proxy.server) {
proxy.server = proxy.server
proxy.server = `${proxy.server}`
.trim()
.replace(/^\[/, '')
.replace(/\]$/, '');