Skip to content

Commit 784a6ae

Browse files
committed
feat: update config merger
1 parent 326136a commit 784a6ae

2 files changed

Lines changed: 24 additions & 12 deletions

File tree

ai-docs/frp-config-list.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
基于 frp 官方文档(https://gofrp.org/zh-cn/docs/reference/)整理的客户端和服务端配置类型。
44

5+
**重要提示**: 本文档适用于 frp v0.52.0+ 版本。在该版本中,配置文件格式从 INI 改为 TOML,部分配置项的位置和命名有所调整。
6+
7+
## 配置格式变更说明 (v0.52.0+)
8+
9+
在 frp v0.52.0 及更高版本中:
10+
- 配置文件格式从 INI 改为 TOML
11+
- 传输层配置(如 `heartbeatInterval``heartbeatTimeout` 等)需要嵌套在 `[transport]` 配置块下
12+
- 鉴权配置需要嵌套在 `[auth]` 配置块下
13+
- Dashboard 配置需要嵌套在 `[webServer]` 配置块下
14+
515
## 1. 通用配置 (Common)
616
> 文件: `src/types/common.ts`
717
@@ -98,12 +108,14 @@
98108

99109
### 2.4 ServerTransportConfig
100110
- **tcpMuxKeepaliveInterval**: int - tcp mux 的心跳检查间隔时间
101-
- **tcpKeepalive**: int - 和客户端底层 TCP 连接的 keepalive 间隔时间
111+
- **tcpKeepalive**: int - 和客户端底层 TCP 连接的 keepalive 间隔时间,单位秒
102112
- **maxPoolCount**: int - 允许客户端设置的最大连接池大小
103-
- **heartbeatTimeout**: int - 服务端和客户端心跳连接的超时时间
113+
- **heartbeatTimeout**: int - 服务端和客户端心跳连接的超时时间,默认为 90s
104114
- **quic**: QUICOptions - QUIC 协议配置参数
105115
- **tls**: TLSServerConfig - 服务端 TLS 协议配置
106116

117+
**注意**: 在 frp v0.52.0+ 版本中,配置文件格式已更新。传输层配置需要嵌套在 `[transport]` 配置块下。
118+
107119
### 2.5 TLSServerConfig
108120
- **force**: bool - 是否只接受启用了 TLS 的客户端连接
109121
- **TLSConfig** - TLS 协议配置,内嵌结构
@@ -146,17 +158,17 @@
146158
- **includes**: []string - 指定额外的配置文件目录
147159

148160
### 3.3 ClientTransportConfig
149-
- **protocol**: string - 和 frps 之间的通信协议
150-
- **dialServerTimeout**: int - 连接服务端的超时时间
151-
- **dialServerKeepalive**: int - 和服务端底层 TCP 连接的 keepalive 间隔时间
161+
- **protocol**: string - 和 frps 之间的通信协议,可选值为 tcp, kcp, quic, websocket, wss
162+
- **dialServerTimeout**: int - 连接服务端的超时时间,默认为 10s
163+
- **dialServerKeepalive**: int - 和服务端底层 TCP 连接的 keepalive 间隔时间,单位秒
152164
- **connectServerLocalIP**: string - 连接服务端时所绑定的本地 IP
153-
- **proxyURL**: string - 连接服务端使用的代理地址
165+
- **proxyURL**: string - 连接服务端使用的代理地址,格式为 {protocol}://user:passwd@192.168.1.128:8080
154166
- **poolCount**: int - 连接池大小
155-
- **tcpMux**: bool - TCP 多路复用
167+
- **tcpMux**: bool - TCP 多路复用,默认启用
156168
- **tcpMuxKeepaliveInterval**: int - tcp_mux 的心跳检查间隔时间
157169
- **quic**: QUICOptions - QUIC 协议配置参数
158-
- **heartbeatInterval**: int - 向服务端发送心跳包的间隔时间
159-
- **heartbeatTimeout**: int - 和服务端心跳的超时时间
170+
- **heartbeatInterval**: int - 向服务端发送心跳包的间隔时间,默认为 30s。建议启用 tcp_mux_keepalive_interval,将此值设置为 -1
171+
- **heartbeatTimeout**: int - 和服务端心跳的超时时间,默认为 90s
160172
- **tls**: TLSClientConfig - 客户端 TLS 协议配置
161173

162174
### 3.4 TLSClientConfig

packages/core/src/config-merger.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ export interface FrpsPresetConfig {
3232
subdomainHost?: string
3333
}
3434

35+
/**
36+
* frpc 预设配置
37+
*/
3538
export interface FrpcPresetConfig {
3639
serverAddr?: string
3740
serverPort?: number
3841
authToken?: string
3942
user?: string
40-
heartbeatInterval?: number
4143
}
4244

4345
/**
@@ -115,8 +117,6 @@ export function mergeConfigs(
115117
baseConfig.serverPort = frpcConfig.serverPort
116118
if (frpcConfig.user)
117119
baseConfig.user = frpcConfig.user
118-
if (frpcConfig.heartbeatInterval)
119-
baseConfig.heartbeatInterval = frpcConfig.heartbeatInterval
120120

121121
// Auth token (nested)
122122
if (frpcConfig.authToken) {

0 commit comments

Comments
 (0)