From eac736f2868e5782a34b403f506c9c7948afa9bb Mon Sep 17 00:00:00 2001 From: xream Date: Fri, 23 Jan 2026 15:04:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20`sing-box`=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=AE=8C=E6=95=B4=E7=9A=84=20`=5Fech`=20?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E8=AE=BE=E7=BD=AE=20`tls`=20=E7=9A=84=20`ech?= =?UTF-8?q?`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package.json | 2 +- backend/src/core/proxy-utils/producers/sing-box.js | 10 ++++++++-- backend/src/utils/index.js | 8 ++++++++ scripts/demo.js | 3 ++- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/backend/package.json b/backend/package.json index d8ece78e..27981003 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.21.12", + "version": "2.21.13", "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/sing-box.js b/backend/src/core/proxy-utils/producers/sing-box.js index 48f3d88b..1cdf915c 100644 --- a/backend/src/core/proxy-utils/producers/sing-box.js +++ b/backend/src/core/proxy-utils/producers/sing-box.js @@ -1,6 +1,6 @@ import ClashMeta_Producer from './clashmeta'; import $ from '@/core/app'; -import { isIPv4, isIPv6 } from '@/utils'; +import { isIPv4, isIPv6, isPlainObject } from '@/utils'; const ipVersions = { ipv4: 'ipv4_only', @@ -271,6 +271,9 @@ const tlsParser = (proxy, parsedProxy) => { enabled: true, fingerprint: proxy['client-fingerprint'], }; + if (proxy._ech && isPlainObject(proxy._ech)) { + parsedProxy.tls.ech = proxy._ech; + } if (proxy['_fragment']) parsedProxy.tls.fragment = !!proxy['_fragment']; if (proxy['_fragment_fallback_delay']) parsedProxy.tls.fragment_fallback_delay = @@ -978,7 +981,10 @@ export default function singbox_Producer() { } break; case 'vless': - if (proxy.encryption && proxy.encryption !== 'none') { + if ( + proxy.encryption && + proxy.encryption !== 'none' + ) { throw new Error( `VLESS encryption is not supported`, ); diff --git a/backend/src/utils/index.js b/backend/src/utils/index.js index f771d2c4..f78146cc 100644 --- a/backend/src/utils/index.js +++ b/backend/src/utils/index.js @@ -150,7 +150,15 @@ function formatDateTime(date, format = 'YYYY-MM-DD_HH-mm-ss') { ); } +function isPlainObject(obj) { + return ( + obj !== null && + typeof obj === 'object' && + [null, Object.prototype].includes(Object.getPrototypeOf(obj)) + ); +} export { + isPlainObject, formatDateTime, isValidUUID, ipAddress, diff --git a/scripts/demo.js b/scripts/demo.js index 8ac76746..928dffa2 100644 --- a/scripts/demo.js +++ b/scripts/demo.js @@ -31,7 +31,8 @@ function operator(proxies = [], targetPlatform, context) { // 17. `block-quic` 支持 `auto`, `on`, `off`. 不同的平台不一定都支持, 会自动转换 // 18. `sing-box` 支持 `_fragment`, `_fragment_fallback_delay`, `_record_fragment` 设置 `tls` 的 `fragment`, `fragment_fallback_delay`, `record_fragment` // 19. `sing-box` 支持 `_certificate`, `_certificate_path`, `_certificate_public_key_sha256`, `_client_certificate`, `_client_certificate_path`, `_client_key`, `_client_key_path` 设置 `tls` 的 `certificate`, `certificate_path`, `certificate_public_key_sha256`, `client_certificate`, `client_certificate_path`, `client_key`, `client_key_path` - // 20. `interface-name` 指定流量出站接口 只给 Surge 用的话, `interface` 也可以 + // 20. `sing-box` 支持使用完整的 `_ech` 结构设置 `tls` 的 `ech` + // 21. `interface-name` 指定流量出站接口 只给 Surge 用的话, `interface` 也可以 // require 为 Node.js 的 require, 在 Node.js 运行环境下 可以用来引入模块 // 例如在 Node.js 环境下, 将文件内容写入 /tmp/1.txt 文件