From 0825f15d046faad032a6b51e14b82c8640420969 Mon Sep 17 00:00:00 2001 From: xream Date: Tue, 18 Feb 2025 15:07:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20Egern=20=E6=94=AF=E6=8C=81=20Shadow=20T?= =?UTF-8?q?LS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package.json | 2 +- .../src/core/proxy-utils/producers/egern.js | 38 ++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/backend/package.json b/backend/package.json index baf95df..6af349b 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.16.46", + "version": "2.16.47", "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/egern.js b/backend/src/core/proxy-utils/producers/egern.js index 16b7367..c451424 100644 --- a/backend/src/core/proxy-utils/producers/egern.js +++ b/backend/src/core/proxy-utils/producers/egern.js @@ -1,6 +1,8 @@ +import { isPresent } from './utils'; + export default function Egern_Producer() { const type = 'ALL'; - const produce = (proxies, type, opts = {}) => { + const produce = (proxies, type) => { // https://egernapp.com/zh-CN/docs/configuration/proxies const list = proxies .filter((proxy) => { @@ -71,6 +73,7 @@ export default function Egern_Producer() { return true; }) .map((proxy) => { + const original = { ...proxy }; if (proxy.tls && !proxy.sni) { proxy.sni = proxy.server; } @@ -326,6 +329,39 @@ export default function Egern_Producer() { // skip_tls_verify: proxy['skip-cert-verify'], }; } + if ( + [ + 'http', + 'socks5', + 'ss', + 'trojan', + 'vless', + 'vmess', + ].includes(original.type) + ) { + if (isPresent(original, 'shadow-tls-password')) { + if (original['shadow-tls-version'] != 3) + throw new Error( + `shadow-tls version ${original['shadow-tls-version']} is not supported`, + ); + proxy.shadow_tls = { + password: original['shadow-tls-password'], + sni: original['shadow-tls-sni'], + }; + } else if ( + ['shadow-tls'].includes(original.plugin) && + original['plugin-opts'] + ) { + if (original['plugin-opts'].version != 3) + throw new Error( + `shadow-tls version ${original['plugin-opts'].version} is not supported`, + ); + proxy.shadow_tls = { + password: original['plugin-opts'].password, + sni: original['plugin-opts'].host, + }; + } + } delete proxy.subName; delete proxy.collectionName;