@frp-bridge/types 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +510 -530
- package/dist/index.js +1 -0
- package/package.json +3 -3
- package/dist/index.d.mts +0 -754
- package/dist/index.mjs +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/common.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* FRP 通用配置类型定义
|
|
3
4
|
* 基于 frp 官方文档: https://gofrp.org/zh-cn/docs/reference/common/
|
|
@@ -6,368 +7,360 @@
|
|
|
6
7
|
type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error';
|
|
7
8
|
/** 日志配置 */
|
|
8
9
|
interface LogConfig {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
/** 日志输出文件路径,如果为 console,则会将日志打印在标准输出中 */
|
|
11
|
+
to?: string;
|
|
12
|
+
/** 日志级别,可选值为 trace, debug, info, warn, error,默认级别为 info */
|
|
13
|
+
level?: LogLevel;
|
|
14
|
+
/** 日志文件最多保留天数,默认为 3 天 */
|
|
15
|
+
maxDays?: number;
|
|
16
|
+
/** 禁用标准输出中的日志颜色 */
|
|
17
|
+
disablePrintColor?: boolean;
|
|
17
18
|
}
|
|
18
19
|
/** TLS 配置 */
|
|
19
20
|
interface TLSConfig {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
/** TLS 证书文件路径 */
|
|
22
|
+
certFile: string;
|
|
23
|
+
/** TLS 密钥文件路径 */
|
|
24
|
+
keyFile: string;
|
|
25
|
+
/** CA 证书文件路径 */
|
|
26
|
+
trustedCaFile?: string;
|
|
27
|
+
/** TLS Server 名称 */
|
|
28
|
+
serverName?: string;
|
|
28
29
|
}
|
|
29
30
|
/** Web 服务器配置 */
|
|
30
31
|
interface WebServerConfig {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
32
|
+
/** webServer 监听地址,默认为 127.0.0.1 */
|
|
33
|
+
addr?: string;
|
|
34
|
+
/** webServer 监听端口 */
|
|
35
|
+
port: number;
|
|
36
|
+
/** HTTP BasicAuth 用户名 */
|
|
37
|
+
user?: string;
|
|
38
|
+
/** HTTP BasicAuth 密码 */
|
|
39
|
+
password?: string;
|
|
40
|
+
/** 静态资源目录,Dashboard 使用的资源默认打包在二进制文件中,通过指定此参数使用自定义的静态资源 */
|
|
41
|
+
assetsDir?: string;
|
|
42
|
+
/** 启动 Go HTTP pprof,用于应用调试 */
|
|
43
|
+
pprofEnable?: boolean;
|
|
44
|
+
/** Dashboard 启用 HTTPS 的 TLS 相关配置 */
|
|
45
|
+
tls?: TLSConfig;
|
|
45
46
|
}
|
|
46
47
|
/** QUIC 协议选项 */
|
|
47
48
|
interface QUICOptions {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
/** 保活周期,默认值为 10 秒 */
|
|
50
|
+
keepalivePeriod?: number;
|
|
51
|
+
/** 最大空闲超时时间,默认值为 30 秒 */
|
|
52
|
+
maxIdleTimeout?: number;
|
|
53
|
+
/** 最大传入流数量,默认值为 100000 */
|
|
54
|
+
maxIncomingStreams?: number;
|
|
54
55
|
}
|
|
55
56
|
/** 端口范围配置 */
|
|
56
57
|
interface PortsRange {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
/** 起始端口 */
|
|
59
|
+
start?: number;
|
|
60
|
+
/** 终止端口 */
|
|
61
|
+
end?: number;
|
|
62
|
+
/** 单一端口 */
|
|
63
|
+
single?: number;
|
|
63
64
|
}
|
|
64
65
|
/** HTTP 头部操作配置 */
|
|
65
66
|
interface HeaderOperations {
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
/** 在 Header 中设置指定的 KV 值 */
|
|
68
|
+
set?: Record<string, string>;
|
|
68
69
|
}
|
|
69
70
|
/** HTTP 头部配置 */
|
|
70
71
|
interface HTTPHeader {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
/** Header 名称 */
|
|
73
|
+
name: string;
|
|
74
|
+
/** Header 值 */
|
|
75
|
+
value: string;
|
|
75
76
|
}
|
|
76
77
|
/** 文件数据源配置 */
|
|
77
78
|
interface FileSource {
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
/** 文件路径 */
|
|
80
|
+
path: string;
|
|
80
81
|
}
|
|
81
82
|
/** 数据源类型 */
|
|
82
83
|
type ValueSourceType = 'file';
|
|
83
84
|
/** 值数据源配置 */
|
|
84
85
|
interface ValueSource {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
/** 数据源类型,目前仅支持 "file" */
|
|
87
|
+
type: ValueSourceType;
|
|
88
|
+
/** 文件数据源配置,当 type 为 "file" 时必填 */
|
|
89
|
+
file?: FileSource;
|
|
89
90
|
}
|
|
90
91
|
/** NAT 穿透配置 */
|
|
91
92
|
interface NatTraversalConfig {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
* FRP 服务端配置类型定义
|
|
101
|
-
* 基于 frp 官方文档: https://gofrp.org/zh-cn/docs/reference/server-configures/
|
|
102
|
-
*/
|
|
103
|
-
|
|
93
|
+
/**
|
|
94
|
+
* 禁用本地网络接口地址的辅助连接。当启用时,仅使用通过 STUN 发现的公网地址进行 NAT 打洞,
|
|
95
|
+
* 避免使用可能较慢的本地网络接口(如 VPN)。默认为 false
|
|
96
|
+
*/
|
|
97
|
+
disableAssistedAddrs?: boolean;
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/server.d.ts
|
|
104
101
|
/** 鉴权方式类型 */
|
|
105
102
|
type AuthMethod = 'token' | 'oidc';
|
|
106
103
|
/** 鉴权信息附加范围类型 */
|
|
107
104
|
type AuthScope = 'HeartBeats' | 'NewWorkConns';
|
|
108
105
|
/** OIDC 服务端鉴权配置 */
|
|
109
106
|
interface AuthOIDCServerConfig {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
107
|
+
/** OIDC 发行者 */
|
|
108
|
+
issuer?: string;
|
|
109
|
+
/** OIDC 受众 */
|
|
110
|
+
audience?: string;
|
|
111
|
+
/** 跳过过期检查 */
|
|
112
|
+
skipExpiryCheck?: boolean;
|
|
113
|
+
/** 跳过发行者检查 */
|
|
114
|
+
skipIssuerCheck?: boolean;
|
|
118
115
|
}
|
|
119
116
|
/** 服务端鉴权配置 */
|
|
120
117
|
interface AuthServerConfig {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
118
|
+
/** 鉴权方式,可选值为 token 或 oidc,默认为 token */
|
|
119
|
+
method?: AuthMethod;
|
|
120
|
+
/** 鉴权信息附加范围,可选值为 HeartBeats 和 NewWorkConns */
|
|
121
|
+
additionalScopes?: AuthScope[];
|
|
122
|
+
/** 在 method 为 token 时生效,客户端需要设置一样的值才能鉴权通过。与 tokenSource 字段互斥 */
|
|
123
|
+
token?: string;
|
|
124
|
+
/** 从文件中加载 token 的配置。与 token 字段互斥 */
|
|
125
|
+
tokenSource?: ValueSource;
|
|
126
|
+
/** oidc 鉴权配置 */
|
|
127
|
+
oidc?: AuthOIDCServerConfig;
|
|
131
128
|
}
|
|
132
129
|
/** 服务端 TLS 配置 */
|
|
133
130
|
interface TLSServerConfig extends TLSConfig {
|
|
134
|
-
|
|
135
|
-
|
|
131
|
+
/** 是否只接受启用了 TLS 的客户端连接 */
|
|
132
|
+
force?: boolean;
|
|
136
133
|
}
|
|
137
134
|
/** 服务端传输层配置 */
|
|
138
135
|
interface ServerTransportConfig {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
136
|
+
/** tcp mux 的心跳检查间隔时间,单位秒 */
|
|
137
|
+
tcpMuxKeepaliveInterval?: number;
|
|
138
|
+
/** 和客户端底层 TCP 连接的 keepalive 间隔时间,单位秒,配置为负数表示不启用 */
|
|
139
|
+
tcpKeepalive?: number;
|
|
140
|
+
/** 允许客户端设置的最大连接池大小,如果客户端配置的值大于此值,会被强制修改为最大值,默认为 5 */
|
|
141
|
+
maxPoolCount?: number;
|
|
142
|
+
/** 服务端和客户端心跳连接的超时时间,单位秒,默认为 90 秒 */
|
|
143
|
+
heartbeatTimeout?: number;
|
|
144
|
+
/** QUIC 协议配置参数 */
|
|
145
|
+
quic?: QUICOptions;
|
|
146
|
+
/** 服务端 TLS 协议配置 */
|
|
147
|
+
tls?: TLSServerConfig;
|
|
151
148
|
}
|
|
152
149
|
/** HTTP 插件选项 */
|
|
153
150
|
interface HTTPPluginOptions {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
151
|
+
/** 插件名称 */
|
|
152
|
+
name: string;
|
|
153
|
+
/** 插件接口的地址 */
|
|
154
|
+
addr: string;
|
|
155
|
+
/** 插件接口的 Path */
|
|
156
|
+
path: string;
|
|
157
|
+
/** 插件需要生效的操作列表,具体可选值请参考服务端插件的说明文档 */
|
|
158
|
+
ops: string[];
|
|
159
|
+
/** 当插件地址为 HTTPS 协议时,是否校验插件的 TLS 证书,默认为不校验 */
|
|
160
|
+
tlsVerify?: boolean;
|
|
164
161
|
}
|
|
165
162
|
/** SSH 隧道网关配置 */
|
|
166
163
|
interface SSHTunnelGateway {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
164
|
+
/** SSH 服务器监听端口 */
|
|
165
|
+
bindPort: number;
|
|
166
|
+
/** SSH 服务器私钥文件路径。若为空,frps将读取autoGenPrivateKeyPath路径下的私钥文件 */
|
|
167
|
+
privateKeyFile?: string;
|
|
168
|
+
/** 私钥文件自动生成路径,默认为./.autogen_ssh_key。若文件不存在或内容为空,frps将自动生成RSA私钥文件并存储到该路径 */
|
|
169
|
+
autoGenPrivateKeyPath?: string;
|
|
170
|
+
/** SSH 客户端授权密钥文件路径。若为空,则不进行SSH客户端鉴权认证。非空可实现SSH免密登录认证 */
|
|
171
|
+
authorizedKeysFile?: string;
|
|
175
172
|
}
|
|
176
173
|
/** 服务端配置 */
|
|
177
174
|
interface ServerConfig {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
* FRP 客户端配置类型定义
|
|
232
|
-
* 基于 frp 官方文档: https://gofrp.org/zh-cn/docs/reference/client-configures/
|
|
233
|
-
*/
|
|
234
|
-
|
|
175
|
+
/** 鉴权配置 */
|
|
176
|
+
auth?: AuthServerConfig;
|
|
177
|
+
/** 服务端监听地址,用于接收 frpc 的连接,默认监听 0.0.0.0 */
|
|
178
|
+
bindAddr?: string;
|
|
179
|
+
/** 服务端监听端口,默认值为 7000 */
|
|
180
|
+
bindPort?: number;
|
|
181
|
+
/** 服务端监听 KCP 协议端口,用于接收配置了使用 KCP 协议的 frpc 连接 */
|
|
182
|
+
kcpBindPort?: number;
|
|
183
|
+
/** 服务端监听 QUIC 协议端口,用于接收配置了使用 QUIC 协议的 frpc 连接 */
|
|
184
|
+
quicBindPort?: number;
|
|
185
|
+
/** 代理监听地址,可以使代理监听在不同的网卡地址,默认情况下同 bindAddr */
|
|
186
|
+
proxyBindAddr?: string;
|
|
187
|
+
/** HTTP 类型代理监听的端口,启用后才能支持 HTTP 类型的代理 */
|
|
188
|
+
vhostHTTPPort?: number;
|
|
189
|
+
/** HTTP 类型代理在服务端的 ResponseHeader 超时时间,默认为 60s */
|
|
190
|
+
vhostHTTPTimeout?: number;
|
|
191
|
+
/** HTTPS 类型代理监听的端口,启用后才能支持 HTTPS 类型的代理 */
|
|
192
|
+
vhostHTTPSPort?: number;
|
|
193
|
+
/** tcpmux 类型且复用器为 httpconnect 的代理监听的端口 */
|
|
194
|
+
tcpmuxHTTPConnectPort?: number;
|
|
195
|
+
/** 对于 tcpmux 类型的代理是否透传 CONNECT 请求 */
|
|
196
|
+
tcpmuxPassthrough?: boolean;
|
|
197
|
+
/** 二级域名后缀 */
|
|
198
|
+
subDomainHost?: string;
|
|
199
|
+
/** 自定义 404 错误页面地址 */
|
|
200
|
+
custom404Page?: string;
|
|
201
|
+
/** ssh 隧道网关配置 */
|
|
202
|
+
sshTunnelGateway?: SSHTunnelGateway;
|
|
203
|
+
/** 服务端 Dashboard 配置 */
|
|
204
|
+
webServer?: WebServerConfig;
|
|
205
|
+
/** 是否提供 Prometheus 监控接口,需要同时启用了 webServer 后才会生效 */
|
|
206
|
+
enablePrometheus?: boolean;
|
|
207
|
+
/** 日志配置 */
|
|
208
|
+
log?: LogConfig;
|
|
209
|
+
/** 网络层配置 */
|
|
210
|
+
transport?: ServerTransportConfig;
|
|
211
|
+
/** 服务端返回详细错误信息给客户端,默认为 true */
|
|
212
|
+
detailedErrorsToClient?: boolean;
|
|
213
|
+
/** 限制单个客户端最大同时存在的代理数,默认无限制 */
|
|
214
|
+
maxPortsPerClient?: number;
|
|
215
|
+
/** 用户建立连接后等待客户端响应的超时时间,单位秒,默认为 10 秒 */
|
|
216
|
+
userConnTimeout?: number;
|
|
217
|
+
/** 代理 UDP 服务时支持的最大包长度,默认为 1500,服务端和客户端的值需要一致 */
|
|
218
|
+
udpPacketSize?: number;
|
|
219
|
+
/** 打洞策略数据的保留时间,默认为 168 小时,即 7 天 */
|
|
220
|
+
natholeAnalysisDataReserveHours?: number;
|
|
221
|
+
/** 允许代理绑定的服务端端口 */
|
|
222
|
+
allowPorts?: PortsRange[];
|
|
223
|
+
/** 服务端 HTTP 插件配置 */
|
|
224
|
+
httpPlugins?: HTTPPluginOptions[];
|
|
225
|
+
}
|
|
226
|
+
//#endregion
|
|
227
|
+
//#region src/client.d.ts
|
|
235
228
|
/** 客户端传输协议类型 */
|
|
236
229
|
type ClientTransportProtocol = 'tcp' | 'kcp' | 'quic' | 'websocket' | 'wss';
|
|
237
230
|
/** OIDC 客户端鉴权配置 */
|
|
238
231
|
interface AuthOIDCClientConfig {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
232
|
+
/** OIDC 客户端 ID */
|
|
233
|
+
clientID?: string;
|
|
234
|
+
/** OIDC 客户端密钥 */
|
|
235
|
+
clientSecret?: string;
|
|
236
|
+
/** OIDC audience 参数 */
|
|
237
|
+
audience?: string;
|
|
238
|
+
/** OIDC scope 参数 */
|
|
239
|
+
scope?: string;
|
|
240
|
+
/** OIDC 令牌端点 URL */
|
|
241
|
+
tokenEndpointURL?: string;
|
|
242
|
+
/** 附加的端点参数 */
|
|
243
|
+
additionalEndpointParams?: Record<string, string>;
|
|
244
|
+
/** 信任的 CA 证书文件路径,用于验证 OIDC 服务器的 TLS 证书 */
|
|
245
|
+
trustedCaFile?: string;
|
|
246
|
+
/** 跳过 TLS 证书验证,不推荐在生产环境使用 */
|
|
247
|
+
insecureSkipVerify?: boolean;
|
|
248
|
+
/** 访问 OIDC 令牌端点时使用的代理服务器 URL */
|
|
249
|
+
proxyURL?: string;
|
|
257
250
|
}
|
|
258
251
|
/** 客户端鉴权配置 */
|
|
259
252
|
interface AuthClientConfig {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
253
|
+
/** 鉴权方式,可选值为 token 或 oidc,默认为 token */
|
|
254
|
+
method?: AuthMethod;
|
|
255
|
+
/** 鉴权信息附加范围,可选值为 HeartBeats 和 NewWorkConns */
|
|
256
|
+
additionalScopes?: AuthScope[];
|
|
257
|
+
/** 在 method 为 token 时生效,客户端需要设置一样的值才能鉴权通过。与 tokenSource 字段互斥 */
|
|
258
|
+
token?: string;
|
|
259
|
+
/** 从文件中加载 token 的配置。与 token 字段互斥 */
|
|
260
|
+
tokenSource?: ValueSource;
|
|
261
|
+
/** oidc 鉴权配置 */
|
|
262
|
+
oidc?: AuthOIDCClientConfig;
|
|
270
263
|
}
|
|
271
264
|
/** 客户端 TLS 配置 */
|
|
272
265
|
interface TLSClientConfig extends TLSConfig {
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
266
|
+
/** 是否和服务端之间启用 TLS 连接,默认启用 */
|
|
267
|
+
enable?: boolean;
|
|
268
|
+
/** 启用 TLS 连接时,不发送 0x17 特殊字节。默认为 true。当配置为 true 时,无法和 vhostHTTPSPort 端口复用 */
|
|
269
|
+
disableCustomTLSFirstByte?: boolean;
|
|
277
270
|
}
|
|
278
271
|
/** 客户端传输层配置 */
|
|
279
272
|
interface ClientTransportConfig {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
273
|
+
/** 和 frps 之间的通信协议,可选值为 tcp, kcp, quic, websocket, wss。默认为 tcp */
|
|
274
|
+
protocol?: ClientTransportProtocol;
|
|
275
|
+
/** 连接服务端的超时时间,默认为 10s */
|
|
276
|
+
dialServerTimeout?: number;
|
|
277
|
+
/** 和服务端底层 TCP 连接的 keepalive 间隔时间,单位秒 */
|
|
278
|
+
dialServerKeepalive?: number;
|
|
279
|
+
/** 连接服务端时所绑定的本地 IP */
|
|
280
|
+
connectServerLocalIP?: string;
|
|
281
|
+
/** 连接服务端使用的代理地址,格式为 {protocol}://user:passwd@192.168.1.128:8080 protocol 目前支持 http、socks5、ntlm */
|
|
282
|
+
proxyURL?: string;
|
|
283
|
+
/** 连接池大小 */
|
|
284
|
+
poolCount?: number;
|
|
285
|
+
/** TCP 多路复用,默认启用 */
|
|
286
|
+
tcpMux?: boolean;
|
|
287
|
+
/** tcp_mux 的心跳检查间隔时间 */
|
|
288
|
+
tcpMuxKeepaliveInterval?: number;
|
|
289
|
+
/** QUIC 协议配置参数 */
|
|
290
|
+
quic?: QUICOptions;
|
|
291
|
+
/** 向服务端发送心跳包的间隔时间,默认为 30s。建议启用 tcp_mux_keepalive_interval,将此值设置为 -1 */
|
|
292
|
+
heartbeatInterval?: number;
|
|
293
|
+
/** 和服务端心跳的超时时间,默认为 90s */
|
|
294
|
+
heartbeatTimeout?: number;
|
|
295
|
+
/** 客户端 TLS 协议配置 */
|
|
296
|
+
tls?: TLSClientConfig;
|
|
304
297
|
}
|
|
305
298
|
/** 虚拟网络配置 */
|
|
306
299
|
interface VirtualNetConfig {
|
|
307
|
-
|
|
308
|
-
|
|
300
|
+
/** 虚拟网络接口的 IP 地址和网段,格式为 CIDR (例如 "100.86.0.1/24") */
|
|
301
|
+
address: string;
|
|
309
302
|
}
|
|
310
303
|
/** 客户端通用配置 */
|
|
311
304
|
interface ClientCommonConfig {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
305
|
+
/** 客户端鉴权配置 */
|
|
306
|
+
auth?: AuthClientConfig;
|
|
307
|
+
/** 用户名,设置此参数后,代理名称会被修改为 {user}.{proxyName},避免代理名称和其他用户冲突 */
|
|
308
|
+
user?: string;
|
|
309
|
+
/** 连接服务端的地址 */
|
|
310
|
+
serverAddr?: string;
|
|
311
|
+
/** 连接服务端的端口,默认为 7000 */
|
|
312
|
+
serverPort?: number;
|
|
313
|
+
/** xtcp 打洞所需的 stun 服务器地址,默认为 stun.easyvoip.com:3478 */
|
|
314
|
+
natHoleStunServer?: string;
|
|
315
|
+
/** 使用 DNS 服务器地址,默认使用系统配置的 DNS 服务器,指定此参数可以强制替换为自定义的 DNS 服务器地址 */
|
|
316
|
+
dnsServer?: string;
|
|
317
|
+
/** 第一次登陆失败后是否退出,默认为 true */
|
|
318
|
+
loginFailExit?: boolean;
|
|
319
|
+
/** 指定启用部分代理,当配置了较多代理,但是只希望启用其中部分时可以通过此参数指定,默认为全部启用 */
|
|
320
|
+
start?: string[];
|
|
321
|
+
/** 日志配置 */
|
|
322
|
+
log?: LogConfig;
|
|
323
|
+
/** 客户端 AdminServer 配置 */
|
|
324
|
+
webServer?: WebServerConfig;
|
|
325
|
+
/** 客户端网络层配置 */
|
|
326
|
+
transport?: ClientTransportConfig;
|
|
327
|
+
/** 虚拟网络配置,Alpha 特性 */
|
|
328
|
+
virtualNet?: VirtualNetConfig;
|
|
329
|
+
/** 特性门控,用于启用或禁用实验性功能 */
|
|
330
|
+
featureGates?: Record<string, boolean>;
|
|
331
|
+
/** 代理 UDP 服务时支持的最大包长度,默认为 1500,服务端和客户端需要保持配置一致 */
|
|
332
|
+
udpPacketSize?: number;
|
|
333
|
+
/** 附加元数据,会传递给服务端插件,提供附加能力 */
|
|
334
|
+
metadatas?: Record<string, string>;
|
|
335
|
+
/** 指定额外的配置文件目录,其中的 proxy 和 visitor 配置会被读取加载 */
|
|
336
|
+
includes?: string[];
|
|
344
337
|
}
|
|
345
338
|
/** 客户端配置 */
|
|
346
|
-
interface ClientConfig extends ClientCommonConfig {
|
|
347
|
-
|
|
348
|
-
|
|
339
|
+
interface ClientConfig extends ClientCommonConfig {}
|
|
340
|
+
//#endregion
|
|
341
|
+
//#region src/proxy.d.ts
|
|
349
342
|
/**
|
|
350
343
|
* FRP Proxy configuration types
|
|
351
344
|
* Based on: https://gofrp.org/zh-cn/docs/reference/proxy-config/
|
|
352
345
|
*/
|
|
353
346
|
/** Proxy type enum */
|
|
354
347
|
declare enum ProxyType {
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
348
|
+
/** TCP proxy */
|
|
349
|
+
TCP = "tcp",
|
|
350
|
+
/** UDP proxy */
|
|
351
|
+
UDP = "udp",
|
|
352
|
+
/** HTTP proxy */
|
|
353
|
+
HTTP = "http",
|
|
354
|
+
/** HTTPS proxy */
|
|
355
|
+
HTTPS = "https",
|
|
356
|
+
/** TCP multiplexer proxy */
|
|
357
|
+
TCPMUX = "tcpmux",
|
|
358
|
+
/** Secure TCP proxy */
|
|
359
|
+
STCP = "stcp",
|
|
360
|
+
/** XTCP (P2P) proxy */
|
|
361
|
+
XTCP = "xtcp",
|
|
362
|
+
/** Secure UDP proxy */
|
|
363
|
+
SUDP = "sudp"
|
|
371
364
|
}
|
|
372
365
|
/** Proxy type (union type for compatibility) */
|
|
373
366
|
type ProxyTypeUnion = `${ProxyType}`;
|
|
@@ -375,312 +368,300 @@ type ProxyTypeUnion = `${ProxyType}`;
|
|
|
375
368
|
type LoadBalancerStrategy = 'random' | 'round_robin';
|
|
376
369
|
/** Base proxy configuration */
|
|
377
370
|
interface BaseProxyConfig {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
timeoutSeconds?: number;
|
|
400
|
-
/** Max failed checks before marking unhealthy */
|
|
401
|
-
maxFailed?: number;
|
|
402
|
-
/** Check interval (seconds) */
|
|
403
|
-
intervalSeconds?: number;
|
|
404
|
-
/** HTTP health check path */
|
|
405
|
-
path?: string;
|
|
406
|
-
};
|
|
407
|
-
};
|
|
408
|
-
/** Enable bandwidth limit */
|
|
409
|
-
transport?: {
|
|
410
|
-
/** Bandwidth limit (KB/s) */
|
|
411
|
-
bandwidthLimit?: string;
|
|
412
|
-
/** Bandwidth limit mode */
|
|
413
|
-
bandwidthLimitMode?: 'client' | 'server';
|
|
371
|
+
/** Proxy name (unique) */
|
|
372
|
+
name: string;
|
|
373
|
+
/** Proxy type */
|
|
374
|
+
type: ProxyType;
|
|
375
|
+
/** Local IP to bind */
|
|
376
|
+
localIP?: string;
|
|
377
|
+
/** Local port */
|
|
378
|
+
localPort?: number;
|
|
379
|
+
/** Additional metadata */
|
|
380
|
+
annotations?: Record<string, string>;
|
|
381
|
+
/** Custom metadata passed to server plugins */
|
|
382
|
+
metadatas?: Record<string, string>;
|
|
383
|
+
/** Load balancer settings */
|
|
384
|
+
loadBalancer?: {
|
|
385
|
+
/** Load balancing strategy */strategy?: LoadBalancerStrategy; /** Health check configuration */
|
|
386
|
+
healthCheck?: {
|
|
387
|
+
/** Health check type */type?: ProxyType.TCP | ProxyType.HTTP; /** Health check timeout (seconds) */
|
|
388
|
+
timeoutSeconds?: number; /** Max failed checks before marking unhealthy */
|
|
389
|
+
maxFailed?: number; /** Check interval (seconds) */
|
|
390
|
+
intervalSeconds?: number; /** HTTP health check path */
|
|
391
|
+
path?: string;
|
|
414
392
|
};
|
|
393
|
+
};
|
|
394
|
+
/** Enable bandwidth limit */
|
|
395
|
+
transport?: {
|
|
396
|
+
/** Bandwidth limit (KB/s) */bandwidthLimit?: string; /** Bandwidth limit mode */
|
|
397
|
+
bandwidthLimitMode?: 'client' | 'server';
|
|
398
|
+
};
|
|
415
399
|
}
|
|
416
400
|
/** TCP proxy configuration */
|
|
417
401
|
interface TCPProxyConfig extends BaseProxyConfig {
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
402
|
+
type: ProxyType.TCP;
|
|
403
|
+
/** Remote port on server */
|
|
404
|
+
remotePort?: number;
|
|
421
405
|
}
|
|
422
406
|
/** UDP proxy configuration */
|
|
423
407
|
interface UDPProxyConfig extends BaseProxyConfig {
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
408
|
+
type: ProxyType.UDP;
|
|
409
|
+
/** Remote port on server */
|
|
410
|
+
remotePort?: number;
|
|
427
411
|
}
|
|
428
412
|
/** HTTP proxy configuration */
|
|
429
413
|
interface HTTPProxyConfig extends BaseProxyConfig {
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
414
|
+
type: ProxyType.HTTP;
|
|
415
|
+
/** Custom domain names */
|
|
416
|
+
customDomains?: string[];
|
|
417
|
+
/** Subdomain under server's subdomain_host */
|
|
418
|
+
subdomain?: string;
|
|
419
|
+
/** Locations to proxy */
|
|
420
|
+
locations?: string[];
|
|
421
|
+
/** Host header rewrite */
|
|
422
|
+
hostHeaderRewrite?: string;
|
|
423
|
+
/** HTTP username for basic auth */
|
|
424
|
+
httpUser?: string;
|
|
425
|
+
/** HTTP password for basic auth */
|
|
426
|
+
httpPassword?: string;
|
|
427
|
+
/** Request headers to set */
|
|
428
|
+
requestHeaders?: {
|
|
429
|
+
set?: Record<string, string>;
|
|
430
|
+
};
|
|
431
|
+
/** Response headers to set */
|
|
432
|
+
responseHeaders?: {
|
|
433
|
+
set?: Record<string, string>;
|
|
434
|
+
};
|
|
435
|
+
/** Route by HTTP user */
|
|
436
|
+
routeByHTTPUser?: string;
|
|
453
437
|
}
|
|
454
438
|
/** HTTPS proxy configuration */
|
|
455
439
|
interface HTTPSProxyConfig extends BaseProxyConfig {
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
440
|
+
type: ProxyType.HTTPS;
|
|
441
|
+
/** Custom domain names */
|
|
442
|
+
customDomains?: string[];
|
|
443
|
+
/** Subdomain under server's subdomain_host */
|
|
444
|
+
subdomain?: string;
|
|
461
445
|
}
|
|
462
446
|
/** TCPMUX proxy configuration */
|
|
463
447
|
interface TCPMUXProxyConfig extends BaseProxyConfig {
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
448
|
+
type: ProxyType.TCPMUX;
|
|
449
|
+
/** Multiplexer type */
|
|
450
|
+
multiplexer?: 'httpconnect';
|
|
451
|
+
/** Custom domain names */
|
|
452
|
+
customDomains?: string[];
|
|
453
|
+
/** Subdomain under server's subdomain_host */
|
|
454
|
+
subdomain?: string;
|
|
455
|
+
/** Route by HTTP user */
|
|
456
|
+
routeByHTTPUser?: string;
|
|
457
|
+
/** HTTP username */
|
|
458
|
+
httpUser?: string;
|
|
459
|
+
/** HTTP password */
|
|
460
|
+
httpPassword?: string;
|
|
477
461
|
}
|
|
478
462
|
/** STCP proxy configuration */
|
|
479
463
|
interface STCPProxyConfig extends BaseProxyConfig {
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
464
|
+
type: ProxyType.STCP;
|
|
465
|
+
/** Secret key shared with visitor */
|
|
466
|
+
secretKey?: string;
|
|
467
|
+
/** Allowed visitor users */
|
|
468
|
+
allowUsers?: string[];
|
|
485
469
|
}
|
|
486
470
|
/** XTCP proxy configuration */
|
|
487
471
|
interface XTCPProxyConfig extends BaseProxyConfig {
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
472
|
+
type: ProxyType.XTCP;
|
|
473
|
+
/** Secret key shared with visitor */
|
|
474
|
+
secretKey?: string;
|
|
475
|
+
/** Allowed visitor users */
|
|
476
|
+
allowUsers?: string[];
|
|
493
477
|
}
|
|
494
478
|
/** SUDP proxy configuration */
|
|
495
479
|
interface SUDPProxyConfig extends BaseProxyConfig {
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
480
|
+
type: ProxyType.SUDP;
|
|
481
|
+
/** Secret key shared with visitor */
|
|
482
|
+
secretKey?: string;
|
|
483
|
+
/** Allowed visitor users */
|
|
484
|
+
allowUsers?: string[];
|
|
501
485
|
}
|
|
502
486
|
/** Union type of all proxy configurations */
|
|
503
487
|
type ProxyConfig = TCPProxyConfig | UDPProxyConfig | HTTPProxyConfig | HTTPSProxyConfig | TCPMUXProxyConfig | STCPProxyConfig | XTCPProxyConfig | SUDPProxyConfig;
|
|
504
488
|
/** Visitor type enum */
|
|
505
489
|
declare enum VisitorType {
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
490
|
+
/** Secure TCP visitor */
|
|
491
|
+
STCP = "stcp",
|
|
492
|
+
/** XTCP (P2P) visitor */
|
|
493
|
+
XTCP = "xtcp",
|
|
494
|
+
/** Secure UDP visitor */
|
|
495
|
+
SUDP = "sudp"
|
|
512
496
|
}
|
|
513
497
|
/** Visitor type (union type for compatibility) */
|
|
514
498
|
type VisitorTypeUnion = `${VisitorType}`;
|
|
515
499
|
/** Base visitor configuration */
|
|
516
500
|
interface BaseVisitorConfig {
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
501
|
+
/** Visitor name (unique) */
|
|
502
|
+
name: string;
|
|
503
|
+
/** Visitor type */
|
|
504
|
+
type: VisitorType;
|
|
505
|
+
/** Server name to connect to */
|
|
506
|
+
serverName: string;
|
|
507
|
+
/** Secret key shared with proxy */
|
|
508
|
+
secretKey?: string;
|
|
509
|
+
/** Local IP to bind */
|
|
510
|
+
bindAddr?: string;
|
|
511
|
+
/** Local port to bind */
|
|
512
|
+
bindPort?: number;
|
|
529
513
|
}
|
|
530
514
|
/** STCP visitor configuration */
|
|
531
515
|
interface STCPVisitorConfig extends BaseVisitorConfig {
|
|
532
|
-
|
|
516
|
+
type: VisitorType.STCP;
|
|
533
517
|
}
|
|
534
518
|
/** XTCP visitor configuration */
|
|
535
519
|
interface XTCPVisitorConfig extends BaseVisitorConfig {
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
520
|
+
type: VisitorType.XTCP;
|
|
521
|
+
/** Keep tunnel alive even when no connection */
|
|
522
|
+
keepTunnelOpen?: boolean;
|
|
523
|
+
/** Max retries for establishing connection */
|
|
524
|
+
maxRetriesAnHour?: number;
|
|
525
|
+
/** Min retry interval (seconds) */
|
|
526
|
+
minRetryInterval?: number;
|
|
527
|
+
/** Fallback to STCP when XTCP fails */
|
|
528
|
+
fallbackTo?: string;
|
|
529
|
+
/** Fallback timeout (seconds) */
|
|
530
|
+
fallbackTimeoutMs?: number;
|
|
547
531
|
}
|
|
548
532
|
/** SUDP visitor configuration */
|
|
549
533
|
interface SUDPVisitorConfig extends BaseVisitorConfig {
|
|
550
|
-
|
|
534
|
+
type: VisitorType.SUDP;
|
|
551
535
|
}
|
|
552
536
|
/** Union type of all visitor configurations */
|
|
553
537
|
type VisitorConfig = STCPVisitorConfig | XTCPVisitorConfig | SUDPVisitorConfig;
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
* Node management types
|
|
557
|
-
* Defines types for managing frp-bridge client nodes connected to server
|
|
558
|
-
*/
|
|
559
|
-
|
|
538
|
+
//#endregion
|
|
539
|
+
//#region src/node.d.ts
|
|
560
540
|
/** Node information structure */
|
|
561
541
|
interface NodeInfo {
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
542
|
+
id: string;
|
|
543
|
+
ip: string;
|
|
544
|
+
port: number;
|
|
545
|
+
protocol: 'tcp' | 'udp';
|
|
546
|
+
serverAddr: string;
|
|
547
|
+
serverPort: number;
|
|
548
|
+
hostname?: string;
|
|
549
|
+
osType?: string;
|
|
550
|
+
osRelease?: string;
|
|
551
|
+
platform?: string;
|
|
552
|
+
cpuCores?: number;
|
|
553
|
+
memTotal?: number;
|
|
554
|
+
frpVersion?: string;
|
|
555
|
+
bridgeVersion?: string;
|
|
556
|
+
status: 'online' | 'offline' | 'connecting' | 'error';
|
|
557
|
+
lastHeartbeat?: number;
|
|
558
|
+
connectedAt?: number;
|
|
559
|
+
labels?: Record<string, string>;
|
|
560
|
+
metadata?: Record<string, unknown>;
|
|
561
|
+
token?: string;
|
|
562
|
+
tunnels?: ProxyConfig[];
|
|
563
|
+
createdAt: number;
|
|
564
|
+
updatedAt: number;
|
|
585
565
|
}
|
|
586
566
|
/** Payload for node registration (Client → Server) */
|
|
587
567
|
interface NodeRegisterPayload {
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
568
|
+
ip: string;
|
|
569
|
+
port: number;
|
|
570
|
+
serverAddr: string;
|
|
571
|
+
serverPort: number;
|
|
572
|
+
protocol: 'tcp' | 'udp';
|
|
573
|
+
hostname: string;
|
|
574
|
+
osType: string;
|
|
575
|
+
osRelease: string;
|
|
576
|
+
platform: string;
|
|
577
|
+
cpuCores: number;
|
|
578
|
+
memTotal: number;
|
|
579
|
+
frpVersion: string;
|
|
580
|
+
bridgeVersion: string;
|
|
581
|
+
token?: string;
|
|
602
582
|
}
|
|
603
583
|
/** Payload for node heartbeat (Client → Server) */
|
|
604
584
|
interface NodeHeartbeatPayload {
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
585
|
+
nodeId: string;
|
|
586
|
+
status: 'online' | 'error';
|
|
587
|
+
lastHeartbeat: number;
|
|
588
|
+
cpuCores?: number;
|
|
589
|
+
memTotal?: number;
|
|
610
590
|
}
|
|
611
591
|
/** Payload for tunnel synchronization (Client → Server) */
|
|
612
592
|
interface TunnelSyncPayload {
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
593
|
+
nodeId: string;
|
|
594
|
+
tunnels: ProxyConfig[];
|
|
595
|
+
timestamp: number;
|
|
616
596
|
}
|
|
617
597
|
/** Payload for tunnel management via RPC (Server → Client) */
|
|
618
598
|
interface TunnelManagePayload {
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
599
|
+
action: 'add' | 'update' | 'remove' | 'list';
|
|
600
|
+
tunnel?: ProxyConfig | Partial<ProxyConfig>;
|
|
601
|
+
name?: string;
|
|
622
602
|
}
|
|
623
603
|
/** Response for tunnel management */
|
|
624
604
|
interface TunnelManageResponse {
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
605
|
+
success: boolean;
|
|
606
|
+
tunnel?: ProxyConfig;
|
|
607
|
+
tunnels?: ProxyConfig[];
|
|
608
|
+
error?: string;
|
|
629
609
|
}
|
|
630
610
|
/** Query parameters for listing nodes */
|
|
631
611
|
interface NodeListQuery {
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
612
|
+
page?: number;
|
|
613
|
+
pageSize?: number;
|
|
614
|
+
status?: NodeInfo['status'];
|
|
615
|
+
labels?: Record<string, string>;
|
|
616
|
+
search?: string;
|
|
637
617
|
}
|
|
638
618
|
/** Response for node list query */
|
|
639
619
|
interface NodeListResponse {
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
620
|
+
items: NodeInfo[];
|
|
621
|
+
total: number;
|
|
622
|
+
page: number;
|
|
623
|
+
pageSize: number;
|
|
624
|
+
hasMore: boolean;
|
|
645
625
|
}
|
|
646
626
|
/** Node statistics */
|
|
647
627
|
interface NodeStatistics {
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
628
|
+
total: number;
|
|
629
|
+
online: number;
|
|
630
|
+
offline: number;
|
|
631
|
+
connecting: number;
|
|
632
|
+
error: number;
|
|
653
633
|
}
|
|
654
634
|
/** Error codes for node operations */
|
|
655
635
|
type NodeErrorCode = 'NODE_NOT_FOUND' | 'NODE_ALREADY_EXISTS' | 'INVALID_NODE_DATA' | 'HEARTBEAT_TIMEOUT' | 'STORAGE_ERROR' | 'UNAUTHORIZED';
|
|
656
|
-
|
|
636
|
+
//#endregion
|
|
637
|
+
//#region src/rpc.d.ts
|
|
657
638
|
interface RpcRequest {
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
639
|
+
id: string;
|
|
640
|
+
method: string;
|
|
641
|
+
params: Record<string, unknown>;
|
|
642
|
+
timeout?: number;
|
|
662
643
|
}
|
|
663
644
|
interface RpcResponse {
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
645
|
+
id: string;
|
|
646
|
+
status: 'success' | 'error';
|
|
647
|
+
result?: unknown;
|
|
648
|
+
error?: {
|
|
649
|
+
code: string;
|
|
650
|
+
message: string;
|
|
651
|
+
};
|
|
671
652
|
}
|
|
672
653
|
interface PingMessage {
|
|
673
|
-
|
|
674
|
-
|
|
654
|
+
type: 'ping';
|
|
655
|
+
timestamp: number;
|
|
675
656
|
}
|
|
676
657
|
interface PongMessage {
|
|
677
|
-
|
|
678
|
-
|
|
658
|
+
type: 'pong';
|
|
659
|
+
timestamp: number;
|
|
679
660
|
}
|
|
680
661
|
interface RegisterMessage {
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
662
|
+
type: 'register';
|
|
663
|
+
nodeId: string;
|
|
664
|
+
payload: NodeInfo;
|
|
684
665
|
}
|
|
685
666
|
type RpcInboundMessage = RpcResponse | PongMessage;
|
|
686
667
|
type RpcOutboundMessage = RpcRequest | PingMessage | RegisterMessage;
|
|
@@ -689,66 +670,65 @@ type RpcOutboundMessage = RpcRequest | PingMessage | RegisterMessage;
|
|
|
689
670
|
* This format matches the RPC architecture document specification
|
|
690
671
|
*/
|
|
691
672
|
interface RpcMessage {
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
673
|
+
type: 'command' | 'event';
|
|
674
|
+
action: string;
|
|
675
|
+
payload: unknown;
|
|
676
|
+
id?: string;
|
|
677
|
+
targetNodeId?: string;
|
|
697
678
|
}
|
|
698
679
|
/**
|
|
699
680
|
* Command message (frps -> frpc)
|
|
700
681
|
*/
|
|
701
682
|
interface CommandMessage extends RpcMessage {
|
|
702
|
-
|
|
703
|
-
|
|
683
|
+
type: 'command';
|
|
684
|
+
id: string;
|
|
704
685
|
}
|
|
705
686
|
/**
|
|
706
687
|
* Event message (frpc -> frps)
|
|
707
688
|
*/
|
|
708
689
|
interface EventMessage extends RpcMessage {
|
|
709
|
-
|
|
710
|
-
|
|
690
|
+
type: 'event';
|
|
691
|
+
id?: string;
|
|
711
692
|
}
|
|
712
693
|
/**
|
|
713
694
|
* Tunnel add payload
|
|
714
695
|
*/
|
|
715
696
|
interface TunnelAddPayload {
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
697
|
+
name: string;
|
|
698
|
+
type: 'tcp' | 'http' | 'https' | 'stcp' | 'sudp' | 'xtcp';
|
|
699
|
+
localPort: number;
|
|
700
|
+
remotePort?: number;
|
|
701
|
+
customDomains?: string[];
|
|
702
|
+
subdomain?: string;
|
|
703
|
+
[key: string]: unknown;
|
|
723
704
|
}
|
|
724
705
|
/**
|
|
725
706
|
* Tunnel delete payload
|
|
726
707
|
*/
|
|
727
708
|
interface TunnelDeletePayload {
|
|
728
|
-
|
|
709
|
+
name: string;
|
|
729
710
|
}
|
|
730
711
|
/**
|
|
731
712
|
* Tunnel response payload
|
|
732
713
|
*/
|
|
733
714
|
interface TunnelResponsePayload {
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
715
|
+
success: boolean;
|
|
716
|
+
error?: string;
|
|
717
|
+
tunnel?: TunnelAddPayload;
|
|
737
718
|
}
|
|
738
719
|
/**
|
|
739
720
|
* Node delete payload
|
|
740
721
|
*/
|
|
741
722
|
interface NodeDeletePayload {
|
|
742
|
-
|
|
723
|
+
name: string;
|
|
743
724
|
}
|
|
744
725
|
/**
|
|
745
726
|
* Node response payload
|
|
746
727
|
*/
|
|
747
728
|
interface NodeResponsePayload {
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
729
|
+
success: boolean;
|
|
730
|
+
error?: string;
|
|
731
|
+
deletedNode?: string;
|
|
751
732
|
}
|
|
752
|
-
|
|
753
|
-
export { ProxyType, VisitorType };
|
|
754
|
-
export type { AuthClientConfig, AuthMethod, AuthOIDCClientConfig, AuthOIDCServerConfig, AuthScope, AuthServerConfig, BaseProxyConfig, BaseVisitorConfig, ClientCommonConfig, ClientConfig, ClientTransportConfig, ClientTransportProtocol, CommandMessage, EventMessage, FileSource, HTTPHeader, HTTPPluginOptions, HTTPProxyConfig, HTTPSProxyConfig, HeaderOperations, LoadBalancerStrategy, LogConfig, LogLevel, NatTraversalConfig, NodeDeletePayload, NodeErrorCode, NodeHeartbeatPayload, NodeInfo, NodeListQuery, NodeListResponse, NodeRegisterPayload, NodeResponsePayload, NodeStatistics, PingMessage, PongMessage, PortsRange, ProxyConfig, ProxyTypeUnion, QUICOptions, RegisterMessage, RpcInboundMessage, RpcMessage, RpcOutboundMessage, RpcRequest, RpcResponse, SSHTunnelGateway, STCPProxyConfig, STCPVisitorConfig, SUDPProxyConfig, SUDPVisitorConfig, ServerConfig, ServerTransportConfig, TCPMUXProxyConfig, TCPProxyConfig, TLSClientConfig, TLSConfig, TLSServerConfig, TunnelAddPayload, TunnelDeletePayload, TunnelManagePayload, TunnelManageResponse, TunnelResponsePayload, TunnelSyncPayload, UDPProxyConfig, ValueSource, ValueSourceType, VirtualNetConfig, VisitorConfig, VisitorTypeUnion, WebServerConfig, XTCPProxyConfig, XTCPVisitorConfig };
|
|
733
|
+
//#endregion
|
|
734
|
+
export { type AuthClientConfig, type AuthMethod, type AuthOIDCClientConfig, type AuthOIDCServerConfig, type AuthScope, type AuthServerConfig, type BaseProxyConfig, type BaseVisitorConfig, type ClientCommonConfig, type ClientConfig, type ClientTransportConfig, type ClientTransportProtocol, type CommandMessage, type EventMessage, type FileSource, type HTTPHeader, type HTTPPluginOptions, type HTTPProxyConfig, type HTTPSProxyConfig, type HeaderOperations, type LoadBalancerStrategy, type LogConfig, type LogLevel, type NatTraversalConfig, type NodeDeletePayload, type NodeErrorCode, type NodeHeartbeatPayload, type NodeInfo, type NodeListQuery, type NodeListResponse, type NodeRegisterPayload, type NodeResponsePayload, type NodeStatistics, type PingMessage, type PongMessage, type PortsRange, type ProxyConfig, ProxyType, type ProxyTypeUnion, type QUICOptions, type RegisterMessage, type RpcInboundMessage, type RpcMessage, type RpcOutboundMessage, type RpcRequest, type RpcResponse, type SSHTunnelGateway, type STCPProxyConfig, type STCPVisitorConfig, type SUDPProxyConfig, type SUDPVisitorConfig, type ServerConfig, type ServerTransportConfig, type TCPMUXProxyConfig, type TCPProxyConfig, type TLSClientConfig, type TLSConfig, type TLSServerConfig, type TunnelAddPayload, type TunnelDeletePayload, type TunnelManagePayload, type TunnelManageResponse, type TunnelResponsePayload, type TunnelSyncPayload, type UDPProxyConfig, type ValueSource, type ValueSourceType, type VirtualNetConfig, type VisitorConfig, VisitorType, type VisitorTypeUnion, type WebServerConfig, type XTCPProxyConfig, type XTCPVisitorConfig };
|