Skip to content

Commit fb27430

Browse files
authored
docs: update documentation to remove pool connection reuse with enhanced udp protocol control
1 parent 4e66cee commit fb27430

File tree

12 files changed

+133
-56
lines changed

12 files changed

+133
-56
lines changed

docs/en/api.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,7 +1578,8 @@ Examples:
15781578
| `min` | Minimum pool capacity | Integer > 0 | `64` | Client dual-end handshake mode only |
15791579
| `max` | Maximum pool capacity | Integer > 0 | `1024` | Dual-end handshake mode |
15801580
| `mode` | Runtime mode control | `0`(auto), `1`(force mode 1), `2`(force mode 2) | `0` | Both |
1581-
| `read` | Read timeout duration | Time duration (e.g., `10m`, `30s`, `1h`) | `10m` | Both |
1581+
| `read` | Read timeout duration | Time duration (e.g., `10m`, `30s`, `1h`) | `0` | Both |
15821582
| `rate` | Bandwidth rate limit | Integer (Mbps), 0=unlimited | `0` | Both |
15831583
| `slot` | Connection slot count | Integer (1-65536) | `65536` | Both |
1584-
| `proxy` | PROXY protocol support | `0`(disabled), `1`(enabled) | `0` | Both |
1584+
| `proxy` | PROXY protocol support | `0`(disabled), `1`(enabled) | `0` | Both |
1585+
| `noudp` | UDP support control | `0`(enabled), `1`(disabled) | `0` | Both |

docs/en/configuration.md

Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -125,39 +125,37 @@ Example:
125125
nodepass "client://server.example.com:10101/127.0.0.1:8080?min=32"
126126
```
127127

128-
## Data Read Timeout and Connection Reuse
128+
## Data Read Timeout
129129

130-
The `read` parameter controls both data read timeout and connection pool reuse behavior:
130+
The `read` parameter controls data read timeout behavior:
131131

132-
- `read`: Data read timeout and connection reuse (default: 0, meaning no timeout and no connection recycling)
133-
- Value 0 or omitted: No data read timeout, connections are not recycled to the pool after data transfer completes
134-
- Positive integer with time unit: Sets read timeout and enables connection reuse
132+
- `read`: Data read timeout (default: 0, meaning no timeout)
133+
- Value 0 or omitted: No data read timeout
134+
- Positive integer with time unit: Sets read timeout
135135
- Value format: integer followed by unit (`s` for seconds, `m` for minutes, `h` for hours)
136136
- Examples: `30s` (30 seconds), `5m` (5 minutes), `1h` (1 hour)
137137
- If no data is received within the timeout period, the connection is closed
138-
- After data transfer completes, the connection is recycled to the pool for reuse
139138
- Applies to both client and server modes
140139

141140
Example:
142141
```bash
143-
# Set data read timeout to 5 minutes, enable connection reuse
142+
# Set data read timeout to 5 minutes
144143
nodepass "client://server.example.com:10101/127.0.0.1:8080?read=5m"
145144

146-
# Set data read timeout to 30 seconds for fast-response applications, enable connection reuse
145+
# Set data read timeout to 30 seconds for fast-response applications
147146
nodepass "client://server.example.com:10101/127.0.0.1:8080?read=30s"
148147

149-
# Set data read timeout to 1 hour for long-running transfers, enable connection reuse
148+
# Set data read timeout to 1 hour for long-running transfers
150149
nodepass "client://server.example.com:10101/127.0.0.1:8080?read=1h"
151150

152-
# Default behavior: no timeout and no connection recycling (omit read parameter or set to 0)
151+
# Default behavior: no timeout (omit read parameter or set to 0)
153152
nodepass "client://server.example.com:10101/127.0.0.1:8080"
154153
```
155154

156-
**Connection Reuse Use Cases:**
157-
- **HTTP Short Connections**: Set reasonable read timeout and enable connection reuse for frequent short connections to improve pool utilization
158-
- **Long Connection Optimization**: Set larger timeout values for long-lived connections while avoiding resource waste
159-
- **Resource Control**: Enable connection recycling by setting timeout in scenarios requiring strict connection lifecycle control
160-
- **Default Mode**: Use the default no-timeout no-recycling mode for scenarios requiring maximum flexibility
155+
**Data Read Timeout Use Cases:**
156+
- **Connection Management**: Prevent idle connections from consuming resources indefinitely
157+
- **Resource Control**: Set appropriate timeouts based on expected data transfer patterns
158+
- **Network Reliability**: Handle network interruptions gracefully with automatic cleanup
161159

162160
## Rate Limiting
163161
NodePass supports bandwidth rate limiting for traffic control through the `rate` parameter. This feature helps prevent network congestion and ensures fair resource allocation across multiple connections.
@@ -264,6 +262,43 @@ nodepass "server://0.0.0.0:10101/0.0.0.0:8080?log=info&tls=1&proxy=1&rate=100"
264262
- The header format follows the HAProxy PROXY protocol v1 specification
265263
- If the target service doesn't support PROXY protocol, connections may fail or behave unexpectedly
266264

265+
## UDP Support Control
266+
267+
NodePass supports UDP traffic tunneling in addition to TCP. The `noudp` parameter allows you to disable UDP support when only TCP traffic needs to be handled, which can reduce resource usage and simplify configuration.
268+
269+
- `noudp`: UDP support control (default: 0)
270+
- Value 0: UDP support enabled - both TCP and UDP traffic will be tunneled
271+
- Value 1: UDP support disabled - only TCP traffic will be tunneled, UDP packets are ignored
272+
- Applies to both client and server modes
273+
- When disabled, UDP-related resources (buffers, connections, sessions) are not allocated
274+
275+
Example:
276+
```bash
277+
# Enable UDP support (default behavior)
278+
nodepass "server://0.0.0.0:10101/0.0.0.0:8080?noudp=0"
279+
280+
# Disable UDP support for TCP-only scenarios
281+
nodepass "server://0.0.0.0:10101/0.0.0.0:8080?noudp=1"
282+
283+
# Client with UDP disabled
284+
nodepass "client://server.example.com:10101/127.0.0.1:8080?noudp=1"
285+
286+
# Combined with other parameters
287+
nodepass "server://0.0.0.0:10101/0.0.0.0:8080?log=info&tls=1&noudp=1"
288+
```
289+
290+
**UDP Support Control Use Cases:**
291+
- **TCP-Only Services**: Disable UDP when tunneling only TCP-based applications
292+
- **Resource Optimization**: Reduce memory and CPU usage by avoiding UDP processing overhead
293+
- **Security**: Prevent UDP-based attacks or unwanted traffic in restricted environments
294+
- **Simplified Configuration**: Easier setup when UDP tunneling is not required
295+
- **Network Isolation**: Isolate TCP and UDP traffic handling for better control
296+
297+
**Important Notes:**
298+
- When UDP is disabled, any UDP packets sent to the tunnel will be silently dropped
299+
- Existing UDP sessions will be terminated when switching to noudp=1
300+
- UDP buffer pools and session management are disabled when noudp=1
301+
267302
## Target Address Groups and Load Balancing
268303

269304
NodePass supports configuring multiple target addresses to achieve high availability and load balancing. Target address groups are only applicable to the egress side (the final destination of traffic) and should not be used on the ingress side.
@@ -334,10 +369,11 @@ NodePass allows flexible configuration via URL query parameters. The following t
334369
| `min` | Minimum pool capacity | `64` | X | O | X |
335370
| `max` | Maximum pool capacity | `1024` | O | X | X |
336371
| `mode` | Run mode control | `0` | O | O | X |
337-
| `read` | Data read timeout and connection reuse | `0` | O | O | X |
372+
| `read` | Data read timeout | `0` | O | O | X |
338373
| `rate` | Bandwidth rate limit | `0` | O | O | X |
339374
| `slot` | Maximum connection limit | `65536` | O | O | X |
340375
| `proxy` | PROXY protocol support| `0` | O | O | X |
376+
| `noudp` | UDP support control | `0` | O | O | X |
341377

342378
- O: Parameter is valid and recommended for configuration
343379
- X: Parameter is not applicable and should be ignored
@@ -347,6 +383,7 @@ NodePass allows flexible configuration via URL query parameters. The following t
347383
- For client/server dual-end handshake modes, adjust connection pool capacity (`min`, `max`) based on traffic and resource constraints for optimal performance.
348384
- Use run mode control (`mode`) when automatic detection doesn't match your deployment requirements or for consistent behavior across environments.
349385
- Configure rate limiting (`rate`) to control bandwidth usage and prevent network congestion in shared environments.
386+
- Set `noudp=1` when only TCP traffic needs to be tunneled to reduce resource usage and simplify configuration.
350387
- Log level (`log`) can be set in all modes for easier operations and troubleshooting.
351388

352389
## Environment Variables

docs/en/how-it-works.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ The data flow mode is automatically determined based on tunnel address and targe
148148
- For UDP: Direct datagram forwarding to target address with minimal latency
149149
- Simplified data path ensuring reliable and efficient forwarding
150150

151+
### Specific protocol characteristics
151152
- **TCP Exchange**:
152153
- Persistent connections for full-duplex communication
153154
- Continuous data streaming until connection termination
@@ -156,7 +157,7 @@ The data flow mode is automatically determined based on tunnel address and targe
156157

157158
- **UDP Exchange**:
158159
- One-shot datagram forwarding with configurable buffer sizes (`UDP_DATA_BUF_SIZE`)
159-
- Read timeout control for response waiting (`read` parameter or default 10m)
160+
- Read timeout control for response waiting (`read` parameter or default 0)
160161
- Optimized for low-latency, stateless communication
161162
- **Client Single-End Forwarding Optimization**: Direct forwarding mechanism with minimal latency
162163

@@ -266,10 +267,10 @@ The connection pool design follows the principle of "warm-up over cold start," e
266267
- Intelligent session timeout management, balancing resource usage and responsiveness
267268
- Session reuse mechanisms, reducing connection establishment overhead
268269

269-
2. **TCP Connection Reuse**:
270-
- Long connection keep-alive technology, reducing connection establishment/closure overhead
271-
- Intelligent connection reuse strategies, maximizing connection utilization
272-
- Connection health checks, ensuring reliability of reused connections
270+
2. **TCP Connection Management**:
271+
- Connection pool management for efficient resource utilization
272+
- One-time use model for connection pool entries to ensure state cleanliness
273+
- Connection health monitoring and automatic cleanup
273274

274275
3. **Cross-Protocol Unified Management**:
275276
- Unified connection lifecycle management, simplifying system complexity

docs/en/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This guide provides detailed instructions for installing NodePass using differen
44

55
## System Requirements
66

7-
- Go 1.24 or higher (for building from source)
7+
- Go 1.25 or higher (for building from source)
88
- Network connectivity between server and client endpoints
99
- Admin privileges may be required for binding to ports below 1024
1010

docs/en/troubleshooting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ This guide helps you diagnose and resolve common issues you might encounter when
7070

7171
3. **Timeout Configuration**
7272
- Adjust `NP_UDP_DIAL_TIMEOUT` if using UDP with slow response times
73-
- Increase `read` parameter in URL for long-running transfers (default: 10m)
73+
- Increase `read` parameter in URL for long-running transfers (default: 0)
7474
- Consider adjusting `NP_TCP_DIAL_TIMEOUT` for unstable network conditions
7575

7676
4. **Overloaded Server**

docs/en/usage.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Common query parameters:
2222
- `min=<min_pool>`: Minimum connection pool capacity (default: 64, set by client)
2323
- `max=<max_pool>`: Maximum connection pool capacity (default: 1024, set by server and delivered to client)
2424
- `mode=<run_mode>`: Run mode control (`0`, `1`, or `2`) - controls operational behavior
25-
- `read=<timeout>`: Data read timeout duration (default: 10m, supports time units like 30s, 5m, 30m, etc.)
25+
- `read=<timeout>`: Data read timeout duration (default: 0, supports time units like 30s, 5m, 1h, etc.)
2626
- `rate=<mbps>`: Bandwidth rate limit in Mbps (default: 0 for unlimited)
2727
- `proxy=<mode>`: PROXY protocol support (default: `0`, `1` enables PROXY protocol v1 header transmission)
2828

@@ -59,7 +59,7 @@ nodepass "server://<tunnel_addr>/<target_addr>?log=<level>&tls=<mode>&crt=<cert_
5959
- `0`: Automatic detection (default) - attempts local binding first, falls back if unavailable
6060
- `1`: Force reverse mode - server binds to target address locally and receives traffic
6161
- `2`: Force forward mode - server connects to remote target address
62-
- `read`: Data read timeout duration (default: 10m, supports time units like 30s, 5m, 30m, etc.)
62+
- `read`: Data read timeout duration (default: 0, supports time units like 30s, 5m, 1h, etc.)
6363
- `rate`: Bandwidth rate limit (default: 0 means no limit)
6464
- `proxy`: PROXY protocol support (default: `0`, `1` enables PROXY protocol v1 header before data transfer)
6565

@@ -114,7 +114,7 @@ nodepass "client://<tunnel_addr>/<target_addr>?log=<level>&min=<min_pool>&mode=<
114114
- `0`: Automatic detection (default) - attempts local binding first, falls back to handshake mode
115115
- `1`: Force single-end forwarding mode - local proxy with connection pooling
116116
- `2`: Force dual-end handshake mode - requires server coordination
117-
- `read`: Data read timeout duration (default: 10m, supports time units like 30s, 5m, 30m, etc.)
117+
- `read`: Data read timeout duration (default: 0, supports time units like 30s, 5m, 1h, etc.)
118118
- `rate`: Bandwidth rate limit (default: 0 means no limit)
119119
- `proxy`: PROXY protocol support (default: `0`, `1` enables PROXY protocol v1 header before data transfer)
120120

docs/zh/api.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,7 +1578,8 @@ client://<server_host>:<server_port>/<local_host>:<local_port>?<parameters>
15781578
| `min` | 最小连接池容量 | 整数 > 0 | `64` | 仅客户端双端握手模式 |
15791579
| `max` | 最大连接池容量 | 整数 > 0 | `1024` | 双端握手模式 |
15801580
| `mode` | 运行模式控制 | `0`(自动), `1`(强制模式1), `2`(强制模式2) | `0` | 两者 |
1581-
| `read` | 读取超时时间 | 时间长度 (如 `10m`, `30s`, `1h`) | `10m` | 两者 |
1581+
| `read` | 读取超时时间 | 时间长度 (如 `10m`, `30s`, `1h`) | `0` | 两者 |
15821582
| `rate` | 带宽速率限制 | 整数 (Mbps), 0=无限制 | `0` | 两者 |
15831583
| `slot` | 连接槽位数 | 整数 (1-65536) | `65536` | 两者 |
1584-
| `proxy` | PROXY协议支持 | `0`(禁用), `1`(启用) | `0` | 两者 |
1584+
| `proxy` | PROXY协议支持 | `0`(禁用), `1`(启用) | `0` | 两者 |
1585+
| `noudp` | UDP支持控制 | `0`(启用), `1`(禁用) | `0` | 两者 |

docs/zh/configuration.md

Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -125,39 +125,37 @@ nodepass "server://0.0.0.0:10101/remote.example.com:8080?mode=2"
125125
nodepass "client://server.example.com:10101/127.0.0.1:8080?min=32"
126126
```
127127

128-
## 数据读取超时与连接重用
128+
## 数据读取超时
129129

130-
`read`参数用于控制数据读取超时时间和连接池连接的重用行为
130+
`read`参数用于控制数据读取超时行为
131131

132-
- `read`: 数据读取超时时间(默认: 0,表示无超时且不回收连接
133-
- 值为0或省略:无数据读取超时,连接在数据传输完成后不回收到连接池
134-
- 正整数加时间单位:设置读取超时时间,并启用连接重用
132+
- `read`: 数据读取超时时间(默认: 0,表示无超时
133+
- 值为0或省略:无数据读取超时
134+
- 正整数加时间单位:设置读取超时时间
135135
- 值格式:整数后跟单位(`s`表示秒,`m`表示分钟,`h`表示小时)
136136
- 示例:`30s`(30秒),`5m`(5分钟),`1h`(1小时)
137137
- 如果在超时时间内未接收到数据,连接将被关闭
138-
- 数据传输完成后,连接将被回收到连接池供重用
139138
- 适用于客户端和服务端模式
140139

141140
示例:
142141
```bash
143-
# 设置数据读取超时为5分钟,启用连接重用
142+
# 设置数据读取超时为5分钟
144143
nodepass "client://server.example.com:10101/127.0.0.1:8080?read=5m"
145144

146-
# 设置数据读取超时为30秒,适用于快速响应应用,启用连接重用
145+
# 设置数据读取超时为30秒,适用于快速响应应用
147146
nodepass "client://server.example.com:10101/127.0.0.1:8080?read=30s"
148147

149-
# 设置数据读取超时为1小时,适用于长时间传输,启用连接重用
148+
# 设置数据读取超时为1小时,适用于长时间传输
150149
nodepass "client://server.example.com:10101/127.0.0.1:8080?read=1h"
151150

152-
# 默认行为:无超时且不回收连接(省略read参数或设置为0)
151+
# 默认行为:无超时(省略read参数或设置为0)
153152
nodepass "client://server.example.com:10101/127.0.0.1:8080"
154153
```
155154

156-
**连接重用使用场景:**
157-
- **HTTP短连接**:为频繁的短连接设置合理的读取超时并启用连接重用,提高连接池利用率
158-
- **长连接优化**:为长时间保持的连接设置较大的超时值,同时避免资源浪费
159-
- **资源控制**:在需要严格控制连接生命周期的场景下,通过设置超时启用连接回收
160-
- **默认模式**:对于需要最大灵活性的场景,使用默认的无超时不回收模式
155+
**数据读取超时使用场景:**
156+
- **连接管理**:防止空闲连接无限期消耗资源
157+
- **资源控制**:根据预期的数据传输模式设置适当的超时时间
158+
- **网络可靠性**:优雅处理网络中断,通过自动清理
161159

162160
## 速率限制
163161
NodePass支持通过`rate`参数进行带宽速率限制,用于流量控制。此功能有助于防止网络拥塞,确保多个连接间的公平资源分配。
@@ -264,6 +262,43 @@ nodepass "server://0.0.0.0:10101/0.0.0.0:8080?log=info&tls=1&proxy=1&rate=100"
264262
- 头部格式遵循HAProxy PROXY协议v1规范
265263
- 如果目标服务不支持PROXY协议,将导致连接失败
266264

265+
## UDP支持控制
266+
267+
除了TCP之外,NodePass还支持UDP流量隧道。`noudp`参数允许您在只需要处理TCP流量时禁用UDP支持,这样可以减少资源使用并简化配置。
268+
269+
- `noudp`: UDP支持控制(默认: 0)
270+
- 值为0:启用UDP支持 - TCP和UDP流量都将被隧道传输
271+
- 值为1:禁用UDP支持 - 仅TCP流量将被隧道传输,UDP数据包将被忽略
272+
- 适用于客户端和服务端模式
273+
- 禁用时,不会分配UDP相关的资源(缓冲区、连接、会话)
274+
275+
示例:
276+
```bash
277+
# 启用UDP支持(默认行为)
278+
nodepass "server://0.0.0.0:10101/0.0.0.0:8080?noudp=0"
279+
280+
# 为仅TCP场景禁用UDP支持
281+
nodepass "server://0.0.0.0:10101/0.0.0.0:8080?noudp=1"
282+
283+
# 禁用UDP的客户端
284+
nodepass "client://server.example.com:10101/127.0.0.1:8080?noudp=1"
285+
286+
# 与其他参数组合使用
287+
nodepass "server://0.0.0.0:10101/0.0.0.0:8080?log=info&tls=1&noudp=1"
288+
```
289+
290+
**UDP支持控制使用场景:**
291+
- **仅TCP服务**:仅隧道传输TCP应用时禁用UDP
292+
- **资源优化**:通过避免UDP处理开销减少内存和CPU使用
293+
- **安全性**:在受限环境中防止基于UDP的攻击或不需要的流量
294+
- **简化配置**:不需要UDP隧道时更容易设置
295+
- **网络隔离**:更好地控制TCP和UDP流量处理
296+
297+
**重要说明:**
298+
- 禁用UDP时,发送到隧道的任何UDP数据包都将被静默丢弃
299+
- 切换到noudp=1时,现有的UDP会话将被终止
300+
- 当noudp=1时,UDP缓冲池和会话管理被禁用
301+
267302
## 目标地址组与负载均衡
268303

269304
NodePass支持配置多个目标地址以实现高可用性和负载均衡。目标地址组功能仅适用于出口端(流量最终到达的目的地),不应在入口端使用。
@@ -334,10 +369,11 @@ NodePass支持通过URL查询参数进行灵活配置,不同参数在 server
334369
| `min` | 最小连接池容量 | `64` | X | O | X |
335370
| `max` | 最大连接池容量 | `1024` | O | X | X |
336371
| `mode` | 运行模式控制 | `0` | O | O | X |
337-
| `read` | 数据读取超时与连接重用 | `0` | O | O | X |
372+
| `read` | 数据读取超时 | `0` | O | O | X |
338373
| `rate` | 带宽速率限制 | `0` | O | O | X |
339374
| `slot` | 最大连接数限制 | `65536` | O | O | X |
340375
| `proxy` | PROXY协议支持 | `0` | O | O | X |
376+
| `noudp` | UDP支持控制 | `0` | O | O | X |
341377

342378
- O:参数有效,推荐根据实际场景配置
343379
- X:参数无效,忽略设置
@@ -347,6 +383,7 @@ NodePass支持通过URL查询参数进行灵活配置,不同参数在 server
347383
- client/server 双端握手模式建议根据流量和资源情况调整连接池容量(min/max),优化性能。
348384
- 当自动检测不符合部署需求时或需要跨环境一致行为时,使用运行模式控制(mode)。
349385
- 配置速率限制(rate)以控制带宽使用,防止共享环境中的网络拥塞。
386+
- 仅需要隧道传输TCP流量时设置`noudp=1`,以减少资源使用并简化配置。
350387
- 日志级别(log)可在所有模式下灵活调整,便于运维和排查。
351388

352389
## 环境变量

0 commit comments

Comments
 (0)