refactor: New tun udpnat

This commit is contained in:
世界
2026-07-16 21:35:01 +08:00
parent 64f833d8f7
commit c8ee3497b2
27 changed files with 428 additions and 102 deletions
+67
View File
@@ -0,0 +1,67 @@
---
icon: material/new-box
---
!!! quote "Changes in sing-box 1.14.0"
:material-plus: [udp_mapping](#udp_mapping)
:material-plus: [udp_filtering](#udp_filtering)
:material-plus: [udp_nat_max](#udp_nat_max)
### Structure
```json
{
"udp_timeout": "5m",
"udp_mapping": "endpoint_independent",
"udp_filtering": "endpoint_independent",
"udp_nat_max": 0
}
```
### Fields
#### udp_timeout
UDP NAT expiration time.
`5m` will be used by default.
#### udp_mapping
!!! question "Since sing-box 1.14.0"
UDP NAT mapping behavior.
| Value | Behavior |
|------------------------------|-------------------------------------------------------------------------------|
| `endpoint_independent` | Reuse the same mapping for the same source address and port for all destinations. |
| `address_dependent` | Use a separate mapping for each destination address. |
| `address_and_port_dependent` | Use a separate mapping for each destination address and port. |
`endpoint_independent` is used by default.
#### udp_filtering
!!! question "Since sing-box 1.14.0"
UDP NAT filtering behavior.
| Value | Behavior |
|------------------------------|-----------------------------------------------------------------------------|
| `endpoint_independent` | Accept packets from any remote endpoint. |
| `address_dependent` | Accept packets only from remote addresses to which packets have been sent. |
| `address_and_port_dependent` | Accept packets only from remote addresses and ports to which packets have been sent. |
`endpoint_independent` is used by default.
#### udp_nat_max
!!! question "Since sing-box 1.14.0"
Maximum number of UDP NAT sessions.
When the limit is reached, the least recently used session is closed.
When unset or set to `0`, `4096` is used on iOS. On other platforms, a value from `4096` to `16384` is selected based on total memory;
`16384` is used if total memory cannot be detected.
+67
View File
@@ -0,0 +1,67 @@
---
icon: material/new-box
---
!!! quote "sing-box 1.14.0 中的更改"
:material-plus: [udp_mapping](#udp_mapping)
:material-plus: [udp_filtering](#udp_filtering)
:material-plus: [udp_nat_max](#udp_nat_max)
### 结构
```json
{
"udp_timeout": "5m",
"udp_mapping": "endpoint_independent",
"udp_filtering": "endpoint_independent",
"udp_nat_max": 0
}
```
### 字段
#### udp_timeout
UDP NAT 过期时间。
默认使用 `5m`
#### udp_mapping
!!! question "自 sing-box 1.14.0 起"
UDP NAT 映射行为。
| 值 | 行为 |
|------------------------------|----------------------------------------------------------|
| `endpoint_independent` | 对相同的源地址和端口,所有目标复用同一映射。 |
| `address_dependent` | 每个目标地址使用单独的映射。 |
| `address_and_port_dependent` | 每个目标地址和端口使用单独的映射。 |
默认使用 `endpoint_independent`
#### udp_filtering
!!! question "自 sing-box 1.14.0 起"
UDP NAT 过滤行为。
| 值 | 行为 |
|------------------------------|----------------------------------------------------------|
| `endpoint_independent` | 接受来自任意远程端点的数据包。 |
| `address_dependent` | 仅接受来自已向其发送过数据包的远程地址的数据包。 |
| `address_and_port_dependent` | 仅接受来自已向其发送过数据包的远程地址和端口的数据包。 |
默认使用 `endpoint_independent`
#### udp_nat_max
!!! question "自 sing-box 1.14.0 起"
UDP NAT 会话的最大数量。
达到限制时,将关闭最近最少使用的会话。
未设置或设置为 `0` 时,iOS 使用 `4096`。其他平台根据总内存在 `4096``16384` 之间选择;
无法检测总内存时使用 `16384`