From 4713b6308357d121c6bf8c4bd9bed8171d46e8cf Mon Sep 17 00:00:00 2001 From: xream Date: Thu, 5 Dec 2024 23:50:51 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20Loon=20=E4=BD=BF=E7=94=A8=20includeUnsu?= =?UTF-8?q?pportedProxy=20=E5=8F=82=E6=95=B0=E5=BC=80=E5=90=AF=20Shadowsoc?= =?UTF-8?q?ks=202022?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package.json | 2 +- backend/src/core/proxy-utils/parsers/peggy/loon.js | 2 +- backend/src/core/proxy-utils/parsers/peggy/loon.peg | 2 +- backend/src/core/proxy-utils/producers/loon.js | 9 ++++++--- backend/src/products/resource-parser.loon.js | 8 ++++++-- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/backend/package.json b/backend/package.json index 04c14a3ca..afb93a485 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.14.436", + "version": "2.14.437", "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/peggy/loon.js b/backend/src/core/proxy-utils/parsers/peggy/loon.js index fc19f7a4f..bbc4ecab6 100644 --- a/backend/src/core/proxy-utils/parsers/peggy/loon.js +++ b/backend/src/core/proxy-utils/parsers/peggy/loon.js @@ -120,7 +120,7 @@ port = digits:[0-9]+ { method = comma cipher:cipher { proxy.cipher = cipher; } -cipher = ("aes-128-cfb"/"aes-128-ctr"/"aes-128-gcm"/"aes-192-cfb"/"aes-192-ctr"/"aes-192-gcm"/"aes-256-cfb"/"aes-256-ctr"/"aes-256-gcm"/"auto"/"bf-cfb"/"camellia-128-cfb"/"camellia-192-cfb"/"camellia-256-cfb"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"none"/"rc4-md5"/"rc4"/"salsa20"/"xchacha20-ietf-poly1305"); +cipher = ("aes-128-cfb"/"aes-128-ctr"/"aes-128-gcm"/"aes-192-cfb"/"aes-192-ctr"/"aes-192-gcm"/"aes-256-cfb"/"aes-256-ctr"/"aes-256-gcm"/"auto"/"bf-cfb"/"camellia-128-cfb"/"camellia-192-cfb"/"camellia-256-cfb"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"none"/"rc4-md5"/"rc4"/"salsa20"/"xchacha20-ietf-poly1305"/"2022-blake3-aes-128-gcm"/"2022-blake3-aes-256-gcm"); username = & { let j = peg$currPos; diff --git a/backend/src/core/proxy-utils/parsers/peggy/loon.peg b/backend/src/core/proxy-utils/parsers/peggy/loon.peg index d1660c826..b950fb673 100644 --- a/backend/src/core/proxy-utils/parsers/peggy/loon.peg +++ b/backend/src/core/proxy-utils/parsers/peggy/loon.peg @@ -118,7 +118,7 @@ port = digits:[0-9]+ { method = comma cipher:cipher { proxy.cipher = cipher; } -cipher = ("aes-128-cfb"/"aes-128-ctr"/"aes-128-gcm"/"aes-192-cfb"/"aes-192-ctr"/"aes-192-gcm"/"aes-256-cfb"/"aes-256-ctr"/"aes-256-gcm"/"auto"/"bf-cfb"/"camellia-128-cfb"/"camellia-192-cfb"/"camellia-256-cfb"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"none"/"rc4-md5"/"rc4"/"salsa20"/"xchacha20-ietf-poly1305"); +cipher = ("aes-128-cfb"/"aes-128-ctr"/"aes-128-gcm"/"aes-192-cfb"/"aes-192-ctr"/"aes-192-gcm"/"aes-256-cfb"/"aes-256-ctr"/"aes-256-gcm"/"auto"/"bf-cfb"/"camellia-128-cfb"/"camellia-192-cfb"/"camellia-256-cfb"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"none"/"rc4-md5"/"rc4"/"salsa20"/"xchacha20-ietf-poly1305"/"2022-blake3-aes-128-gcm"/"2022-blake3-aes-256-gcm"); username = & { let j = peg$currPos; diff --git a/backend/src/core/proxy-utils/producers/loon.js b/backend/src/core/proxy-utils/producers/loon.js index 39f3cd480..2dc0af490 100644 --- a/backend/src/core/proxy-utils/producers/loon.js +++ b/backend/src/core/proxy-utils/producers/loon.js @@ -4,10 +4,10 @@ import { isPresent, Result } from './utils'; import { isIPv4, isIPv6 } from '@/utils'; export default function Loon_Producer() { - const produce = (proxy) => { + const produce = (proxy, type, opts = {}) => { switch (proxy.type) { case 'ss': - return shadowsocks(proxy); + return shadowsocks(proxy, opts['include-unsupported-proxy']); case 'ssr': return shadowsocksr(proxy); case 'trojan': @@ -32,7 +32,7 @@ export default function Loon_Producer() { return { produce }; } -function shadowsocks(proxy) { +function shadowsocks(proxy, includeUnsupportedProxy) { const result = new Result(proxy); if ( ![ @@ -56,6 +56,9 @@ function shadowsocks(proxy) { 'aes-256-gcm', 'chacha20-ietf-poly1305', 'xchacha20-ietf-poly1305', + ...(includeUnsupportedProxy + ? ['2022-blake3-aes-128-gcm', '2022-blake3-aes-256-gcm'] + : []), ].includes(proxy.cipher) ) { throw new Error(`cipher ${proxy.cipher} is not supported`); diff --git a/backend/src/products/resource-parser.loon.js b/backend/src/products/resource-parser.loon.js index b77314a2e..c02c35786 100644 --- a/backend/src/products/resource-parser.loon.js +++ b/backend/src/products/resource-parser.loon.js @@ -37,7 +37,9 @@ let resourceUrl = typeof $resourceUrl !== 'undefined' ? $resourceUrl : ''; if (resourceType === RESOURCE_TYPE.PROXY) { try { let proxies = ProxyUtils.parse(resource); - result = ProxyUtils.produce(proxies, 'Loon'); + result = ProxyUtils.produce(proxies, 'Loon', undefined, { + 'include-unsupported-proxy': arg?.includeUnsupportedProxy, + }); } catch (e) { console.log('解析器: 使用 resource 出现错误'); console.log(e.message ?? e); @@ -47,7 +49,9 @@ let resourceUrl = typeof $resourceUrl !== 'undefined' ? $resourceUrl : ''; try { let raw = await download(resourceUrl, arg?.ua, arg?.timeout); let proxies = ProxyUtils.parse(raw); - result = ProxyUtils.produce(proxies, 'Loon'); + result = ProxyUtils.produce(proxies, 'Loon', undefined, { + 'include-unsupported-proxy': arg?.includeUnsupportedProxy, + }); } catch (e) { console.log(e.message ?? e); }