@frp-bridge/types 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 imba97 <https://github.com/imba97>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,527 @@
1
+ /**
2
+ * FRP 通用配置类型定义
3
+ * 基于 frp 官方文档: https://gofrp.org/zh-cn/docs/reference/common/
4
+ */
5
+ /** 日志级别类型 */
6
+ type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error';
7
+ /** 日志配置 */
8
+ interface LogConfig {
9
+ /** 日志输出文件路径,如果为 console,则会将日志打印在标准输出中 */
10
+ to?: string;
11
+ /** 日志级别,可选值为 trace, debug, info, warn, error,默认级别为 info */
12
+ level?: LogLevel;
13
+ /** 日志文件最多保留天数,默认为 3 天 */
14
+ maxDays?: number;
15
+ /** 禁用标准输出中的日志颜色 */
16
+ disablePrintColor?: boolean;
17
+ }
18
+ /** TLS 配置 */
19
+ interface TLSConfig {
20
+ /** TLS 证书文件路径 */
21
+ certFile: string;
22
+ /** TLS 密钥文件路径 */
23
+ keyFile: string;
24
+ /** CA 证书文件路径 */
25
+ trustedCaFile?: string;
26
+ /** TLS Server 名称 */
27
+ serverName?: string;
28
+ }
29
+ /** Web 服务器配置 */
30
+ interface WebServerConfig {
31
+ /** webServer 监听地址,默认为 127.0.0.1 */
32
+ addr?: string;
33
+ /** webServer 监听端口 */
34
+ port: number;
35
+ /** HTTP BasicAuth 用户名 */
36
+ user?: string;
37
+ /** HTTP BasicAuth 密码 */
38
+ password?: string;
39
+ /** 静态资源目录,Dashboard 使用的资源默认打包在二进制文件中,通过指定此参数使用自定义的静态资源 */
40
+ assetsDir?: string;
41
+ /** 启动 Go HTTP pprof,用于应用调试 */
42
+ pprofEnable?: boolean;
43
+ /** Dashboard 启用 HTTPS 的 TLS 相关配置 */
44
+ tls?: TLSConfig;
45
+ }
46
+ /** QUIC 协议选项 */
47
+ interface QUICOptions {
48
+ /** 保活周期,默认值为 10 秒 */
49
+ keepalivePeriod?: number;
50
+ /** 最大空闲超时时间,默认值为 30 秒 */
51
+ maxIdleTimeout?: number;
52
+ /** 最大传入流数量,默认值为 100000 */
53
+ maxIncomingStreams?: number;
54
+ }
55
+ /** 端口范围配置 */
56
+ interface PortsRange {
57
+ /** 起始端口 */
58
+ start?: number;
59
+ /** 终止端口 */
60
+ end?: number;
61
+ /** 单一端口 */
62
+ single?: number;
63
+ }
64
+ /** HTTP 头部操作配置 */
65
+ interface HeaderOperations {
66
+ /** 在 Header 中设置指定的 KV 值 */
67
+ set?: Record<string, string>;
68
+ }
69
+ /** HTTP 头部配置 */
70
+ interface HTTPHeader {
71
+ /** Header 名称 */
72
+ name: string;
73
+ /** Header 值 */
74
+ value: string;
75
+ }
76
+ /** 文件数据源配置 */
77
+ interface FileSource {
78
+ /** 文件路径 */
79
+ path: string;
80
+ }
81
+ /** 数据源类型 */
82
+ type ValueSourceType = 'file';
83
+ /** 值数据源配置 */
84
+ interface ValueSource {
85
+ /** 数据源类型,目前仅支持 "file" */
86
+ type: ValueSourceType;
87
+ /** 文件数据源配置,当 type 为 "file" 时必填 */
88
+ file?: FileSource;
89
+ }
90
+ /** NAT 穿透配置 */
91
+ interface NatTraversalConfig {
92
+ /**
93
+ * 禁用本地网络接口地址的辅助连接。当启用时,仅使用通过 STUN 发现的公网地址进行 NAT 打洞,
94
+ * 避免使用可能较慢的本地网络接口(如 VPN)。默认为 false
95
+ */
96
+ disableAssistedAddrs?: boolean;
97
+ }
98
+
99
+ /**
100
+ * FRP 服务端配置类型定义
101
+ * 基于 frp 官方文档: https://gofrp.org/zh-cn/docs/reference/server-configures/
102
+ */
103
+
104
+ /** 鉴权方式类型 */
105
+ type AuthMethod = 'token' | 'oidc';
106
+ /** 鉴权信息附加范围类型 */
107
+ type AuthScope = 'HeartBeats' | 'NewWorkConns';
108
+ /** OIDC 服务端鉴权配置 */
109
+ interface AuthOIDCServerConfig {
110
+ /** OIDC 发行者 */
111
+ issuer?: string;
112
+ /** OIDC 受众 */
113
+ audience?: string;
114
+ /** 跳过过期检查 */
115
+ skipExpiryCheck?: boolean;
116
+ /** 跳过发行者检查 */
117
+ skipIssuerCheck?: boolean;
118
+ }
119
+ /** 服务端鉴权配置 */
120
+ interface AuthServerConfig {
121
+ /** 鉴权方式,可选值为 token 或 oidc,默认为 token */
122
+ method?: AuthMethod;
123
+ /** 鉴权信息附加范围,可选值为 HeartBeats 和 NewWorkConns */
124
+ additionalScopes?: AuthScope[];
125
+ /** 在 method 为 token 时生效,客户端需要设置一样的值才能鉴权通过。与 tokenSource 字段互斥 */
126
+ token?: string;
127
+ /** 从文件中加载 token 的配置。与 token 字段互斥 */
128
+ tokenSource?: ValueSource;
129
+ /** oidc 鉴权配置 */
130
+ oidc?: AuthOIDCServerConfig;
131
+ }
132
+ /** 服务端 TLS 配置 */
133
+ interface TLSServerConfig extends TLSConfig {
134
+ /** 是否只接受启用了 TLS 的客户端连接 */
135
+ force?: boolean;
136
+ }
137
+ /** 服务端传输层配置 */
138
+ interface ServerTransportConfig {
139
+ /** tcp mux 的心跳检查间隔时间,单位秒 */
140
+ tcpMuxKeepaliveInterval?: number;
141
+ /** 和客户端底层 TCP 连接的 keepalive 间隔时间,单位秒,配置为负数表示不启用 */
142
+ tcpKeepalive?: number;
143
+ /** 允许客户端设置的最大连接池大小,如果客户端配置的值大于此值,会被强制修改为最大值,默认为 5 */
144
+ maxPoolCount?: number;
145
+ /** 服务端和客户端心跳连接的超时时间,单位秒,默认为 90 秒 */
146
+ heartbeatTimeout?: number;
147
+ /** QUIC 协议配置参数 */
148
+ quic?: QUICOptions;
149
+ /** 服务端 TLS 协议配置 */
150
+ tls?: TLSServerConfig;
151
+ }
152
+ /** HTTP 插件选项 */
153
+ interface HTTPPluginOptions {
154
+ /** 插件名称 */
155
+ name: string;
156
+ /** 插件接口的地址 */
157
+ addr: string;
158
+ /** 插件接口的 Path */
159
+ path: string;
160
+ /** 插件需要生效的操作列表,具体可选值请参考服务端插件的说明文档 */
161
+ ops: string[];
162
+ /** 当插件地址为 HTTPS 协议时,是否校验插件的 TLS 证书,默认为不校验 */
163
+ tlsVerify?: boolean;
164
+ }
165
+ /** SSH 隧道网关配置 */
166
+ interface SSHTunnelGateway {
167
+ /** SSH 服务器监听端口 */
168
+ bindPort: number;
169
+ /** SSH 服务器私钥文件路径。若为空,frps将读取autoGenPrivateKeyPath路径下的私钥文件 */
170
+ privateKeyFile?: string;
171
+ /** 私钥文件自动生成路径,默认为./.autogen_ssh_key。若文件不存在或内容为空,frps将自动生成RSA私钥文件并存储到该路径 */
172
+ autoGenPrivateKeyPath?: string;
173
+ /** SSH 客户端授权密钥文件路径。若为空,则不进行SSH客户端鉴权认证。非空可实现SSH免密登录认证 */
174
+ authorizedKeysFile?: string;
175
+ }
176
+ /** 服务端配置 */
177
+ interface ServerConfig {
178
+ /** 鉴权配置 */
179
+ auth?: AuthServerConfig;
180
+ /** 服务端监听地址,用于接收 frpc 的连接,默认监听 0.0.0.0 */
181
+ bindAddr?: string;
182
+ /** 服务端监听端口,默认值为 7000 */
183
+ bindPort?: number;
184
+ /** 服务端监听 KCP 协议端口,用于接收配置了使用 KCP 协议的 frpc 连接 */
185
+ kcpBindPort?: number;
186
+ /** 服务端监听 QUIC 协议端口,用于接收配置了使用 QUIC 协议的 frpc 连接 */
187
+ quicBindPort?: number;
188
+ /** 代理监听地址,可以使代理监听在不同的网卡地址,默认情况下同 bindAddr */
189
+ proxyBindAddr?: string;
190
+ /** HTTP 类型代理监听的端口,启用后才能支持 HTTP 类型的代理 */
191
+ vhostHTTPPort?: number;
192
+ /** HTTP 类型代理在服务端的 ResponseHeader 超时时间,默认为 60s */
193
+ vhostHTTPTimeout?: number;
194
+ /** HTTPS 类型代理监听的端口,启用后才能支持 HTTPS 类型的代理 */
195
+ vhostHTTPSPort?: number;
196
+ /** tcpmux 类型且复用器为 httpconnect 的代理监听的端口 */
197
+ tcpmuxHTTPConnectPort?: number;
198
+ /** 对于 tcpmux 类型的代理是否透传 CONNECT 请求 */
199
+ tcpmuxPassthrough?: boolean;
200
+ /** 二级域名后缀 */
201
+ subDomainHost?: string;
202
+ /** 自定义 404 错误页面地址 */
203
+ custom404Page?: string;
204
+ /** ssh 隧道网关配置 */
205
+ sshTunnelGateway?: SSHTunnelGateway;
206
+ /** 服务端 Dashboard 配置 */
207
+ webServer?: WebServerConfig;
208
+ /** 是否提供 Prometheus 监控接口,需要同时启用了 webServer 后才会生效 */
209
+ enablePrometheus?: boolean;
210
+ /** 日志配置 */
211
+ log?: LogConfig;
212
+ /** 网络层配置 */
213
+ transport?: ServerTransportConfig;
214
+ /** 服务端返回详细错误信息给客户端,默认为 true */
215
+ detailedErrorsToClient?: boolean;
216
+ /** 限制单个客户端最大同时存在的代理数,默认无限制 */
217
+ maxPortsPerClient?: number;
218
+ /** 用户建立连接后等待客户端响应的超时时间,单位秒,默认为 10 秒 */
219
+ userConnTimeout?: number;
220
+ /** 代理 UDP 服务时支持的最大包长度,默认为 1500,服务端和客户端的值需要一致 */
221
+ udpPacketSize?: number;
222
+ /** 打洞策略数据的保留时间,默认为 168 小时,即 7 天 */
223
+ natholeAnalysisDataReserveHours?: number;
224
+ /** 允许代理绑定的服务端端口 */
225
+ allowPorts?: PortsRange[];
226
+ /** 服务端 HTTP 插件配置 */
227
+ httpPlugins?: HTTPPluginOptions[];
228
+ }
229
+
230
+ /**
231
+ * FRP 客户端配置类型定义
232
+ * 基于 frp 官方文档: https://gofrp.org/zh-cn/docs/reference/client-configures/
233
+ */
234
+
235
+ /** 客户端传输协议类型 */
236
+ type ClientTransportProtocol = 'tcp' | 'kcp' | 'quic' | 'websocket' | 'wss';
237
+ /** OIDC 客户端鉴权配置 */
238
+ interface AuthOIDCClientConfig {
239
+ /** OIDC 客户端 ID */
240
+ clientID?: string;
241
+ /** OIDC 客户端密钥 */
242
+ clientSecret?: string;
243
+ /** OIDC audience 参数 */
244
+ audience?: string;
245
+ /** OIDC scope 参数 */
246
+ scope?: string;
247
+ /** OIDC 令牌端点 URL */
248
+ tokenEndpointURL?: string;
249
+ /** 附加的端点参数 */
250
+ additionalEndpointParams?: Record<string, string>;
251
+ /** 信任的 CA 证书文件路径,用于验证 OIDC 服务器的 TLS 证书 */
252
+ trustedCaFile?: string;
253
+ /** 跳过 TLS 证书验证,不推荐在生产环境使用 */
254
+ insecureSkipVerify?: boolean;
255
+ /** 访问 OIDC 令牌端点时使用的代理服务器 URL */
256
+ proxyURL?: string;
257
+ }
258
+ /** 客户端鉴权配置 */
259
+ interface AuthClientConfig {
260
+ /** 鉴权方式,可选值为 token 或 oidc,默认为 token */
261
+ method?: AuthMethod;
262
+ /** 鉴权信息附加范围,可选值为 HeartBeats 和 NewWorkConns */
263
+ additionalScopes?: AuthScope[];
264
+ /** 在 method 为 token 时生效,客户端需要设置一样的值才能鉴权通过。与 tokenSource 字段互斥 */
265
+ token?: string;
266
+ /** 从文件中加载 token 的配置。与 token 字段互斥 */
267
+ tokenSource?: ValueSource;
268
+ /** oidc 鉴权配置 */
269
+ oidc?: AuthOIDCClientConfig;
270
+ }
271
+ /** 客户端 TLS 配置 */
272
+ interface TLSClientConfig extends TLSConfig {
273
+ /** 是否和服务端之间启用 TLS 连接,默认启用 */
274
+ enable?: boolean;
275
+ /** 启用 TLS 连接时,不发送 0x17 特殊字节。默认为 true。当配置为 true 时,无法和 vhostHTTPSPort 端口复用 */
276
+ disableCustomTLSFirstByte?: boolean;
277
+ }
278
+ /** 客户端传输层配置 */
279
+ interface ClientTransportConfig {
280
+ /** 和 frps 之间的通信协议,可选值为 tcp, kcp, quic, websocket, wss。默认为 tcp */
281
+ protocol?: ClientTransportProtocol;
282
+ /** 连接服务端的超时时间,默认为 10s */
283
+ dialServerTimeout?: number;
284
+ /** 和服务端底层 TCP 连接的 keepalive 间隔时间,单位秒 */
285
+ dialServerKeepalive?: number;
286
+ /** 连接服务端时所绑定的本地 IP */
287
+ connectServerLocalIP?: string;
288
+ /** 连接服务端使用的代理地址,格式为 {protocol}://user:passwd@192.168.1.128:8080 protocol 目前支持 http、socks5、ntlm */
289
+ proxyURL?: string;
290
+ /** 连接池大小 */
291
+ poolCount?: number;
292
+ /** TCP 多路复用,默认启用 */
293
+ tcpMux?: boolean;
294
+ /** tcp_mux 的心跳检查间隔时间 */
295
+ tcpMuxKeepaliveInterval?: number;
296
+ /** QUIC 协议配置参数 */
297
+ quic?: QUICOptions;
298
+ /** 向服务端发送心跳包的间隔时间,默认为 30s。建议启用 tcp_mux_keepalive_interval,将此值设置为 -1 */
299
+ heartbeatInterval?: number;
300
+ /** 和服务端心跳的超时时间,默认为 90s */
301
+ heartbeatTimeout?: number;
302
+ /** 客户端 TLS 协议配置 */
303
+ tls?: TLSClientConfig;
304
+ }
305
+ /** 虚拟网络配置 */
306
+ interface VirtualNetConfig {
307
+ /** 虚拟网络接口的 IP 地址和网段,格式为 CIDR (例如 "100.86.0.1/24") */
308
+ address: string;
309
+ }
310
+ /** 客户端通用配置 */
311
+ interface ClientCommonConfig {
312
+ /** 客户端鉴权配置 */
313
+ auth?: AuthClientConfig;
314
+ /** 用户名,设置此参数后,代理名称会被修改为 {user}.{proxyName},避免代理名称和其他用户冲突 */
315
+ user?: string;
316
+ /** 连接服务端的地址 */
317
+ serverAddr?: string;
318
+ /** 连接服务端的端口,默认为 7000 */
319
+ serverPort?: number;
320
+ /** xtcp 打洞所需的 stun 服务器地址,默认为 stun.easyvoip.com:3478 */
321
+ natHoleStunServer?: string;
322
+ /** 使用 DNS 服务器地址,默认使用系统配置的 DNS 服务器,指定此参数可以强制替换为自定义的 DNS 服务器地址 */
323
+ dnsServer?: string;
324
+ /** 第一次登陆失败后是否退出,默认为 true */
325
+ loginFailExit?: boolean;
326
+ /** 指定启用部分代理,当配置了较多代理,但是只希望启用其中部分时可以通过此参数指定,默认为全部启用 */
327
+ start?: string[];
328
+ /** 日志配置 */
329
+ log?: LogConfig;
330
+ /** 客户端 AdminServer 配置 */
331
+ webServer?: WebServerConfig;
332
+ /** 客户端网络层配置 */
333
+ transport?: ClientTransportConfig;
334
+ /** 虚拟网络配置,Alpha 特性 */
335
+ virtualNet?: VirtualNetConfig;
336
+ /** 特性门控,用于启用或禁用实验性功能 */
337
+ featureGates?: Record<string, boolean>;
338
+ /** 代理 UDP 服务时支持的最大包长度,默认为 1500,服务端和客户端需要保持配置一致 */
339
+ udpPacketSize?: number;
340
+ /** 附加元数据,会传递给服务端插件,提供附加能力 */
341
+ metadatas?: Record<string, string>;
342
+ /** 指定额外的配置文件目录,其中的 proxy 和 visitor 配置会被读取加载 */
343
+ includes?: string[];
344
+ }
345
+ /** 客户端配置 */
346
+ interface ClientConfig extends ClientCommonConfig {
347
+ }
348
+
349
+ /**
350
+ * FRP Proxy configuration types
351
+ * Based on: https://gofrp.org/zh-cn/docs/reference/proxy-config/
352
+ */
353
+ /** Proxy type */
354
+ type ProxyType = 'tcp' | 'udp' | 'http' | 'https' | 'tcpmux' | 'stcp' | 'xtcp' | 'sudp';
355
+ /** Load balancer strategy */
356
+ type LoadBalancerStrategy = 'random' | 'round_robin';
357
+ /** Base proxy configuration */
358
+ interface BaseProxyConfig {
359
+ /** Proxy name (unique) */
360
+ name: string;
361
+ /** Proxy type */
362
+ type: ProxyType;
363
+ /** Local IP to bind */
364
+ localIP?: string;
365
+ /** Local port */
366
+ localPort?: number;
367
+ /** Additional metadata */
368
+ annotations?: Record<string, string>;
369
+ /** Custom metadata passed to server plugins */
370
+ metadatas?: Record<string, string>;
371
+ /** Load balancer settings */
372
+ loadBalancer?: {
373
+ /** Load balancing strategy */
374
+ strategy?: LoadBalancerStrategy;
375
+ /** Health check configuration */
376
+ healthCheck?: {
377
+ /** Health check type */
378
+ type?: 'tcp' | 'http';
379
+ /** Health check timeout (seconds) */
380
+ timeoutSeconds?: number;
381
+ /** Max failed checks before marking unhealthy */
382
+ maxFailed?: number;
383
+ /** Check interval (seconds) */
384
+ intervalSeconds?: number;
385
+ /** HTTP health check path */
386
+ path?: string;
387
+ };
388
+ };
389
+ /** Enable bandwidth limit */
390
+ transport?: {
391
+ /** Bandwidth limit (KB/s) */
392
+ bandwidthLimit?: string;
393
+ /** Bandwidth limit mode */
394
+ bandwidthLimitMode?: 'client' | 'server';
395
+ };
396
+ }
397
+ /** TCP proxy configuration */
398
+ interface TCPProxyConfig extends BaseProxyConfig {
399
+ type: 'tcp';
400
+ /** Remote port on server */
401
+ remotePort?: number;
402
+ }
403
+ /** UDP proxy configuration */
404
+ interface UDPProxyConfig extends BaseProxyConfig {
405
+ type: 'udp';
406
+ /** Remote port on server */
407
+ remotePort?: number;
408
+ }
409
+ /** HTTP proxy configuration */
410
+ interface HTTPProxyConfig extends BaseProxyConfig {
411
+ type: 'http';
412
+ /** Custom domain names */
413
+ customDomains?: string[];
414
+ /** Subdomain under server's subdomain_host */
415
+ subdomain?: string;
416
+ /** Locations to proxy */
417
+ locations?: string[];
418
+ /** Host header rewrite */
419
+ hostHeaderRewrite?: string;
420
+ /** HTTP username for basic auth */
421
+ httpUser?: string;
422
+ /** HTTP password for basic auth */
423
+ httpPassword?: string;
424
+ /** Request headers to set */
425
+ requestHeaders?: {
426
+ set?: Record<string, string>;
427
+ };
428
+ /** Response headers to set */
429
+ responseHeaders?: {
430
+ set?: Record<string, string>;
431
+ };
432
+ /** Route by HTTP user */
433
+ routeByHTTPUser?: string;
434
+ }
435
+ /** HTTPS proxy configuration */
436
+ interface HTTPSProxyConfig extends BaseProxyConfig {
437
+ type: 'https';
438
+ /** Custom domain names */
439
+ customDomains?: string[];
440
+ /** Subdomain under server's subdomain_host */
441
+ subdomain?: string;
442
+ }
443
+ /** TCPMUX proxy configuration */
444
+ interface TCPMUXProxyConfig extends BaseProxyConfig {
445
+ type: 'tcpmux';
446
+ /** Multiplexer type */
447
+ multiplexer?: 'httpconnect';
448
+ /** Custom domain names */
449
+ customDomains?: string[];
450
+ /** Subdomain under server's subdomain_host */
451
+ subdomain?: string;
452
+ /** Route by HTTP user */
453
+ routeByHTTPUser?: string;
454
+ /** HTTP username */
455
+ httpUser?: string;
456
+ /** HTTP password */
457
+ httpPassword?: string;
458
+ }
459
+ /** STCP proxy configuration */
460
+ interface STCPProxyConfig extends BaseProxyConfig {
461
+ type: 'stcp';
462
+ /** Secret key shared with visitor */
463
+ secretKey?: string;
464
+ /** Allowed visitor users */
465
+ allowUsers?: string[];
466
+ }
467
+ /** XTCP proxy configuration */
468
+ interface XTCPProxyConfig extends BaseProxyConfig {
469
+ type: 'xtcp';
470
+ /** Secret key shared with visitor */
471
+ secretKey?: string;
472
+ /** Allowed visitor users */
473
+ allowUsers?: string[];
474
+ }
475
+ /** SUDP proxy configuration */
476
+ interface SUDPProxyConfig extends BaseProxyConfig {
477
+ type: 'sudp';
478
+ /** Secret key shared with visitor */
479
+ secretKey?: string;
480
+ /** Allowed visitor users */
481
+ allowUsers?: string[];
482
+ }
483
+ /** Union type of all proxy configurations */
484
+ type ProxyConfig = TCPProxyConfig | UDPProxyConfig | HTTPProxyConfig | HTTPSProxyConfig | TCPMUXProxyConfig | STCPProxyConfig | XTCPProxyConfig | SUDPProxyConfig;
485
+ /** Visitor type */
486
+ type VisitorType = 'stcp' | 'xtcp' | 'sudp';
487
+ /** Base visitor configuration */
488
+ interface BaseVisitorConfig {
489
+ /** Visitor name (unique) */
490
+ name: string;
491
+ /** Visitor type */
492
+ type: VisitorType;
493
+ /** Server name to connect to */
494
+ serverName: string;
495
+ /** Secret key shared with proxy */
496
+ secretKey?: string;
497
+ /** Local IP to bind */
498
+ bindAddr?: string;
499
+ /** Local port to bind */
500
+ bindPort?: number;
501
+ }
502
+ /** STCP visitor configuration */
503
+ interface STCPVisitorConfig extends BaseVisitorConfig {
504
+ type: 'stcp';
505
+ }
506
+ /** XTCP visitor configuration */
507
+ interface XTCPVisitorConfig extends BaseVisitorConfig {
508
+ type: 'xtcp';
509
+ /** Keep tunnel alive even when no connection */
510
+ keepTunnelOpen?: boolean;
511
+ /** Max retries for establishing connection */
512
+ maxRetriesAnHour?: number;
513
+ /** Min retry interval (seconds) */
514
+ minRetryInterval?: number;
515
+ /** Fallback to STCP when XTCP fails */
516
+ fallbackTo?: string;
517
+ /** Fallback timeout (seconds) */
518
+ fallbackTimeoutMs?: number;
519
+ }
520
+ /** SUDP visitor configuration */
521
+ interface SUDPVisitorConfig extends BaseVisitorConfig {
522
+ type: 'sudp';
523
+ }
524
+ /** Union type of all visitor configurations */
525
+ type VisitorConfig = STCPVisitorConfig | XTCPVisitorConfig | SUDPVisitorConfig;
526
+
527
+ export type { AuthClientConfig, AuthMethod, AuthOIDCClientConfig, AuthOIDCServerConfig, AuthScope, AuthServerConfig, BaseProxyConfig, BaseVisitorConfig, ClientCommonConfig, ClientConfig, ClientTransportConfig, ClientTransportProtocol, FileSource, HTTPHeader, HTTPPluginOptions, HTTPProxyConfig, HTTPSProxyConfig, HeaderOperations, LoadBalancerStrategy, LogConfig, LogLevel, NatTraversalConfig, PortsRange, ProxyConfig, ProxyType, QUICOptions, SSHTunnelGateway, STCPProxyConfig, STCPVisitorConfig, SUDPProxyConfig, SUDPVisitorConfig, ServerConfig, ServerTransportConfig, TCPMUXProxyConfig, TCPProxyConfig, TLSClientConfig, TLSConfig, TLSServerConfig, UDPProxyConfig, ValueSource, ValueSourceType, VirtualNetConfig, VisitorConfig, VisitorType, WebServerConfig, XTCPProxyConfig, XTCPVisitorConfig };
@@ -0,0 +1,527 @@
1
+ /**
2
+ * FRP 通用配置类型定义
3
+ * 基于 frp 官方文档: https://gofrp.org/zh-cn/docs/reference/common/
4
+ */
5
+ /** 日志级别类型 */
6
+ type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error';
7
+ /** 日志配置 */
8
+ interface LogConfig {
9
+ /** 日志输出文件路径,如果为 console,则会将日志打印在标准输出中 */
10
+ to?: string;
11
+ /** 日志级别,可选值为 trace, debug, info, warn, error,默认级别为 info */
12
+ level?: LogLevel;
13
+ /** 日志文件最多保留天数,默认为 3 天 */
14
+ maxDays?: number;
15
+ /** 禁用标准输出中的日志颜色 */
16
+ disablePrintColor?: boolean;
17
+ }
18
+ /** TLS 配置 */
19
+ interface TLSConfig {
20
+ /** TLS 证书文件路径 */
21
+ certFile: string;
22
+ /** TLS 密钥文件路径 */
23
+ keyFile: string;
24
+ /** CA 证书文件路径 */
25
+ trustedCaFile?: string;
26
+ /** TLS Server 名称 */
27
+ serverName?: string;
28
+ }
29
+ /** Web 服务器配置 */
30
+ interface WebServerConfig {
31
+ /** webServer 监听地址,默认为 127.0.0.1 */
32
+ addr?: string;
33
+ /** webServer 监听端口 */
34
+ port: number;
35
+ /** HTTP BasicAuth 用户名 */
36
+ user?: string;
37
+ /** HTTP BasicAuth 密码 */
38
+ password?: string;
39
+ /** 静态资源目录,Dashboard 使用的资源默认打包在二进制文件中,通过指定此参数使用自定义的静态资源 */
40
+ assetsDir?: string;
41
+ /** 启动 Go HTTP pprof,用于应用调试 */
42
+ pprofEnable?: boolean;
43
+ /** Dashboard 启用 HTTPS 的 TLS 相关配置 */
44
+ tls?: TLSConfig;
45
+ }
46
+ /** QUIC 协议选项 */
47
+ interface QUICOptions {
48
+ /** 保活周期,默认值为 10 秒 */
49
+ keepalivePeriod?: number;
50
+ /** 最大空闲超时时间,默认值为 30 秒 */
51
+ maxIdleTimeout?: number;
52
+ /** 最大传入流数量,默认值为 100000 */
53
+ maxIncomingStreams?: number;
54
+ }
55
+ /** 端口范围配置 */
56
+ interface PortsRange {
57
+ /** 起始端口 */
58
+ start?: number;
59
+ /** 终止端口 */
60
+ end?: number;
61
+ /** 单一端口 */
62
+ single?: number;
63
+ }
64
+ /** HTTP 头部操作配置 */
65
+ interface HeaderOperations {
66
+ /** 在 Header 中设置指定的 KV 值 */
67
+ set?: Record<string, string>;
68
+ }
69
+ /** HTTP 头部配置 */
70
+ interface HTTPHeader {
71
+ /** Header 名称 */
72
+ name: string;
73
+ /** Header 值 */
74
+ value: string;
75
+ }
76
+ /** 文件数据源配置 */
77
+ interface FileSource {
78
+ /** 文件路径 */
79
+ path: string;
80
+ }
81
+ /** 数据源类型 */
82
+ type ValueSourceType = 'file';
83
+ /** 值数据源配置 */
84
+ interface ValueSource {
85
+ /** 数据源类型,目前仅支持 "file" */
86
+ type: ValueSourceType;
87
+ /** 文件数据源配置,当 type 为 "file" 时必填 */
88
+ file?: FileSource;
89
+ }
90
+ /** NAT 穿透配置 */
91
+ interface NatTraversalConfig {
92
+ /**
93
+ * 禁用本地网络接口地址的辅助连接。当启用时,仅使用通过 STUN 发现的公网地址进行 NAT 打洞,
94
+ * 避免使用可能较慢的本地网络接口(如 VPN)。默认为 false
95
+ */
96
+ disableAssistedAddrs?: boolean;
97
+ }
98
+
99
+ /**
100
+ * FRP 服务端配置类型定义
101
+ * 基于 frp 官方文档: https://gofrp.org/zh-cn/docs/reference/server-configures/
102
+ */
103
+
104
+ /** 鉴权方式类型 */
105
+ type AuthMethod = 'token' | 'oidc';
106
+ /** 鉴权信息附加范围类型 */
107
+ type AuthScope = 'HeartBeats' | 'NewWorkConns';
108
+ /** OIDC 服务端鉴权配置 */
109
+ interface AuthOIDCServerConfig {
110
+ /** OIDC 发行者 */
111
+ issuer?: string;
112
+ /** OIDC 受众 */
113
+ audience?: string;
114
+ /** 跳过过期检查 */
115
+ skipExpiryCheck?: boolean;
116
+ /** 跳过发行者检查 */
117
+ skipIssuerCheck?: boolean;
118
+ }
119
+ /** 服务端鉴权配置 */
120
+ interface AuthServerConfig {
121
+ /** 鉴权方式,可选值为 token 或 oidc,默认为 token */
122
+ method?: AuthMethod;
123
+ /** 鉴权信息附加范围,可选值为 HeartBeats 和 NewWorkConns */
124
+ additionalScopes?: AuthScope[];
125
+ /** 在 method 为 token 时生效,客户端需要设置一样的值才能鉴权通过。与 tokenSource 字段互斥 */
126
+ token?: string;
127
+ /** 从文件中加载 token 的配置。与 token 字段互斥 */
128
+ tokenSource?: ValueSource;
129
+ /** oidc 鉴权配置 */
130
+ oidc?: AuthOIDCServerConfig;
131
+ }
132
+ /** 服务端 TLS 配置 */
133
+ interface TLSServerConfig extends TLSConfig {
134
+ /** 是否只接受启用了 TLS 的客户端连接 */
135
+ force?: boolean;
136
+ }
137
+ /** 服务端传输层配置 */
138
+ interface ServerTransportConfig {
139
+ /** tcp mux 的心跳检查间隔时间,单位秒 */
140
+ tcpMuxKeepaliveInterval?: number;
141
+ /** 和客户端底层 TCP 连接的 keepalive 间隔时间,单位秒,配置为负数表示不启用 */
142
+ tcpKeepalive?: number;
143
+ /** 允许客户端设置的最大连接池大小,如果客户端配置的值大于此值,会被强制修改为最大值,默认为 5 */
144
+ maxPoolCount?: number;
145
+ /** 服务端和客户端心跳连接的超时时间,单位秒,默认为 90 秒 */
146
+ heartbeatTimeout?: number;
147
+ /** QUIC 协议配置参数 */
148
+ quic?: QUICOptions;
149
+ /** 服务端 TLS 协议配置 */
150
+ tls?: TLSServerConfig;
151
+ }
152
+ /** HTTP 插件选项 */
153
+ interface HTTPPluginOptions {
154
+ /** 插件名称 */
155
+ name: string;
156
+ /** 插件接口的地址 */
157
+ addr: string;
158
+ /** 插件接口的 Path */
159
+ path: string;
160
+ /** 插件需要生效的操作列表,具体可选值请参考服务端插件的说明文档 */
161
+ ops: string[];
162
+ /** 当插件地址为 HTTPS 协议时,是否校验插件的 TLS 证书,默认为不校验 */
163
+ tlsVerify?: boolean;
164
+ }
165
+ /** SSH 隧道网关配置 */
166
+ interface SSHTunnelGateway {
167
+ /** SSH 服务器监听端口 */
168
+ bindPort: number;
169
+ /** SSH 服务器私钥文件路径。若为空,frps将读取autoGenPrivateKeyPath路径下的私钥文件 */
170
+ privateKeyFile?: string;
171
+ /** 私钥文件自动生成路径,默认为./.autogen_ssh_key。若文件不存在或内容为空,frps将自动生成RSA私钥文件并存储到该路径 */
172
+ autoGenPrivateKeyPath?: string;
173
+ /** SSH 客户端授权密钥文件路径。若为空,则不进行SSH客户端鉴权认证。非空可实现SSH免密登录认证 */
174
+ authorizedKeysFile?: string;
175
+ }
176
+ /** 服务端配置 */
177
+ interface ServerConfig {
178
+ /** 鉴权配置 */
179
+ auth?: AuthServerConfig;
180
+ /** 服务端监听地址,用于接收 frpc 的连接,默认监听 0.0.0.0 */
181
+ bindAddr?: string;
182
+ /** 服务端监听端口,默认值为 7000 */
183
+ bindPort?: number;
184
+ /** 服务端监听 KCP 协议端口,用于接收配置了使用 KCP 协议的 frpc 连接 */
185
+ kcpBindPort?: number;
186
+ /** 服务端监听 QUIC 协议端口,用于接收配置了使用 QUIC 协议的 frpc 连接 */
187
+ quicBindPort?: number;
188
+ /** 代理监听地址,可以使代理监听在不同的网卡地址,默认情况下同 bindAddr */
189
+ proxyBindAddr?: string;
190
+ /** HTTP 类型代理监听的端口,启用后才能支持 HTTP 类型的代理 */
191
+ vhostHTTPPort?: number;
192
+ /** HTTP 类型代理在服务端的 ResponseHeader 超时时间,默认为 60s */
193
+ vhostHTTPTimeout?: number;
194
+ /** HTTPS 类型代理监听的端口,启用后才能支持 HTTPS 类型的代理 */
195
+ vhostHTTPSPort?: number;
196
+ /** tcpmux 类型且复用器为 httpconnect 的代理监听的端口 */
197
+ tcpmuxHTTPConnectPort?: number;
198
+ /** 对于 tcpmux 类型的代理是否透传 CONNECT 请求 */
199
+ tcpmuxPassthrough?: boolean;
200
+ /** 二级域名后缀 */
201
+ subDomainHost?: string;
202
+ /** 自定义 404 错误页面地址 */
203
+ custom404Page?: string;
204
+ /** ssh 隧道网关配置 */
205
+ sshTunnelGateway?: SSHTunnelGateway;
206
+ /** 服务端 Dashboard 配置 */
207
+ webServer?: WebServerConfig;
208
+ /** 是否提供 Prometheus 监控接口,需要同时启用了 webServer 后才会生效 */
209
+ enablePrometheus?: boolean;
210
+ /** 日志配置 */
211
+ log?: LogConfig;
212
+ /** 网络层配置 */
213
+ transport?: ServerTransportConfig;
214
+ /** 服务端返回详细错误信息给客户端,默认为 true */
215
+ detailedErrorsToClient?: boolean;
216
+ /** 限制单个客户端最大同时存在的代理数,默认无限制 */
217
+ maxPortsPerClient?: number;
218
+ /** 用户建立连接后等待客户端响应的超时时间,单位秒,默认为 10 秒 */
219
+ userConnTimeout?: number;
220
+ /** 代理 UDP 服务时支持的最大包长度,默认为 1500,服务端和客户端的值需要一致 */
221
+ udpPacketSize?: number;
222
+ /** 打洞策略数据的保留时间,默认为 168 小时,即 7 天 */
223
+ natholeAnalysisDataReserveHours?: number;
224
+ /** 允许代理绑定的服务端端口 */
225
+ allowPorts?: PortsRange[];
226
+ /** 服务端 HTTP 插件配置 */
227
+ httpPlugins?: HTTPPluginOptions[];
228
+ }
229
+
230
+ /**
231
+ * FRP 客户端配置类型定义
232
+ * 基于 frp 官方文档: https://gofrp.org/zh-cn/docs/reference/client-configures/
233
+ */
234
+
235
+ /** 客户端传输协议类型 */
236
+ type ClientTransportProtocol = 'tcp' | 'kcp' | 'quic' | 'websocket' | 'wss';
237
+ /** OIDC 客户端鉴权配置 */
238
+ interface AuthOIDCClientConfig {
239
+ /** OIDC 客户端 ID */
240
+ clientID?: string;
241
+ /** OIDC 客户端密钥 */
242
+ clientSecret?: string;
243
+ /** OIDC audience 参数 */
244
+ audience?: string;
245
+ /** OIDC scope 参数 */
246
+ scope?: string;
247
+ /** OIDC 令牌端点 URL */
248
+ tokenEndpointURL?: string;
249
+ /** 附加的端点参数 */
250
+ additionalEndpointParams?: Record<string, string>;
251
+ /** 信任的 CA 证书文件路径,用于验证 OIDC 服务器的 TLS 证书 */
252
+ trustedCaFile?: string;
253
+ /** 跳过 TLS 证书验证,不推荐在生产环境使用 */
254
+ insecureSkipVerify?: boolean;
255
+ /** 访问 OIDC 令牌端点时使用的代理服务器 URL */
256
+ proxyURL?: string;
257
+ }
258
+ /** 客户端鉴权配置 */
259
+ interface AuthClientConfig {
260
+ /** 鉴权方式,可选值为 token 或 oidc,默认为 token */
261
+ method?: AuthMethod;
262
+ /** 鉴权信息附加范围,可选值为 HeartBeats 和 NewWorkConns */
263
+ additionalScopes?: AuthScope[];
264
+ /** 在 method 为 token 时生效,客户端需要设置一样的值才能鉴权通过。与 tokenSource 字段互斥 */
265
+ token?: string;
266
+ /** 从文件中加载 token 的配置。与 token 字段互斥 */
267
+ tokenSource?: ValueSource;
268
+ /** oidc 鉴权配置 */
269
+ oidc?: AuthOIDCClientConfig;
270
+ }
271
+ /** 客户端 TLS 配置 */
272
+ interface TLSClientConfig extends TLSConfig {
273
+ /** 是否和服务端之间启用 TLS 连接,默认启用 */
274
+ enable?: boolean;
275
+ /** 启用 TLS 连接时,不发送 0x17 特殊字节。默认为 true。当配置为 true 时,无法和 vhostHTTPSPort 端口复用 */
276
+ disableCustomTLSFirstByte?: boolean;
277
+ }
278
+ /** 客户端传输层配置 */
279
+ interface ClientTransportConfig {
280
+ /** 和 frps 之间的通信协议,可选值为 tcp, kcp, quic, websocket, wss。默认为 tcp */
281
+ protocol?: ClientTransportProtocol;
282
+ /** 连接服务端的超时时间,默认为 10s */
283
+ dialServerTimeout?: number;
284
+ /** 和服务端底层 TCP 连接的 keepalive 间隔时间,单位秒 */
285
+ dialServerKeepalive?: number;
286
+ /** 连接服务端时所绑定的本地 IP */
287
+ connectServerLocalIP?: string;
288
+ /** 连接服务端使用的代理地址,格式为 {protocol}://user:passwd@192.168.1.128:8080 protocol 目前支持 http、socks5、ntlm */
289
+ proxyURL?: string;
290
+ /** 连接池大小 */
291
+ poolCount?: number;
292
+ /** TCP 多路复用,默认启用 */
293
+ tcpMux?: boolean;
294
+ /** tcp_mux 的心跳检查间隔时间 */
295
+ tcpMuxKeepaliveInterval?: number;
296
+ /** QUIC 协议配置参数 */
297
+ quic?: QUICOptions;
298
+ /** 向服务端发送心跳包的间隔时间,默认为 30s。建议启用 tcp_mux_keepalive_interval,将此值设置为 -1 */
299
+ heartbeatInterval?: number;
300
+ /** 和服务端心跳的超时时间,默认为 90s */
301
+ heartbeatTimeout?: number;
302
+ /** 客户端 TLS 协议配置 */
303
+ tls?: TLSClientConfig;
304
+ }
305
+ /** 虚拟网络配置 */
306
+ interface VirtualNetConfig {
307
+ /** 虚拟网络接口的 IP 地址和网段,格式为 CIDR (例如 "100.86.0.1/24") */
308
+ address: string;
309
+ }
310
+ /** 客户端通用配置 */
311
+ interface ClientCommonConfig {
312
+ /** 客户端鉴权配置 */
313
+ auth?: AuthClientConfig;
314
+ /** 用户名,设置此参数后,代理名称会被修改为 {user}.{proxyName},避免代理名称和其他用户冲突 */
315
+ user?: string;
316
+ /** 连接服务端的地址 */
317
+ serverAddr?: string;
318
+ /** 连接服务端的端口,默认为 7000 */
319
+ serverPort?: number;
320
+ /** xtcp 打洞所需的 stun 服务器地址,默认为 stun.easyvoip.com:3478 */
321
+ natHoleStunServer?: string;
322
+ /** 使用 DNS 服务器地址,默认使用系统配置的 DNS 服务器,指定此参数可以强制替换为自定义的 DNS 服务器地址 */
323
+ dnsServer?: string;
324
+ /** 第一次登陆失败后是否退出,默认为 true */
325
+ loginFailExit?: boolean;
326
+ /** 指定启用部分代理,当配置了较多代理,但是只希望启用其中部分时可以通过此参数指定,默认为全部启用 */
327
+ start?: string[];
328
+ /** 日志配置 */
329
+ log?: LogConfig;
330
+ /** 客户端 AdminServer 配置 */
331
+ webServer?: WebServerConfig;
332
+ /** 客户端网络层配置 */
333
+ transport?: ClientTransportConfig;
334
+ /** 虚拟网络配置,Alpha 特性 */
335
+ virtualNet?: VirtualNetConfig;
336
+ /** 特性门控,用于启用或禁用实验性功能 */
337
+ featureGates?: Record<string, boolean>;
338
+ /** 代理 UDP 服务时支持的最大包长度,默认为 1500,服务端和客户端需要保持配置一致 */
339
+ udpPacketSize?: number;
340
+ /** 附加元数据,会传递给服务端插件,提供附加能力 */
341
+ metadatas?: Record<string, string>;
342
+ /** 指定额外的配置文件目录,其中的 proxy 和 visitor 配置会被读取加载 */
343
+ includes?: string[];
344
+ }
345
+ /** 客户端配置 */
346
+ interface ClientConfig extends ClientCommonConfig {
347
+ }
348
+
349
+ /**
350
+ * FRP Proxy configuration types
351
+ * Based on: https://gofrp.org/zh-cn/docs/reference/proxy-config/
352
+ */
353
+ /** Proxy type */
354
+ type ProxyType = 'tcp' | 'udp' | 'http' | 'https' | 'tcpmux' | 'stcp' | 'xtcp' | 'sudp';
355
+ /** Load balancer strategy */
356
+ type LoadBalancerStrategy = 'random' | 'round_robin';
357
+ /** Base proxy configuration */
358
+ interface BaseProxyConfig {
359
+ /** Proxy name (unique) */
360
+ name: string;
361
+ /** Proxy type */
362
+ type: ProxyType;
363
+ /** Local IP to bind */
364
+ localIP?: string;
365
+ /** Local port */
366
+ localPort?: number;
367
+ /** Additional metadata */
368
+ annotations?: Record<string, string>;
369
+ /** Custom metadata passed to server plugins */
370
+ metadatas?: Record<string, string>;
371
+ /** Load balancer settings */
372
+ loadBalancer?: {
373
+ /** Load balancing strategy */
374
+ strategy?: LoadBalancerStrategy;
375
+ /** Health check configuration */
376
+ healthCheck?: {
377
+ /** Health check type */
378
+ type?: 'tcp' | 'http';
379
+ /** Health check timeout (seconds) */
380
+ timeoutSeconds?: number;
381
+ /** Max failed checks before marking unhealthy */
382
+ maxFailed?: number;
383
+ /** Check interval (seconds) */
384
+ intervalSeconds?: number;
385
+ /** HTTP health check path */
386
+ path?: string;
387
+ };
388
+ };
389
+ /** Enable bandwidth limit */
390
+ transport?: {
391
+ /** Bandwidth limit (KB/s) */
392
+ bandwidthLimit?: string;
393
+ /** Bandwidth limit mode */
394
+ bandwidthLimitMode?: 'client' | 'server';
395
+ };
396
+ }
397
+ /** TCP proxy configuration */
398
+ interface TCPProxyConfig extends BaseProxyConfig {
399
+ type: 'tcp';
400
+ /** Remote port on server */
401
+ remotePort?: number;
402
+ }
403
+ /** UDP proxy configuration */
404
+ interface UDPProxyConfig extends BaseProxyConfig {
405
+ type: 'udp';
406
+ /** Remote port on server */
407
+ remotePort?: number;
408
+ }
409
+ /** HTTP proxy configuration */
410
+ interface HTTPProxyConfig extends BaseProxyConfig {
411
+ type: 'http';
412
+ /** Custom domain names */
413
+ customDomains?: string[];
414
+ /** Subdomain under server's subdomain_host */
415
+ subdomain?: string;
416
+ /** Locations to proxy */
417
+ locations?: string[];
418
+ /** Host header rewrite */
419
+ hostHeaderRewrite?: string;
420
+ /** HTTP username for basic auth */
421
+ httpUser?: string;
422
+ /** HTTP password for basic auth */
423
+ httpPassword?: string;
424
+ /** Request headers to set */
425
+ requestHeaders?: {
426
+ set?: Record<string, string>;
427
+ };
428
+ /** Response headers to set */
429
+ responseHeaders?: {
430
+ set?: Record<string, string>;
431
+ };
432
+ /** Route by HTTP user */
433
+ routeByHTTPUser?: string;
434
+ }
435
+ /** HTTPS proxy configuration */
436
+ interface HTTPSProxyConfig extends BaseProxyConfig {
437
+ type: 'https';
438
+ /** Custom domain names */
439
+ customDomains?: string[];
440
+ /** Subdomain under server's subdomain_host */
441
+ subdomain?: string;
442
+ }
443
+ /** TCPMUX proxy configuration */
444
+ interface TCPMUXProxyConfig extends BaseProxyConfig {
445
+ type: 'tcpmux';
446
+ /** Multiplexer type */
447
+ multiplexer?: 'httpconnect';
448
+ /** Custom domain names */
449
+ customDomains?: string[];
450
+ /** Subdomain under server's subdomain_host */
451
+ subdomain?: string;
452
+ /** Route by HTTP user */
453
+ routeByHTTPUser?: string;
454
+ /** HTTP username */
455
+ httpUser?: string;
456
+ /** HTTP password */
457
+ httpPassword?: string;
458
+ }
459
+ /** STCP proxy configuration */
460
+ interface STCPProxyConfig extends BaseProxyConfig {
461
+ type: 'stcp';
462
+ /** Secret key shared with visitor */
463
+ secretKey?: string;
464
+ /** Allowed visitor users */
465
+ allowUsers?: string[];
466
+ }
467
+ /** XTCP proxy configuration */
468
+ interface XTCPProxyConfig extends BaseProxyConfig {
469
+ type: 'xtcp';
470
+ /** Secret key shared with visitor */
471
+ secretKey?: string;
472
+ /** Allowed visitor users */
473
+ allowUsers?: string[];
474
+ }
475
+ /** SUDP proxy configuration */
476
+ interface SUDPProxyConfig extends BaseProxyConfig {
477
+ type: 'sudp';
478
+ /** Secret key shared with visitor */
479
+ secretKey?: string;
480
+ /** Allowed visitor users */
481
+ allowUsers?: string[];
482
+ }
483
+ /** Union type of all proxy configurations */
484
+ type ProxyConfig = TCPProxyConfig | UDPProxyConfig | HTTPProxyConfig | HTTPSProxyConfig | TCPMUXProxyConfig | STCPProxyConfig | XTCPProxyConfig | SUDPProxyConfig;
485
+ /** Visitor type */
486
+ type VisitorType = 'stcp' | 'xtcp' | 'sudp';
487
+ /** Base visitor configuration */
488
+ interface BaseVisitorConfig {
489
+ /** Visitor name (unique) */
490
+ name: string;
491
+ /** Visitor type */
492
+ type: VisitorType;
493
+ /** Server name to connect to */
494
+ serverName: string;
495
+ /** Secret key shared with proxy */
496
+ secretKey?: string;
497
+ /** Local IP to bind */
498
+ bindAddr?: string;
499
+ /** Local port to bind */
500
+ bindPort?: number;
501
+ }
502
+ /** STCP visitor configuration */
503
+ interface STCPVisitorConfig extends BaseVisitorConfig {
504
+ type: 'stcp';
505
+ }
506
+ /** XTCP visitor configuration */
507
+ interface XTCPVisitorConfig extends BaseVisitorConfig {
508
+ type: 'xtcp';
509
+ /** Keep tunnel alive even when no connection */
510
+ keepTunnelOpen?: boolean;
511
+ /** Max retries for establishing connection */
512
+ maxRetriesAnHour?: number;
513
+ /** Min retry interval (seconds) */
514
+ minRetryInterval?: number;
515
+ /** Fallback to STCP when XTCP fails */
516
+ fallbackTo?: string;
517
+ /** Fallback timeout (seconds) */
518
+ fallbackTimeoutMs?: number;
519
+ }
520
+ /** SUDP visitor configuration */
521
+ interface SUDPVisitorConfig extends BaseVisitorConfig {
522
+ type: 'sudp';
523
+ }
524
+ /** Union type of all visitor configurations */
525
+ type VisitorConfig = STCPVisitorConfig | XTCPVisitorConfig | SUDPVisitorConfig;
526
+
527
+ export type { AuthClientConfig, AuthMethod, AuthOIDCClientConfig, AuthOIDCServerConfig, AuthScope, AuthServerConfig, BaseProxyConfig, BaseVisitorConfig, ClientCommonConfig, ClientConfig, ClientTransportConfig, ClientTransportProtocol, FileSource, HTTPHeader, HTTPPluginOptions, HTTPProxyConfig, HTTPSProxyConfig, HeaderOperations, LoadBalancerStrategy, LogConfig, LogLevel, NatTraversalConfig, PortsRange, ProxyConfig, ProxyType, QUICOptions, SSHTunnelGateway, STCPProxyConfig, STCPVisitorConfig, SUDPProxyConfig, SUDPVisitorConfig, ServerConfig, ServerTransportConfig, TCPMUXProxyConfig, TCPProxyConfig, TLSClientConfig, TLSConfig, TLSServerConfig, UDPProxyConfig, ValueSource, ValueSourceType, VirtualNetConfig, VisitorConfig, VisitorType, WebServerConfig, XTCPProxyConfig, XTCPVisitorConfig };
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@frp-bridge/types",
3
+ "type": "module",
4
+ "version": "0.0.1",
5
+ "description": "Frp bridge type definitions",
6
+ "license": "MIT",
7
+ "homepage": "https://github.com/frp-web/bridge#readme",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git@github.com:frp-web/bridge.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/frp-web/bridge/issues"
14
+ },
15
+ "keywords": [
16
+ "frp",
17
+ "bridge",
18
+ "types",
19
+ "typescript"
20
+ ],
21
+ "main": "dist/index.mjs",
22
+ "module": "dist/index.mjs",
23
+ "types": "dist/index.d.ts",
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "scripts": {
28
+ "stub": "unbuild --stub",
29
+ "build": "unbuild"
30
+ }
31
+ }