Refactor: HTTP clients, unified HTTP2/QUIC options, Apple engines

This commit is contained in:
世界
2026-04-14 22:59:46 +08:00
parent 94b4a4e718
commit 0f3d72cc9a
113 changed files with 13622 additions and 8053 deletions
@@ -6,7 +6,7 @@ icon: material/new-box
:material-plus: [account_key](#account_key)
:material-plus: [key_type](#key_type)
:material-plus: [detour](#detour)
:material-plus: [http_client](#http_client)
# ACME
@@ -37,7 +37,7 @@ icon: material/new-box
},
"dns01_challenge": {},
"key_type": "",
"detour": ""
"http_client": "" // or {}
}
```
@@ -141,10 +141,10 @@ The private key type to generate for new certificates.
| `rsa2048` | RSA |
| `rsa4096` | RSA |
#### detour
#### http_client
!!! question "Since sing-box 1.14.0"
The tag of the upstream outbound.
HTTP Client for all provider HTTP requests.
All provider HTTP requests will use this outbound.
See [HTTP Client Fields](/configuration/shared/http-client/) for details.
@@ -6,7 +6,7 @@ icon: material/new-box
:material-plus: [account_key](#account_key)
:material-plus: [key_type](#key_type)
:material-plus: [detour](#detour)
:material-plus: [http_client](#http_client)
# ACME
@@ -37,7 +37,7 @@ icon: material/new-box
},
"dns01_challenge": {},
"key_type": "",
"detour": ""
"http_client": "" // 或 {}
}
```
@@ -136,10 +136,12 @@ ACME DNS01 质询字段。如果配置,将禁用其他质询方法。
| `rsa2048` | RSA |
| `rsa4096` | RSA |
#### detour
#### http_client
!!! question "自 sing-box 1.14.0 起"
上游出站的标签
用于所有提供者 HTTP 请求的 HTTP 客户端
参阅 [HTTP 客户端字段](/zh/configuration/shared/http-client/) 了解详情。
所有提供者 HTTP 请求将使用此出站。
@@ -19,7 +19,7 @@ icon: material/new-box
"origin_ca_key": "",
"request_type": "",
"requested_validity": 0,
"detour": ""
"http_client": "" // or {}
}
```
@@ -75,8 +75,8 @@ Available values: `7`, `30`, `90`, `365`, `730`, `1095`, `5475`.
`5475` days (15 years) is used if empty.
#### detour
#### http_client
The tag of the upstream outbound.
HTTP Client for all provider HTTP requests.
All provider HTTP requests will use this outbound.
See [HTTP Client Fields](/configuration/shared/http-client/) for details.
@@ -19,7 +19,7 @@ icon: material/new-box
"origin_ca_key": "",
"request_type": "",
"requested_validity": 0,
"detour": ""
"http_client": "" // 或 {}
}
```
@@ -75,8 +75,8 @@ Cloudflare Origin CA Key。
如果为空,使用 `5475` 天(15 年)。
#### detour
#### http_client
上游出站的标签
用于所有提供者 HTTP 请求的 HTTP 客户端
所有提供者 HTTP 请求将使用此出站
参阅 [HTTP 客户端字段](/zh/configuration/shared/http-client/) 了解详情
+114
View File
@@ -0,0 +1,114 @@
---
icon: material/new-box
---
!!! question "Since sing-box 1.14.0"
### Structure
A string or an object.
When string, the tag of a shared [HTTP Client](/configuration/shared/http-client/) defined in top-level `http_clients`.
When object:
```json
{
"engine": "",
"version": 0,
"disable_version_fallback": false,
"headers": {},
... // HTTP2 Fields
"tls": {},
... // Dial Fields
}
```
### Fields
#### engine
HTTP engine to use.
Values:
* `go` (default)
* `apple`
`apple` uses NSURLSession, only available on Apple platforms.
!!! warning ""
Experimental only: due to the high memory overhead of both CGO and Network.framework,
do not use in hot paths on iOS and tvOS.
Supported fields:
* `headers`
* `tls.server_name` (must match request host)
* `tls.insecure`
* `tls.min_version` / `tls.max_version`
* `tls.certificate` / `tls.certificate_path`
* `tls.certificate_public_key_sha256`
* Dial Fields
Unsupported fields:
* `version`
* `disable_version_fallback`
* HTTP2 Fields
* QUIC Fields
* `tls.engine`
* `tls.alpn`
* `tls.disable_sni`
* `tls.cipher_suites`
* `tls.curve_preferences`
* `tls.client_certificate` / `tls.client_certificate_path` / `tls.client_key` / `tls.client_key_path`
* `tls.fragment` / `tls.record_fragment`
* `tls.kernel_tx` / `tls.kernel_rx`
* `tls.ech`
* `tls.utls`
* `tls.reality`
#### version
HTTP version.
Available values: `1`, `2`, `3`.
`2` is used by default.
When `3`, [HTTP2 Fields](#http2-fields) are replaced by [QUIC Fields](#quic-fields).
#### disable_version_fallback
Disable automatic fallback to lower HTTP version.
#### headers
Custom HTTP headers.
`Host` header is used as request host.
### HTTP2 Fields
When `version` is `2` (default).
See [HTTP2 Fields](/configuration/shared/http2/) for details.
### QUIC Fields
When `version` is `3`.
See [QUIC Fields](/configuration/shared/quic/) for details.
### TLS Fields
See [TLS](/configuration/shared/tls/#outbound) for details.
### Dial Fields
See [Dial Fields](/configuration/shared/dial/) for details.
+114
View File
@@ -0,0 +1,114 @@
---
icon: material/new-box
---
!!! question "自 sing-box 1.14.0 起"
### 结构
字符串或对象。
当为字符串时,为顶层 `http_clients` 中定义的共享 [HTTP 客户端](/zh/configuration/shared/http-client/) 的标签。
当为对象时:
```json
{
"engine": "",
"version": 0,
"disable_version_fallback": false,
"headers": {},
... // HTTP2 字段
"tls": {},
... // 拨号字段
}
```
### 字段
#### engine
要使用的 HTTP 引擎。
可用值:
* `go`(默认)
* `apple`
`apple` 使用 NSURLSession,仅在 Apple 平台可用。
!!! warning ""
仅供实验用途:由于 CGO 和 Network.framework 占用的内存都很多,
不应在 iOS 和 tvOS 的热路径中使用。
支持的字段:
* `headers`
* `tls.server_name`(必须与请求主机匹配)
* `tls.insecure`
* `tls.min_version` / `tls.max_version`
* `tls.certificate` / `tls.certificate_path`
* `tls.certificate_public_key_sha256`
* 拨号字段
不支持的字段:
* `version`
* `disable_version_fallback`
* HTTP2 字段
* QUIC 字段
* `tls.engine`
* `tls.alpn`
* `tls.disable_sni`
* `tls.cipher_suites`
* `tls.curve_preferences`
* `tls.client_certificate` / `tls.client_certificate_path` / `tls.client_key` / `tls.client_key_path`
* `tls.fragment` / `tls.record_fragment`
* `tls.kernel_tx` / `tls.kernel_rx`
* `tls.ech`
* `tls.utls`
* `tls.reality`
#### version
HTTP 版本。
可用值:`1``2``3`
默认使用 `2`
当为 `3` 时,[HTTP2 字段](#http2-字段) 替换为 [QUIC 字段](#quic-字段)。
#### disable_version_fallback
禁用自动回退到更低的 HTTP 版本。
#### headers
自定义 HTTP 标头。
`Host` 标头用作请求主机。
### HTTP2 字段
`version``2`(默认)时。
参阅 [HTTP2 字段](/zh/configuration/shared/http2/) 了解详情。
### QUIC 字段
`version``3` 时。
参阅 [QUIC 字段](/zh/configuration/shared/quic/) 了解详情。
### TLS 字段
参阅 [TLS](/zh/configuration/shared/tls/#出站) 了解详情。
### 拨号字段
参阅 [拨号字段](/zh/configuration/shared/dial/) 了解详情。
+43
View File
@@ -0,0 +1,43 @@
---
icon: material/new-box
---
!!! question "Since sing-box 1.14.0"
### Structure
```json
{
"idle_timeout": "",
"keep_alive_period": "",
"stream_receive_window": "",
"connection_receive_window": "",
"max_concurrent_streams": 0
}
```
### Fields
#### idle_timeout
Idle connection timeout, in golang's Duration format.
#### keep_alive_period
Keep alive period, in golang's Duration format.
#### stream_receive_window
HTTP2 stream-level flow-control receive window size.
Accepts memory size format, e.g. `"64 MB"`.
#### connection_receive_window
HTTP2 connection-level flow-control receive window size.
Accepts memory size format, e.g. `"64 MB"`.
#### max_concurrent_streams
Maximum concurrent streams per connection.
+43
View File
@@ -0,0 +1,43 @@
---
icon: material/new-box
---
!!! question "自 sing-box 1.14.0 起"
### 结构
```json
{
"idle_timeout": "",
"keep_alive_period": "",
"stream_receive_window": "",
"connection_receive_window": "",
"max_concurrent_streams": 0
}
```
### 字段
#### idle_timeout
空闲连接超时,采用 golang 的 Duration 格式。
#### keep_alive_period
Keep alive 周期,采用 golang 的 Duration 格式。
#### stream_receive_window
HTTP2 流级别流控接收窗口大小。
接受内存大小格式,例如 `"64 MB"`
#### connection_receive_window
HTTP2 连接级别流控接收窗口大小。
接受内存大小格式,例如 `"64 MB"`
#### max_concurrent_streams
每个连接的最大并发流数。
+30
View File
@@ -0,0 +1,30 @@
---
icon: material/new-box
---
!!! question "Since sing-box 1.14.0"
### Structure
```json
{
"initial_packet_size": 0,
"disable_path_mtu_discovery": false,
... // HTTP2 Fields
}
```
### Fields
#### initial_packet_size
Initial QUIC packet size.
#### disable_path_mtu_discovery
Disable QUIC path MTU discovery.
### HTTP2 Fields
See [HTTP2 Fields](/configuration/shared/http2/) for details.
+30
View File
@@ -0,0 +1,30 @@
---
icon: material/new-box
---
!!! question "自 sing-box 1.14.0 起"
### 结构
```json
{
"initial_packet_size": 0,
"disable_path_mtu_discovery": false,
... // HTTP2 字段
}
```
### 字段
#### initial_packet_size
初始 QUIC 数据包大小。
#### disable_path_mtu_discovery
禁用 QUIC 路径 MTU 发现。
### HTTP2 字段
参阅 [HTTP2 字段](/zh/configuration/shared/http2/) 了解详情。
+57
View File
@@ -5,6 +5,7 @@ icon: material/new-box
!!! quote "Changes in sing-box 1.14.0"
:material-plus: [certificate_provider](#certificate_provider)
:material-plus: [handshake_timeout](#handshake_timeout)
:material-delete-clock: [acme](#acme-fields)
!!! quote "Changes in sing-box 1.13.0"
@@ -54,6 +55,7 @@ icon: material/new-box
"key_path": "",
"kernel_tx": false,
"kernel_rx": false,
"handshake_timeout": "",
"certificate_provider": "",
// Deprecated
@@ -106,6 +108,7 @@ icon: material/new-box
```json
{
"enabled": true,
"engine": "",
"disable_sni": false,
"server_name": "",
"insecure": false,
@@ -124,6 +127,9 @@ icon: material/new-box
"fragment": false,
"fragment_fallback_delay": "",
"record_fragment": false,
"kernel_tx": false,
"kernel_rx": false,
"handshake_timeout": "",
"ech": {
"enabled": false,
"config": [],
@@ -183,6 +189,49 @@ Cipher suite values:
Enable TLS.
#### engine
==Client only==
TLS engine to use.
Values:
* `go` (default)
* `apple`
`apple` uses Network.framework, only available on Apple platforms and only supports **direct** TCP TLS client connections.
!!! warning ""
Experimental only: due to the high memory overhead of both CGO and Network.framework,
do not use in hot paths on iOS and tvOS.
If you want to circumvent TLS fingerprint-based proxy censorship,
use [NaiveProxy](/configuration/outbound/naive/) instead.
Supported fields:
* `server_name`
* `insecure`
* `alpn`
* `min_version`
* `max_version`
* `certificate` / `certificate_path`
* `certificate_public_key_sha256`
* `handshake_timeout`
Unsupported fields:
* `disable_sni`
* `cipher_suites`
* `curve_preferences`
* `client_certificate` / `client_certificate_path` / `client_key` / `client_key_path`
* `fragment` / `record_fragment`
* `kernel_tx` / `kernel_rx`
* `ech`
* `utls`
* `reality`
#### disable_sni
==Client only==
@@ -417,6 +466,14 @@ Enable kernel TLS transmit support.
Enable kernel TLS receive support.
#### handshake_timeout
!!! question "Since sing-box 1.14.0"
TLS handshake timeout, in golang's Duration format.
`15s` is used by default.
#### certificate_provider
!!! question "Since sing-box 1.14.0"
+56
View File
@@ -5,6 +5,7 @@ icon: material/new-box
!!! quote "sing-box 1.14.0 中的更改"
:material-plus: [certificate_provider](#certificate_provider)
:material-plus: [handshake_timeout](#handshake_timeout)
:material-delete-clock: [acme](#acme-字段)
!!! quote "sing-box 1.13.0 中的更改"
@@ -54,6 +55,7 @@ icon: material/new-box
"key_path": "",
"kernel_tx": false,
"kernel_rx": false,
"handshake_timeout": "",
"certificate_provider": "",
// 废弃的
@@ -106,6 +108,7 @@ icon: material/new-box
```json
{
"enabled": true,
"engine": "",
"disable_sni": false,
"server_name": "",
"insecure": false,
@@ -124,6 +127,9 @@ icon: material/new-box
"fragment": false,
"fragment_fallback_delay": "",
"record_fragment": false,
"kernel_tx": false,
"kernel_rx": false,
"handshake_timeout": "",
"ech": {
"enabled": false,
"config": [],
@@ -183,6 +189,48 @@ TLS 版本值:
启用 TLS
#### engine
==仅客户端==
要使用的 TLS 引擎。
可用值:
* `go`(默认)
* `apple`
`apple` 使用 Network.framework,仅在 Apple 平台可用,且仅支持 **直接** TCP TLS 客户端连接。
!!! warning ""
仅供实验用途:由于 CGO 和 Network.framework 占用的内存都很多,
不应在 iOS 和 tvOS 的热路径中使用。
如果您想规避基于 TLS 指纹的代理审查,应使用 [NaiveProxy](/zh/configuration/outbound/naive/)。
支持的字段:
* `server_name`
* `insecure`
* `alpn`
* `min_version`
* `max_version`
* `certificate` / `certificate_path`
* `certificate_public_key_sha256`
* `handshake_timeout`
不支持的字段:
* `disable_sni`
* `cipher_suites`
* `curve_preferences`
* `client_certificate` / `client_certificate_path` / `client_key` / `client_key_path`
* `fragment` / `record_fragment`
* `kernel_tx` / `kernel_rx`
* `ech`
* `utls`
* `reality`
#### disable_sni
==仅客户端==
@@ -416,6 +464,14 @@ echo | openssl s_client -servername example.com -connect example.com:443 2>/dev/
启用内核 TLS 接收支持。
#### handshake_timeout
!!! question "自 sing-box 1.14.0 起"
TLS 握手超时,采用 golang 的 Duration 格式。
默认使用 `15s`
#### certificate_provider
!!! question "自 sing-box 1.14.0 起"