Skip to content

Commit eac736f

Browse files
committed
feat: sing-box 支持使用完整的 _ech 结构设置 tlsech
1 parent 1af1af1 commit eac736f

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sub-store",
3-
"version": "2.21.12",
3+
"version": "2.21.13",
44
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
55
"main": "src/main.js",
66
"scripts": {

backend/src/core/proxy-utils/producers/sing-box.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import ClashMeta_Producer from './clashmeta';
22
import $ from '@/core/app';
3-
import { isIPv4, isIPv6 } from '@/utils';
3+
import { isIPv4, isIPv6, isPlainObject } from '@/utils';
44

55
const ipVersions = {
66
ipv4: 'ipv4_only',
@@ -271,6 +271,9 @@ const tlsParser = (proxy, parsedProxy) => {
271271
enabled: true,
272272
fingerprint: proxy['client-fingerprint'],
273273
};
274+
if (proxy._ech && isPlainObject(proxy._ech)) {
275+
parsedProxy.tls.ech = proxy._ech;
276+
}
274277
if (proxy['_fragment']) parsedProxy.tls.fragment = !!proxy['_fragment'];
275278
if (proxy['_fragment_fallback_delay'])
276279
parsedProxy.tls.fragment_fallback_delay =
@@ -978,7 +981,10 @@ export default function singbox_Producer() {
978981
}
979982
break;
980983
case 'vless':
981-
if (proxy.encryption && proxy.encryption !== 'none') {
984+
if (
985+
proxy.encryption &&
986+
proxy.encryption !== 'none'
987+
) {
982988
throw new Error(
983989
`VLESS encryption is not supported`,
984990
);

backend/src/utils/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,15 @@ function formatDateTime(date, format = 'YYYY-MM-DD_HH-mm-ss') {
150150
);
151151
}
152152

153+
function isPlainObject(obj) {
154+
return (
155+
obj !== null &&
156+
typeof obj === 'object' &&
157+
[null, Object.prototype].includes(Object.getPrototypeOf(obj))
158+
);
159+
}
153160
export {
161+
isPlainObject,
154162
formatDateTime,
155163
isValidUUID,
156164
ipAddress,

scripts/demo.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ function operator(proxies = [], targetPlatform, context) {
3131
// 17. `block-quic` 支持 `auto`, `on`, `off`. 不同的平台不一定都支持, 会自动转换
3232
// 18. `sing-box` 支持 `_fragment`, `_fragment_fallback_delay`, `_record_fragment` 设置 `tls` 的 `fragment`, `fragment_fallback_delay`, `record_fragment`
3333
// 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`
34-
// 20. `interface-name` 指定流量出站接口 只给 Surge 用的话, `interface` 也可以
34+
// 20. `sing-box` 支持使用完整的 `_ech` 结构设置 `tls` 的 `ech`
35+
// 21. `interface-name` 指定流量出站接口 只给 Surge 用的话, `interface` 也可以
3536

3637
// require 为 Node.js 的 require, 在 Node.js 运行环境下 可以用来引入模块
3738
// 例如在 Node.js 环境下, 将文件内容写入 /tmp/1.txt 文件

0 commit comments

Comments
 (0)