From 2e99f28aa56718aef72c5a83fda991ef37b0772c Mon Sep 17 00:00:00 2001 From: xream Date: Fri, 2 Feb 2024 12:45:46 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=BE=93=E5=87=BA=E6=97=B6=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=20Surge,=20Surfboard,=20Loon,=20QX=20Shadowsocks=20ci?= =?UTF-8?q?pher?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package.json | 2 +- .../src/core/proxy-utils/producers/loon.js | 26 ++++++++++++++ backend/src/core/proxy-utils/producers/qx.js | 31 +++++++++++++++- .../core/proxy-utils/producers/surfboard.js | 26 ++++++++++++++ .../src/core/proxy-utils/producers/surge.js | 35 +++++++++++++++++++ 5 files changed, 118 insertions(+), 2 deletions(-) diff --git a/backend/package.json b/backend/package.json index 334cc48..2f8b5ba 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.14.199", + "version": "2.14.200", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.", "main": "src/main.js", "scripts": { diff --git a/backend/src/core/proxy-utils/producers/loon.js b/backend/src/core/proxy-utils/producers/loon.js index c8fca87..34f092e 100644 --- a/backend/src/core/proxy-utils/producers/loon.js +++ b/backend/src/core/proxy-utils/producers/loon.js @@ -32,6 +32,32 @@ export default function Loon_Producer() { function shadowsocks(proxy) { const result = new Result(proxy); + if ( + ![ + 'rc4', + 'rc4-md5', + 'aes-128-cfb', + 'aes-192-cfb', + 'aes-256-cfb', + 'aes-128-ctr', + 'aes-192-ctr', + 'aes-256-ctr', + 'bf-cfb', + 'camellia-128-cfb', + 'camellia-192-cfb', + 'camellia-256-cfb', + 'salsa20', + 'chacha20', + 'chacha20-ietf', + 'aes-128-gcm', + 'aes-192-gcm', + 'aes-256-gcm', + 'chacha20-ietf-poly1305', + 'xchacha20-ietf-poly1305', + ].includes(proxy.cipher) + ) { + throw new Error(`cipher ${proxy.cipher} is not supported`); + } result.append( `${proxy.name}=shadowsocks,${proxy.server},${proxy.port},${proxy.cipher},"${proxy.password}"`, ); diff --git a/backend/src/core/proxy-utils/producers/qx.js b/backend/src/core/proxy-utils/producers/qx.js index 1adb55b..1694c87 100644 --- a/backend/src/core/proxy-utils/producers/qx.js +++ b/backend/src/core/proxy-utils/producers/qx.js @@ -37,7 +37,36 @@ function shadowsocks(proxy) { const result = new Result(proxy); const append = result.append.bind(result); const appendIfPresent = result.appendIfPresent.bind(result); - + if (!proxy.cipher) { + proxy.cipher = 'none'; + } + if ( + ![ + 'none', + 'rc4-md5', + 'rc4-md5-6', + 'aes-128-cfb', + 'aes-192-cfb', + 'aes-256-cfb', + 'aes-128-ctr', + 'aes-192-ctr', + 'aes-256-ctr', + 'bf-cfb', + 'cast5-cfb', + 'des-cfb', + 'rc2-cfb', + 'salsa20', + 'chacha20', + 'chacha20-ietf', + 'aes-128-gcm', + 'aes-192-gcm', + 'aes-256-gcm', + 'chacha20-ietf-poly1305', + 'xchacha20-ietf-poly1305', + ].includes(proxy.cipher) + ) { + throw new Error(`cipher ${proxy.cipher} is not supported`); + } append(`shadowsocks=${proxy.server}:${proxy.port}`); append(`,method=${proxy.cipher}`); append(`,password=${proxy.password}`); diff --git a/backend/src/core/proxy-utils/producers/surfboard.js b/backend/src/core/proxy-utils/producers/surfboard.js index 08f1675..aaf5f57 100644 --- a/backend/src/core/proxy-utils/producers/surfboard.js +++ b/backend/src/core/proxy-utils/producers/surfboard.js @@ -31,6 +31,32 @@ export default function Surfboard_Producer() { function shadowsocks(proxy) { const result = new Result(proxy); result.append(`${proxy.name}=${proxy.type},${proxy.server},${proxy.port}`); + if ( + ![ + 'aes-128-gcm', + 'aes-192-gcm', + 'aes-256-gcm', + 'chacha20-ietf-poly1305', + 'xchacha20-ietf-poly1305', + 'rc4', + 'rc4-md5', + 'aes-128-cfb', + 'aes-192-cfb', + 'aes-256-cfb', + 'aes-128-ctr', + 'aes-192-ctr', + 'aes-256-ctr', + 'bf-cfb', + 'camellia-128-cfb', + 'camellia-192-cfb', + 'camellia-256-cfb', + 'salsa20', + 'chacha20', + 'chacha20-ietf', + ].includes(proxy.cipher) + ) { + throw new Error(`cipher ${proxy.cipher} is not supported`); + } result.append(`,encrypt-method=${proxy.cipher}`); result.appendIfPresent(`,password=${proxy.password}`, 'password'); diff --git a/backend/src/core/proxy-utils/producers/surge.js b/backend/src/core/proxy-utils/producers/surge.js index e3fdf0d..cb5410e 100644 --- a/backend/src/core/proxy-utils/producers/surge.js +++ b/backend/src/core/proxy-utils/producers/surge.js @@ -44,6 +44,41 @@ export default function Surge_Producer() { function shadowsocks(proxy) { const result = new Result(proxy); result.append(`${proxy.name}=${proxy.type},${proxy.server},${proxy.port}`); + if (!proxy.cipher) { + proxy.cipher = 'none'; + } + if ( + ![ + 'aes-128-gcm', + 'aes-192-gcm', + 'aes-256-gcm', + 'chacha20-ietf-poly1305', + 'xchacha20-ietf-poly1305', + 'rc4', + 'rc4-md5', + 'aes-128-cfb', + 'aes-192-cfb', + 'aes-256-cfb', + 'aes-128-ctr', + 'aes-192-ctr', + 'aes-256-ctr', + 'bf-cfb', + 'camellia-128-cfb', + 'camellia-192-cfb', + 'camellia-256-cfb', + 'cast5-cfb', + 'des-cfb', + 'idea-cfb', + 'rc2-cfb', + 'seed-cfb', + 'salsa20', + 'chacha20', + 'chacha20-ietf', + 'none', + ].includes(proxy.cipher) + ) { + throw new Error(`cipher ${proxy.cipher} is not supported`); + } result.append(`,encrypt-method=${proxy.cipher}`); result.appendIfPresent(`,password=${proxy.password}`, 'password');