Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ nodepass "server://:10101/127.0.0.1:8080?log=debug&tls=1"

**Client Mode**
```bash
nodepass client://server.example.com:10101/127.0.0.1:8080
nodepass "client://server:10101/127.0.0.1:8080?min=128"
```

**Master Mode (API)**
Expand All @@ -83,6 +83,8 @@ The [NodePassProject](https://github.com/NodePassProject) organization develops

- **[NodePassDash](https://github.com/NodePassProject/NodePassDash)**: A modern NodePass management interface that provides master management, instance management, traffic statistics, history records, and more.

- **[NodePanel](https://github.com/NodePassProject/NodePanel)**: A lightweight frontend panel that provides visual tunnel management, deployable on Vercel or Cloudflare Pages.

- **[npsh](https://github.com/NodePassProject/npsh)**: A convenient script that provides simple and easy-to-use installation, configuration, and management functionality for NodePass master API mode.

## 💬 Discussion
Expand Down
8 changes: 5 additions & 3 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ nodepass "server://:10101/127.0.0.1:8080?log=debug&tls=1"

**客户端模式**
```bash
nodepass client://server.example.com:10101/127.0.0.1:8080
nodepass "client://server:10101/127.0.0.1:8080?min=128"
```

**主控模式 (API)**
Expand All @@ -81,9 +81,11 @@ nodepass "master://:10101/api?log=debug&tls=1"

[NodePassProject](https://github.com/NodePassProject) 组织开发了各种前端应用和辅助工具来增强 NodePass 体验:

- **[NodePassDash](https://github.com/NodePassProject/NodePassDash)**: 一个现代化的 NodePass 管理界面,提供主控管理、实例管理、流量统计、历史记录等功能。
- **[NodePassDash](https://github.com/NodePassProject/NodePassDash)**: 现代化的 NodePass 管理界面,提供主控管理、实例管理、流量统计、历史记录等功能。

- **[npsh](https://github.com/NodePassProject/npsh)**: 一个便捷的脚本,为 NodePass master API 模式提供简单易用的安装、配置和管理功能。
- **[NodePanel](https://github.com/NodePassProject/NodePanel)**: 轻量化的前端面板,提供可视化的隧道管理功能,在 Vercel 或 Cloudflare Pages 轻松部署。

- **[npsh](https://github.com/NodePassProject/npsh)**: 便捷的一键脚本,为 NodePass master API 模式提供简单易用的安装、配置和管理功能。

## 💬 讨论

Expand Down
57 changes: 40 additions & 17 deletions docs/en/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,39 +46,50 @@ Example with TLS Mode 2 (custom certificate):
nodepass server://0.0.0.0:10101/0.0.0.0:8080?tls=2&crt=/path/to/cert.pem&key=/path/to/key.pem
```

## Connection Pool Capacity Parameters

Connection pool capacity can be configured via URL query parameters:

- `min`: Minimum connection pool capacity (default: 64)
- `max`: Maximum connection pool capacity (default: 8192)

Example:
```bash
# Set minimum pool to 32 and maximum to 4096
nodepass client://server.example.com:10101/127.0.0.1:8080?min=32&max=4096
```

## Environment Variables

NodePass behavior can be fine-tuned using environment variables. Below is the complete list of available variables with their descriptions, default values, and recommended settings for different scenarios.

| Variable | Description | Default | Example |
|----------|-------------|---------|---------|
| `NP_SEMAPHORE_LIMIT` | Maximum number of concurrent connections | 1024 | `export NP_SEMAPHORE_LIMIT=2048` |
| `NP_MIN_POOL_CAPACITY` | Minimum connection pool size | 16 | `export NP_MIN_POOL_CAPACITY=32` |
| `NP_MAX_POOL_CAPACITY` | Maximum connection pool size | 1024 | `export NP_MAX_POOL_CAPACITY=4096` |
| `NP_UDP_DATA_BUF_SIZE` | Buffer size for UDP packets | 8192 | `export NP_UDP_DATA_BUF_SIZE=16384` |
| `NP_UDP_READ_TIMEOUT` | Timeout for UDP read operations | 15s | `export NP_UDP_READ_TIMEOUT=30s` |
| `NP_TCP_READ_TIMEOUT` | Timeout for TCP read operations | 15s | `export NP_TCP_READ_TIMEOUT=30s` |
| `NP_UDP_DIAL_TIMEOUT` | Timeout for establishing UDP connections | 15s | `export NP_UDP_DIAL_TIMEOUT=30s` |
| `NP_TCP_DIAL_TIMEOUT` | Timeout for establishing TCP connections | 15s | `export NP_TCP_DIAL_TIMEOUT=30s` |
| `NP_UDP_READ_TIMEOUT` | Timeout for UDP read operations | 10s | `export NP_UDP_READ_TIMEOUT=30s` |
| `NP_UDP_DIAL_TIMEOUT` | Timeout for establishing UDP connections | 10s | `export NP_UDP_DIAL_TIMEOUT=30s` |
| `NP_TCP_READ_TIMEOUT` | Timeout for TCP read operations | 10s | `export NP_TCP_READ_TIMEOUT=30s` |
| `NP_TCP_DIAL_TIMEOUT` | Timeout for establishing TCP connections | 10s | `export NP_TCP_DIAL_TIMEOUT=30s` |
| `NP_MIN_POOL_INTERVAL` | Minimum interval between connection creations | 1s | `export NP_MIN_POOL_INTERVAL=500ms` |
| `NP_MAX_POOL_INTERVAL` | Maximum interval between connection creations | 5s | `export NP_MAX_POOL_INTERVAL=3s` |
| `NP_REPORT_INTERVAL` | Interval for health check reports | 5s | `export NP_REPORT_INTERVAL=10s` |
| `NP_SERVICE_COOLDOWN` | Cooldown period before restart attempts | 5s | `export NP_SERVICE_COOLDOWN=3s` |
| `NP_SERVICE_COOLDOWN` | Cooldown period before restart attempts | 3s | `export NP_SERVICE_COOLDOWN=5s` |
| `NP_SHUTDOWN_TIMEOUT` | Timeout for graceful shutdown | 5s | `export NP_SHUTDOWN_TIMEOUT=10s` |
| `NP_RELOAD_INTERVAL` | Interval for cert/pool reload | 1h | `export NP_RELOAD_INTERVAL=30m` |

### Connection Pool Tuning

The connection pool parameters are among the most important settings for performance tuning:
The connection pool parameters are important settings for performance tuning:

#### Pool Capacity Settings

- `NP_MIN_POOL_CAPACITY`: Ensures a minimum number of available connections
- `min` (URL parameter): Ensures a minimum number of available connections
- Too low: Increased latency during traffic spikes as new connections must be established
- Too high: Wasted resources maintaining idle connections
- Recommended starting point: 25-50% of your average concurrent connections

- `NP_MAX_POOL_CAPACITY`: Prevents excessive resource consumption while handling peak loads
- `max` (URL parameter): Prevents excessive resource consumption while handling peak loads
- Too low: Connection failures during traffic spikes
- Too high: Potential resource exhaustion affecting system stability
- Recommended starting point: 150-200% of your peak concurrent connections
Expand Down Expand Up @@ -157,9 +168,13 @@ Here are some recommended environment variable configurations for common scenari

For applications requiring maximum throughput (e.g., media streaming, file transfers):

URL parameters:
```bash
nodepass client://server.example.com:10101/127.0.0.1:8080?min=128&max=8192
```

Environment variables:
```bash
export NP_MIN_POOL_CAPACITY=64
export NP_MAX_POOL_CAPACITY=4096
export NP_MIN_POOL_INTERVAL=500ms
export NP_MAX_POOL_INTERVAL=3s
export NP_SEMAPHORE_LIMIT=8192
Expand All @@ -171,23 +186,31 @@ export NP_REPORT_INTERVAL=10s

For applications requiring minimal latency (e.g., gaming, financial trading):

URL parameters:
```bash
nodepass client://server.example.com:10101/127.0.0.1:8080?min=256&max=4096
```

Environment variables:
```bash
export NP_MIN_POOL_CAPACITY=128
export NP_MAX_POOL_CAPACITY=2048
export NP_MIN_POOL_INTERVAL=100ms
export NP_MAX_POOL_INTERVAL=1s
export NP_SEMAPHORE_LIMIT=4096
export NP_UDP_READ_TIMEOUT=10s
export NP_UDP_READ_TIMEOUT=5s
export NP_REPORT_INTERVAL=1s
```

### Resource-Constrained Configuration

For deployment on systems with limited resources (e.g., IoT devices, small VPS):

URL parameters:
```bash
nodepass client://server.example.com:10101/127.0.0.1:8080?min=16&max=512
```

Environment variables:
```bash
export NP_MIN_POOL_CAPACITY=8
export NP_MAX_POOL_CAPACITY=256
export NP_MIN_POOL_INTERVAL=2s
export NP_MAX_POOL_INTERVAL=10s
export NP_SEMAPHORE_LIMIT=512
Expand Down
46 changes: 27 additions & 19 deletions docs/en/usage.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
# Usage Instructions

NodePass creates tunnels with an unencrypted TCP control channel and configurable TLS #### Examples

```bash
# Client single-end forwarding mode - Local proxy listening on port 1080, forwarding to target server
nodepass client://127.0.0.1:1080/target.example.com:8080?log=debug

# Connect to NodePass server and automatically adopt its TLS security policy - Client sends mode
nodepass client://server.example.com:10101/127.0.0.1:8080

# Connect with debug logging - Client receives mode
nodepass client://server.example.com:10101/192.168.1.100:8080?log=debug
```n options for data exchange. This guide covers the three operating modes and explains how to use each effectively.
NodePass creates tunnels with an unencrypted TCP control channel and configurable TLS encryption options for data exchange. This guide covers the three operating modes and explains how to use each effectively.

## Command Line Syntax

The general syntax for NodePass commands is:

```bash
nodepass <core>://<tunnel_addr>/<target_addr>?log=<level>&tls=<mode>&crt=<cert_file>&key=<key_file>
nodepass <core>://<tunnel_addr>/<target_addr>?log=<level>&tls=<mode>&crt=<cert_file>&key=<key_file>&min=<min_pool>&max=<max_pool>
```

Where:
- `<core>`: Specifies the operating mode (`server`, `client`, or `master`)
- `<tunnel_addr>`: The tunnel endpoint address for control channel communications
- `<target_addr>`: The destination address for business data with bidirectional flow support (or API prefix in master mode)
- `<level>`: Log verbosity level (`debug`, `info`, `warn`, `error`, or `event`)
- `<mode>`: TLS security level for data channels (`0`, `1`, or `2`) - server/master modes only
- `<cert_file>`: Path to certificate file (when `tls=2`) - server/master modes only
- `<key_file>`: Path to private key file (when `tls=2`) - server/master modes only

### Query Parameters

Common query parameters:
- `log=<level>`: Log verbosity level (`debug`, `info`, `warn`, `error`, or `event`)
- `min=<min_pool>`: Minimum connection pool capacity (default: 64, client mode only)
- `max=<max_pool>`: Maximum connection pool capacity (default: 8192, client mode only)

TLS-related parameters (server/master modes only):
- `tls=<mode>`: TLS security level for data channels (`0`, `1`, or `2`)
- `crt=<cert_file>`: Path to certificate file (when `tls=2`)
- `key=<key_file>`: Path to private key file (when `tls=2`)

## Operating Modes

Expand Down Expand Up @@ -87,14 +84,16 @@ nodepass "server://10.1.0.1:10101/10.1.0.1:8080?log=debug&tls=2&crt=/path/to/cer
Client mode connects to a NodePass server and supports bidirectional data flow forwarding.

```bash
nodepass client://<tunnel_addr>/<target_addr>?log=<level>
nodepass client://<tunnel_addr>/<target_addr>?log=<level>&min=<min_pool>&max=<max_pool>
```

#### Parameters

- `tunnel_addr`: Address of the NodePass server's tunnel endpoint to connect to (e.g., 10.1.0.1:10101)
- `target_addr`: The destination address for business data with bidirectional flow support (e.g., 127.0.0.1:8080)
- `log`: Log level (debug, info, warn, error, event)
- `min`: Minimum connection pool capacity (default: 64)
- `max`: Maximum connection pool capacity (default: 8192)

#### How Client Mode Works

Expand All @@ -121,11 +120,20 @@ In client mode, NodePass supports three operating modes:
#### Examples

```bash
# Connect to a NodePass server and automatically adopt its TLS security policy - Client sends mode
# Client single-end forwarding mode - Local proxy listening on port 1080, forwarding to target server
nodepass client://127.0.0.1:1080/target.example.com:8080?log=debug

# Connect to a NodePass server and adopt its TLS security policy - Client sends mode
nodepass client://server.example.com:10101/127.0.0.1:8080

# Connect with debug logging - Client receives mode
nodepass client://server.example.com:10101/192.168.1.100:8080?log=debug

# Custom connection pool capacity - High performance configuration
nodepass client://server.example.com:10101/127.0.0.1:8080?min=128&max=4096

# Resource-constrained configuration - Small connection pool
nodepass client://server.example.com:10101/127.0.0.1:8080?min=16&max=512&log=info
```

### Master Mode (API)
Expand Down
59 changes: 41 additions & 18 deletions docs/zh/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,39 +46,50 @@ TLS模式2示例(自定义证书):
nodepass server://0.0.0.0:10101/0.0.0.0:8080?tls=2&crt=/path/to/cert.pem&key=/path/to/key.pem
```

## 连接池容量参数

连接池容量可以通过URL查询参数进行配置:

- `min`: 最小连接池容量(默认: 64)
- `max`: 最大连接池容量(默认: 8192)

示例:
```bash
# 设置最小连接池为32,最大为4096
nodepass client://server.example.com:10101/127.0.0.1:8080?min=32&max=4096
```

## 环境变量

可以使用环境变量微调NodePass行为。以下是所有可用变量的完整列表,包括其描述、默认值以及不同场景的推荐设置。

| 变量 | 描述 | 默认值 | 示例 |
|----------|-------------|---------|---------|
| `NP_SEMAPHORE_LIMIT` | 最大并发连接数 | 1024 | `export NP_SEMAPHORE_LIMIT=2048` |
| `NP_MIN_POOL_CAPACITY` | 最小连接池大小 | 16 | `export NP_MIN_POOL_CAPACITY=32` |
| `NP_MAX_POOL_CAPACITY` | 最大连接池大小 | 1024 | `export NP_MAX_POOL_CAPACITY=4096` |
| `NP_UDP_DATA_BUF_SIZE` | UDP数据包缓冲区大小 | 8192 | `export NP_UDP_DATA_BUF_SIZE=16384` |
| `NP_UDP_READ_TIMEOUT` | UDP读取操作超时 | 15s | `export NP_UDP_READ_TIMEOUT=30s` |
| `NP_TCP_READ_TIMEOUT` | TCP读取操作超时 | 15s | `export NP_TCP_READ_TIMEOUT=30s` |
| `NP_UDP_DIAL_TIMEOUT` | UDP拨号超时 | 15s | `export NP_UDP_DIAL_TIMEOUT=30s` |
| `NP_TCP_DIAL_TIMEOUT` | TCP拨号超时 | 15s | `export NP_TCP_DIAL_TIMEOUT=30s` |
| `NP_UDP_READ_TIMEOUT` | UDP读取操作超时 | 10s | `export NP_UDP_READ_TIMEOUT=30s` |
| `NP_UDP_DIAL_TIMEOUT` | UDP连接建立超时 | 10s | `export NP_UDP_DIAL_TIMEOUT=30s` |
| `NP_TCP_READ_TIMEOUT` | TCP读取操作超时 | 10s | `export NP_TCP_READ_TIMEOUT=30s` |
| `NP_TCP_DIAL_TIMEOUT` | TCP连接建立超时 | 10s | `export NP_TCP_DIAL_TIMEOUT=30s` |
| `NP_MIN_POOL_INTERVAL` | 连接创建之间的最小间隔 | 1s | `export NP_MIN_POOL_INTERVAL=500ms` |
| `NP_MAX_POOL_INTERVAL` | 连接创建之间的最大间隔 | 5s | `export NP_MAX_POOL_INTERVAL=3s` |
| `NP_REPORT_INTERVAL` | 健康检查报告间隔 | 5s | `export NP_REPORT_INTERVAL=10s` |
| `NP_SERVICE_COOLDOWN` | 重启尝试前的冷却期 | 5s | `export NP_SERVICE_COOLDOWN=3s` |
| `NP_SERVICE_COOLDOWN` | 重启尝试前的冷却期 | 3s | `export NP_SERVICE_COOLDOWN=5s` |
| `NP_SHUTDOWN_TIMEOUT` | 优雅关闭超时 | 5s | `export NP_SHUTDOWN_TIMEOUT=10s` |
| `NP_RELOAD_INTERVAL` | 证书/连接池重载间隔 | 1h | `export NP_RELOAD_INTERVAL=30m` |

### 连接池调优

连接池参数是性能调优中最重要的设置之一
连接池参数是性能调优中的重要设置

#### 池容量设置

- `NP_MIN_POOL_CAPACITY`:确保最小可用连接数
- 太低:流量高峰期延迟增加,因为必须建立新连接
- `min` (URL参数):确保最小可用连接数
- 太低:流量高峰期延迟增加,因为必须建立新连接
- 太高:维护空闲连接浪费资源
- 推荐起点:平均并发连接的25-50%

- `NP_MAX_POOL_CAPACITY`:防止过度资源消耗,同时处理峰值负载
- `max` (URL参数):防止过度资源消耗,同时处理峰值负载
- 太低:流量高峰期连接失败
- 太高:潜在资源耗尽影响系统稳定性
- 推荐起点:峰值并发连接的150-200%
Expand Down Expand Up @@ -157,9 +168,13 @@ nodepass server://0.0.0.0:10101/0.0.0.0:8080?tls=2&crt=/path/to/cert.pem&key=/pa

对于需要最大吞吐量的应用(如媒体流、文件传输):

URL参数:
```bash
nodepass client://server.example.com:10101/127.0.0.1:8080?min=128&max=8192
```

环境变量:
```bash
export NP_MIN_POOL_CAPACITY=64
export NP_MAX_POOL_CAPACITY=4096
export NP_MIN_POOL_INTERVAL=500ms
export NP_MAX_POOL_INTERVAL=3s
export NP_SEMAPHORE_LIMIT=8192
Expand All @@ -171,23 +186,31 @@ export NP_REPORT_INTERVAL=10s

对于需要最小延迟的应用(如游戏、金融交易):

URL参数:
```bash
nodepass client://server.example.com:10101/127.0.0.1:8080?min=256&max=4096
```

环境变量:
```bash
export NP_MIN_POOL_CAPACITY=128
export NP_MAX_POOL_CAPACITY=2048
export NP_MIN_POOL_INTERVAL=100ms
export NP_MAX_POOL_INTERVAL=1s
export NP_SEMAPHORE_LIMIT=4096
export NP_UDP_READ_TIMEOUT=10s
export NP_UDP_READ_TIMEOUT=5s
export NP_REPORT_INTERVAL=1s
```

### 资源受限配置

对于在资源有限系统上的部署(如IoT设备、小型VPS):

URL参数:
```bash
nodepass client://server.example.com:10101/127.0.0.1:8080?min=16&max=512
```

环境变量:
```bash
export NP_MIN_POOL_CAPACITY=8
export NP_MAX_POOL_CAPACITY=256
export NP_MIN_POOL_INTERVAL=2s
export NP_MAX_POOL_INTERVAL=10s
export NP_SEMAPHORE_LIMIT=512
Expand Down
Loading