diff --git a/README.md b/README.md index 247075d..f66763a 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Core functionalities: - [x] Clash Proxy JSON(single line) - [x] QX (SS, SSR, VMess, Trojan, HTTP, SOCKS5, VLESS) - [x] Loon (SS, SSR, VMess, Trojan, HTTP, SOCKS5, SOCKS5-TLS, WireGuard, VLESS, Hysteria 2) -- [x] Surge (SS, VMess, Trojan, HTTP, SOCKS5, SOCKS5-TLS, TUIC, Snell, Hysteria 2, SSH(Password authentication only), External Proxy Program(only for macOS), WireGuard(Surge to Surge)) +- [x] Surge (Direct, SS, VMess, Trojan, HTTP, SOCKS5, SOCKS5-TLS, TUIC, Snell, Hysteria 2, SSH(Password authentication only), External Proxy Program(only for macOS), WireGuard(Surge to Surge)) - [x] Surfboard (SS, VMess, Trojan, HTTP, SOCKS5, SOCKS5-TLS, WireGuard(Surfboard to Surfboard)) - [x] Clash.Meta (SS, SSR, VMess, Trojan, HTTP, SOCKS5, Snell, VLESS, WireGuard, Hysteria, Hysteria 2, TUIC) - [x] Stash (SS, SSR, VMess, Trojan, HTTP, SOCKS5, Snell, VLESS, WireGuard, Hysteria, TUIC, Juicity, SSH) diff --git a/backend/package.json b/backend/package.json index d2837d8..d2d1105 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.14.439", + "version": "2.14.440", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.", "main": "src/main.js", "scripts": { diff --git a/backend/src/core/proxy-utils/parsers/index.js b/backend/src/core/proxy-utils/parsers/index.js index 85efe8d..543049a 100644 --- a/backend/src/core/proxy-utils/parsers/index.js +++ b/backend/src/core/proxy-utils/parsers/index.js @@ -1192,6 +1192,14 @@ function Loon_WireGuard() { return { name, test, parse }; } +function Surge_Direct() { + const name = 'Surge Direct Parser'; + const test = (line) => { + return /^.*=\s*direct/.test(line.split(',')[0]); + }; + const parse = (line) => getSurgeParser().parse(line); + return { name, test, parse }; +} function Surge_SSH() { const name = 'Surge SSH Parser'; const test = (line) => { @@ -1381,6 +1389,7 @@ export default [ URI_Hysteria2(), URI_Trojan(), Clash_All(), + Surge_Direct(), Surge_SSH(), Surge_SS(), Surge_VMess(), diff --git a/backend/src/core/proxy-utils/parsers/peggy/surge.js b/backend/src/core/proxy-utils/parsers/peggy/surge.js index 8d198e9..20f5c66 100644 --- a/backend/src/core/proxy-utils/parsers/peggy/surge.js +++ b/backend/src/core/proxy-utils/parsers/peggy/surge.js @@ -37,7 +37,7 @@ const grammars = String.raw` } } -start = (shadowsocks/vmess/trojan/https/http/snell/socks5/socks5_tls/tuic/tuic_v5/wireguard/hysteria2/ssh) { +start = (shadowsocks/vmess/trojan/https/http/snell/socks5/socks5_tls/tuic/tuic_v5/wireguard/hysteria2/ssh/direct) { return proxy; } @@ -117,6 +117,9 @@ socks5_tls = tag equals "socks5-tls" address (username password)? (usernamek pas proxy.tls = true; handleShadowTLS(); } +direct = tag equals "direct" (ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/block_quic/others)* { + proxy.type = "direct"; +} address = comma server:server comma port:port { proxy.server = server; diff --git a/backend/src/core/proxy-utils/parsers/peggy/surge.peg b/backend/src/core/proxy-utils/parsers/peggy/surge.peg index a72ad58..c565aee 100644 --- a/backend/src/core/proxy-utils/parsers/peggy/surge.peg +++ b/backend/src/core/proxy-utils/parsers/peggy/surge.peg @@ -35,7 +35,7 @@ } } -start = (shadowsocks/vmess/trojan/https/http/snell/socks5/socks5_tls/tuic/tuic_v5/wireguard/hysteria2/ssh) { +start = (shadowsocks/vmess/trojan/https/http/snell/socks5/socks5_tls/tuic/tuic_v5/wireguard/hysteria2/ssh/direct) { return proxy; } @@ -115,7 +115,9 @@ socks5_tls = tag equals "socks5-tls" address (username password)? (usernamek pas proxy.tls = true; handleShadowTLS(); } - +direct = tag equals "direct" (ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/block_quic/others)* { + proxy.type = "direct"; +} address = comma server:server comma port:port { proxy.server = server; proxy.port = port; diff --git a/backend/src/core/proxy-utils/producers/surge.js b/backend/src/core/proxy-utils/producers/surge.js index 063b18e..dfbfd25 100644 --- a/backend/src/core/proxy-utils/producers/surge.js +++ b/backend/src/core/proxy-utils/producers/surge.js @@ -27,6 +27,8 @@ export default function Surge_Producer() { return vmess(proxy, opts['include-unsupported-proxy']); case 'http': return http(proxy); + case 'direct': + return direct(proxy); case 'socks5': return socks5(proxy); case 'snell': @@ -503,6 +505,54 @@ function http(proxy) { return result.toString(); } +function direct(proxy) { + const result = new Result(proxy); + const type = 'direct'; + result.append(`${proxy.name}=${type}`); + + const ip_version = ipVersions[proxy['ip-version']] || proxy['ip-version']; + result.appendIfPresent(`,ip-version=${ip_version}`, 'ip-version'); + + result.appendIfPresent( + `,no-error-alert=${proxy['no-error-alert']}`, + 'no-error-alert', + ); + + // tfo + result.appendIfPresent(`,tfo=${proxy.tfo}`, 'tfo'); + + // udp + result.appendIfPresent(`,udp-relay=${proxy.udp}`, 'udp'); + + // test-url + result.appendIfPresent(`,test-url=${proxy['test-url']}`, 'test-url'); + result.appendIfPresent( + `,test-timeout=${proxy['test-timeout']}`, + 'test-timeout', + ); + result.appendIfPresent(`,test-udp=${proxy['test-udp']}`, 'test-udp'); + result.appendIfPresent(`,hybrid=${proxy['hybrid']}`, 'hybrid'); + result.appendIfPresent(`,tos=${proxy['tos']}`, 'tos'); + result.appendIfPresent( + `,allow-other-interface=${proxy['allow-other-interface']}`, + 'allow-other-interface', + ); + result.appendIfPresent( + `,interface=${proxy['interface-name']}`, + 'interface-name', + ); + + // block-quic + result.appendIfPresent(`,block-quic=${proxy['block-quic']}`, 'block-quic'); + + // underlying-proxy + result.appendIfPresent( + `,underlying-proxy=${proxy['underlying-proxy']}`, + 'underlying-proxy', + ); + + return result.toString(); +} function socks5(proxy) { const result = new Result(proxy);