@black-duty/sing-box-schema 1.12.2

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.cjs ADDED
@@ -0,0 +1,4117 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+
23
+ //#endregion
24
+ const zod = __toESM(require("zod"));
25
+
26
+ //#region src/utils.ts
27
+ /**
28
+ * Create a new Zod schema that allows either a single value of type `T` or an
29
+ * array of values of type `T`. This is useful for defining configuration
30
+ * options that can be either a single value or a list of values.
31
+ *
32
+ * @example
33
+ * const port = z.number().int().refine((v) => v > 0 && v < 65536);
34
+ * const ports = listable(port);
35
+ * ports.parse(42); // => 42
36
+ * ports.parse([42, 8080]); // => [42, 8080]
37
+ *
38
+ * @param {z.ZodTypeAny} schema
39
+ * @returns {z.ZodTypeAny}
40
+ */
41
+ const listable = (schema) => zod.default.union([schema, zod.default.array(schema)]);
42
+ /**
43
+ * Create a new Zod schema that allows either a single string or an array of
44
+ * strings. This is useful for defining configuration options that can be either
45
+ * a single string or a list of strings.
46
+ */
47
+ const listableString = listable(zod.default.string());
48
+ /**
49
+ * Create a new Zod schema that allows either a single number or an array of
50
+ * integers. This is useful for defining configuration options that can be either
51
+ * a single number or a list of numbers.
52
+ *
53
+ */
54
+ const listableInts = listable(zod.default.number().int());
55
+
56
+ //#endregion
57
+ //#region src/schema/certificate.ts
58
+ /**
59
+ * Certificate settings for sing-box.
60
+ */
61
+ const CertificateOptions = zod.z.object({
62
+ store: zod.z.enum([
63
+ "system",
64
+ "mozilla",
65
+ "none"
66
+ ]).optional().meta({ description: "The default X509 trusted CA certificate list." }),
67
+ certificate: listableString.optional().meta({ description: "The certificate line array to trust, in PEM format." }),
68
+ certificate_path: listableString.optional().meta({ description: "The paths to certificates to trust, in PEM format." }),
69
+ certificate_directory_path: listableString.optional().meta({ description: "The directory path to search for certificates to trust,in PEM format." })
70
+ }).meta({
71
+ id: "CertificateOptions",
72
+ title: "Certificate",
73
+ description: "Certificate settings for sing-box."
74
+ });
75
+
76
+ //#endregion
77
+ //#region src/schema/shared.ts
78
+ const DomainStrategy = zod.z.enum([
79
+ "",
80
+ "prefer_ipv4",
81
+ "prefer_ipv6",
82
+ "ipv4_only",
83
+ "ipv6_only"
84
+ ]).meta({
85
+ description: "Default domain strategy for resolving the domain names.",
86
+ description_zh: "默认解析域名策略。"
87
+ });
88
+ const FwMark = zod.z.union([zod.z.number().int(), zod.z.string()]).meta({
89
+ description: "Set netfilter routing mark.",
90
+ description_zh: "设置 netfilter 路由标记。"
91
+ });
92
+ const Network = listable(zod.z.enum([
93
+ "",
94
+ "tcp",
95
+ "udp"
96
+ ])).meta({
97
+ description: "Network protocol, `tcp` or `udp`.",
98
+ description_zh: "网络协议,`tcp` 或 `udp`。"
99
+ });
100
+ const Tag = zod.z.string().optional().meta({
101
+ description: "Tag of the inbound/outbound/service/endpoint.",
102
+ description_zh: "入站/出站/服务/端点的标签。"
103
+ });
104
+ const IpVersion = zod.z.union([zod.z.literal(4), zod.z.literal(6)]).meta({
105
+ description: "IP version, 4 or 6.",
106
+ description_zh: "IP 版本,4 或 6。"
107
+ });
108
+ const HttpHeader = zod.z.record(zod.z.string(), zod.z.string()).meta({
109
+ description: "HTTP headers.",
110
+ description_zh: "HTTP 标头。"
111
+ });
112
+ const InboundOptions = zod.z.object({
113
+ sniff: zod.z.boolean().optional().meta({
114
+ description: "Enable sniffing.",
115
+ description_zh: "启用协议探测。",
116
+ deprecated: true
117
+ }),
118
+ sniff_override_destination: zod.z.boolean().optional().meta({
119
+ description: "Override the connection destination address with the sniffed domain.",
120
+ description_zh: "用探测出的域名覆盖连接目标地址。",
121
+ deprecated: true
122
+ }),
123
+ sniff_timeout: zod.z.string().optional().meta({
124
+ description: "Timeout for sniffing.",
125
+ description_zh: "探测超时时间。",
126
+ deprecated: true
127
+ }),
128
+ domain_strategy: DomainStrategy.optional().meta({
129
+ description: "If set, the requested domain name will be resolved to IP before routing.",
130
+ description_zh: "如果设置,请求的域名将在路由之前解析为 IP。",
131
+ deprecated: true
132
+ }),
133
+ udp_disable_domain_unmapping: zod.z.boolean().optional().meta({
134
+ description: "If enabled, for UDP proxy requests addressed to a domain, the original packet address will be sent in the response instead of the mapped domain.",
135
+ description_zh: "如果启用,对于地址为域的 UDP 代理请求,将在响应中发送原始包地址而不是映射的域。",
136
+ deprecated: true
137
+ }),
138
+ detour: zod.z.string().optional().meta({
139
+ description: "If set, connections will be forwarded to the specified inbound.",
140
+ description_zh: "如果设置,连接将被转发到指定的入站。"
141
+ })
142
+ });
143
+ const ListenOptions = zod.z.object({
144
+ listen: zod.z.string().optional().meta({
145
+ description: "Listen address.",
146
+ description_zh: "监听地址。"
147
+ }),
148
+ listen_port: zod.z.number().int().optional().meta({
149
+ description: "Listen port.",
150
+ description_zh: "监听端口。"
151
+ }),
152
+ bind_interface: zod.z.string().optional().meta({
153
+ description: "The network interface to bind to.",
154
+ description_zh: "要绑定到的网络接口。"
155
+ }),
156
+ routing_mark: FwMark.optional().meta({
157
+ description: "Set netfilter routing mark.",
158
+ description_zh: "设置 netfilter 路由标记。"
159
+ }),
160
+ reuse_addr: zod.z.boolean().optional().meta({
161
+ description: "Reuse listener address.",
162
+ description_zh: "重用监听地址。"
163
+ }),
164
+ netns: zod.z.string().optional().meta({
165
+ description: "Set network namespace, name or path.",
166
+ description_zh: "设置网络命名空间,名称或路径。"
167
+ }),
168
+ tcp_keep_alive: zod.z.string().optional().meta({
169
+ description: "TCP keep alive interval.",
170
+ description_zh: "TCP keep alive 间隔。"
171
+ }),
172
+ tcp_keep_alive_interval: zod.z.string().optional().meta({
173
+ description: "TCP keep alive interval.",
174
+ description_zh: "TCP keep alive 间隔。"
175
+ }),
176
+ tcp_fast_open: zod.z.boolean().optional().meta({
177
+ description: "Enable TCP Fast Open.",
178
+ description_zh: "启用 TCP Fast Open。"
179
+ }),
180
+ tcp_multi_path: zod.z.boolean().optional().meta({
181
+ description: "Enable TCP Multi Path.",
182
+ description_zh: "启用 TCP Multi Path。"
183
+ }),
184
+ udp_fragment: zod.z.boolean().optional().meta({
185
+ description: "Enable UDP fragmentation.",
186
+ description_zh: "启用 UDP 分段。"
187
+ }),
188
+ udp_timeout: zod.z.union([zod.z.string(), zod.z.number()]).optional().meta({
189
+ description: "UDP NAT expiration time.",
190
+ description_zh: "UDP NAT 过期时间。"
191
+ }),
192
+ ...InboundOptions.shape
193
+ }).meta({
194
+ id: "ListenOptions",
195
+ title: "Listen Options",
196
+ title_zh: "监听选项"
197
+ });
198
+ const NetworkType = zod.z.enum([
199
+ "wifi",
200
+ "cellular",
201
+ "ethernet",
202
+ "other"
203
+ ]).meta({
204
+ description: "Network type.",
205
+ description_zh: "网络类型。"
206
+ });
207
+ const NetworkStrategy = zod.z.object({
208
+ network_type: listable(NetworkType).optional().meta({
209
+ description: "Network types to use.",
210
+ description_zh: "要使用的网络类型。"
211
+ }),
212
+ fallback_network_type: listable(NetworkType).optional().meta({
213
+ description: "Fallback network types.",
214
+ description_zh: "备用网络类型。"
215
+ }),
216
+ fallback_delay: zod.z.string().optional().meta({
217
+ description: "The length of time to wait before spawning a RFC 6555 Fast Fallback connection.",
218
+ description_zh: "在生成 RFC 6555 快速回退连接之前等待的时间长度。"
219
+ })
220
+ }).meta({
221
+ id: "NetworkStrategy",
222
+ title: "Network Strategy",
223
+ title_zh: "网络策略"
224
+ });
225
+ const DomainResolverOptions = zod.z.object({
226
+ server: zod.z.string().meta({
227
+ description: "Tag of a another server to resolve the domain name in the address.",
228
+ description_zh: "用于解析本 DNS 服务器的域名的另一个 DNS 服务器的标签。"
229
+ }),
230
+ strategy: DomainStrategy.optional().meta({
231
+ description: "The domain strategy for resolving the domain name in the address.",
232
+ description_zh: "用于解析本 DNS 服务器的域名的策略。"
233
+ }),
234
+ disable_cache: zod.z.boolean().optional().meta({
235
+ description: "Disable cache and save cache in this query.",
236
+ description_zh: "在此查询中禁用缓存。"
237
+ }),
238
+ rewrite_ttl: zod.z.number().int().optional().meta({
239
+ description: "Rewrite TTL in DNS responses.",
240
+ description_zh: "重写 DNS 回应中的 TTL。"
241
+ }),
242
+ client_subnet: zod.z.string().optional().meta({
243
+ description: "Append a `edns0-subnet` OPT extra record with the specified IP prefix to every query by default.",
244
+ description_zh: "默认情况下,将带有指定 IP 前缀的 `edns0-subnet` OPT 附加记录附加到每个查询。"
245
+ })
246
+ }).meta({
247
+ id: "DomainResolverOptions",
248
+ title: "Domain Resolver Options",
249
+ title_zh: "域名解析器选项"
250
+ });
251
+ const DialerOptions = zod.z.object({
252
+ detour: zod.z.string().optional().meta({
253
+ description: "The tag of the upstream outbound.",
254
+ description_zh: "上游出站的标签。"
255
+ }),
256
+ bind_interface: zod.z.string().optional().meta({
257
+ description: "The network interface to bind to.",
258
+ description_zh: "要绑定到的网络接口。"
259
+ }),
260
+ inet4_bind_address: zod.z.string().optional().meta({
261
+ description: "The IPv4 address to bind to.",
262
+ description_zh: "要绑定的 IPv4 地址。"
263
+ }),
264
+ inet6_bind_address: zod.z.string().optional().meta({
265
+ description: "The IPv6 address to bind to.",
266
+ description_zh: "要绑定的 IPv6 地址。"
267
+ }),
268
+ routing_mark: FwMark.optional().meta({
269
+ description: "Set netfilter routing mark.",
270
+ description_zh: "设置 netfilter 路由标记。"
271
+ }),
272
+ reuse_addr: zod.z.boolean().optional().meta({
273
+ description: "Reuse listener address.",
274
+ description_zh: "重用监听地址。"
275
+ }),
276
+ netns: zod.z.string().optional().meta({
277
+ description: "Set network namespace, name or path.",
278
+ description_zh: "设置网络命名空间,名称或路径。"
279
+ }),
280
+ connect_timeout: zod.z.string().optional().meta({
281
+ description: "Connect timeout, in golang's Duration format.",
282
+ description_zh: "连接超时,采用 golang 的 Duration 格式。"
283
+ }),
284
+ tcp_fast_open: zod.z.boolean().optional().meta({
285
+ description: "Enable TCP Fast Open.",
286
+ description_zh: "启用 TCP Fast Open。"
287
+ }),
288
+ tcp_multi_path: zod.z.boolean().optional().meta({
289
+ description: "Enable TCP Multi Path.",
290
+ description_zh: "启用 TCP Multi Path。"
291
+ }),
292
+ udp_fragment: zod.z.boolean().optional().meta({
293
+ description: "Enable UDP fragmentation.",
294
+ description_zh: "启用 UDP 分段。"
295
+ }),
296
+ domain_resolver: zod.z.union([zod.z.string(), DomainResolverOptions]).optional().meta({
297
+ description: "Set domain resolver to use for resolving domain names.",
298
+ description_zh: "用于设置解析域名的域名解析器。"
299
+ }),
300
+ network_strategy: zod.z.union([zod.z.string(), NetworkStrategy]).optional().meta({
301
+ description: "Strategy for selecting network interfaces.",
302
+ description_zh: "用于选择网络接口的策略。"
303
+ }),
304
+ network_type: listable(NetworkType).optional().meta({
305
+ description: "Network types to use.",
306
+ description_zh: "要使用的网络类型。"
307
+ }),
308
+ fallback_network_type: listable(NetworkType).optional().meta({
309
+ description: "Fallback network types.",
310
+ description_zh: "备用网络类型。"
311
+ }),
312
+ fallback_delay: zod.z.string().optional().meta({
313
+ description: "The length of time to wait before spawning a RFC 6555 Fast Fallback connection.",
314
+ description_zh: "在生成 RFC 6555 快速回退连接之前等待的时间长度。"
315
+ }),
316
+ domain_strategy: DomainStrategy.optional().meta({
317
+ description: "Default domain strategy for resolving the domain names.",
318
+ description_zh: "默认解析域名策略。",
319
+ deprecated: true
320
+ })
321
+ }).meta({
322
+ id: "DialerOptions",
323
+ title: "Dialer Options",
324
+ title_zh: "拨号选项"
325
+ });
326
+ const ServerOptions = zod.z.object({
327
+ server: zod.z.string().meta({
328
+ description: "The server address.",
329
+ description_zh: "服务器地址。"
330
+ }),
331
+ server_port: zod.z.number().int().optional().meta({
332
+ description: "The server port.",
333
+ description_zh: "服务器端口。"
334
+ })
335
+ }).meta({
336
+ id: "ServerOptions",
337
+ title: "Server Options",
338
+ title_zh: "服务器选项"
339
+ });
340
+ const TLSVersion = zod.z.enum([
341
+ "1.0",
342
+ "1.1",
343
+ "1.2",
344
+ "1.3"
345
+ ]).meta({
346
+ description: "TLS version.",
347
+ description_zh: "TLS 版本。"
348
+ });
349
+ const TLSCipherSuite = zod.z.enum([
350
+ "TLS_RSA_WITH_AES_128_CBC_SHA",
351
+ "TLS_RSA_WITH_AES_256_CBC_SHA",
352
+ "TLS_RSA_WITH_AES_128_GCM_SHA256",
353
+ "TLS_RSA_WITH_AES_256_GCM_SHA384",
354
+ "TLS_AES_128_GCM_SHA256",
355
+ "TLS_AES_256_GCM_SHA384",
356
+ "TLS_CHACHA20_POLY1305_SHA256",
357
+ "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA",
358
+ "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA",
359
+ "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
360
+ "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",
361
+ "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
362
+ "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
363
+ "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
364
+ "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
365
+ "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256",
366
+ "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256"
367
+ ]).meta({
368
+ description: "TLS cipher suite.",
369
+ description_zh: "TLS 密码套件。"
370
+ });
371
+ const DNS01Challenge = zod.z.object({
372
+ provider: zod.z.string().meta({
373
+ description: "ACME CA provider.",
374
+ description_zh: "ACME CA 供应商。"
375
+ }),
376
+ access_key_id: zod.z.string().optional().meta({
377
+ description: "The access key ID.",
378
+ description_zh: "访问密钥 ID。"
379
+ }),
380
+ access_key_secret: zod.z.string().optional().meta({
381
+ description: "The access key secret.",
382
+ description_zh: "访问密钥 secret。"
383
+ }),
384
+ region_id: zod.z.string().optional().meta({
385
+ description: "The region ID.",
386
+ description_zh: "区域 ID。"
387
+ }),
388
+ api_token: zod.z.string().optional().meta({
389
+ description: "The API token.",
390
+ description_zh: "API 令牌。"
391
+ })
392
+ }).meta({
393
+ id: "DNS01Challenge",
394
+ title: "DNS01 Challenge",
395
+ title_zh: "DNS01 质询"
396
+ });
397
+ const InboundACMEOptions = zod.z.object({
398
+ domain: listableString.optional().meta({
399
+ description: "List of domain.",
400
+ description_zh: "域名列表。"
401
+ }),
402
+ data_directory: zod.z.string().optional().meta({
403
+ description: "The directory to store ACME data.",
404
+ description_zh: "存储 ACME 数据的目录。"
405
+ }),
406
+ default_server_name: zod.z.string().optional().meta({
407
+ description: "Server name to use when choosing a certificate if the ClientHello's ServerName field is empty.",
408
+ description_zh: "如果 ClientHello 的 ServerName 字段为空,则选择证书时要使用的服务器名称。"
409
+ }),
410
+ email: zod.z.string().optional().meta({
411
+ description: "The email address to use when creating or selecting an existing ACME server account.",
412
+ description_zh: "创建或选择现有 ACME 服务器帐户时使用的电子邮件地址。"
413
+ }),
414
+ provider: zod.z.string().optional().meta({
415
+ description: "The ACME CA provider to use.",
416
+ description_zh: "要使用的 ACME CA 供应商。"
417
+ }),
418
+ disable_http_challenge: zod.z.boolean().optional().meta({
419
+ description: "Disable all HTTP challenges.",
420
+ description_zh: "禁用所有 HTTP 质询。"
421
+ }),
422
+ disable_tls_alpn_challenge: zod.z.boolean().optional().meta({
423
+ description: "Disable all TLS-ALPN challenges.",
424
+ description_zh: "禁用所有 TLS-ALPN 质询。"
425
+ }),
426
+ alternative_http_port: zod.z.number().int().optional().meta({
427
+ description: "The alternate port to use for the ACME HTTP challenge.",
428
+ description_zh: "用于 ACME HTTP 质询的备用端口。"
429
+ }),
430
+ alternative_tls_port: zod.z.number().int().optional().meta({
431
+ description: "The alternate port to use for the ACME TLS-ALPN challenge.",
432
+ description_zh: "用于 ACME TLS-ALPN 质询的备用端口。"
433
+ }),
434
+ external_account: zod.z.object({
435
+ key_id: zod.z.string().meta({
436
+ description: "The key identifier.",
437
+ description_zh: "密钥标识符。"
438
+ }),
439
+ mac_key: zod.z.string().meta({
440
+ description: "The MAC key.",
441
+ description_zh: "MAC 密钥。"
442
+ })
443
+ }).optional().meta({
444
+ description: "EAB (External Account Binding) contains information necessary to bind or map an ACME account to some other account known by the CA.",
445
+ description_zh: "EAB(外部帐户绑定)包含将 ACME 帐户绑定或映射到其他已知帐户所需的信息。"
446
+ }),
447
+ dns01_challenge: DNS01Challenge.optional().meta({
448
+ description: "ACME DNS01 challenge field.",
449
+ description_zh: "ACME DNS01 验证字段。"
450
+ })
451
+ }).meta({
452
+ id: "InboundACMEOptions",
453
+ title: "Inbound ACME Options",
454
+ title_zh: "入站 ACME 选项"
455
+ });
456
+ const InboundECHOptions = zod.z.object({
457
+ enabled: zod.z.boolean().optional().meta({
458
+ description: "Enable ECH.",
459
+ description_zh: "启用 ECH。"
460
+ }),
461
+ key: listableString.optional().meta({
462
+ description: "ECH key line array, in PEM format.",
463
+ description_zh: "ECH PEM 密钥行数组。"
464
+ }),
465
+ key_path: zod.z.string().optional().meta({
466
+ description: "The path to ECH key, in PEM format.",
467
+ description_zh: "ECH PEM 密钥路径。"
468
+ })
469
+ }).meta({
470
+ id: "InboundECHOptions",
471
+ title: "Inbound ECH Options",
472
+ title_zh: "入站 ECH 选项"
473
+ });
474
+ const InboundRealityOptions = zod.z.object({
475
+ enabled: zod.z.boolean().optional().meta({
476
+ description: "Enable Reality.",
477
+ description_zh: "启用 Reality。"
478
+ }),
479
+ handshake: zod.z.object({
480
+ ...ServerOptions.shape,
481
+ ...DialerOptions.shape
482
+ }).optional().meta({
483
+ description: "Handshake server address and Dial Fields.",
484
+ description_zh: "握手服务器地址和拨号参数。"
485
+ }),
486
+ private_key: zod.z.string().optional().meta({
487
+ description: "Private key, generated by `sing-box generate reality-keypair`.",
488
+ description_zh: "私钥,由 `sing-box generate reality-keypair` 生成。"
489
+ }),
490
+ short_id: listableString.optional().meta({
491
+ description: "A hexadecimal string with zero to eight digits.",
492
+ description_zh: "一个零到八位的十六进制字符串。"
493
+ }),
494
+ max_time_difference: zod.z.string().optional().meta({
495
+ description: "The maximum time difference between the server and the client.",
496
+ description_zh: "服务器与和客户端之间允许的最大时间差。"
497
+ })
498
+ }).meta({
499
+ id: "InboundRealityOptions",
500
+ title: "Inbound Reality Options",
501
+ title_zh: "入站 Reality 选项"
502
+ });
503
+ const InboundTLSOptions = zod.z.object({
504
+ enabled: zod.z.boolean().optional().meta({
505
+ description: "Enable TLS.",
506
+ description_zh: "启用 TLS。"
507
+ }),
508
+ server_name: zod.z.string().optional().meta({
509
+ description: "Used to verify the hostname on the returned certificates unless insecure is given.",
510
+ description_zh: "用于验证返回证书上的主机名,除非设置不安全。"
511
+ }),
512
+ alpn: listableString.optional().meta({
513
+ description: "List of supported application level protocols, in order of preference.",
514
+ description_zh: "支持的应用层协议协商列表,按优先顺序排列。"
515
+ }),
516
+ min_version: TLSVersion.optional().meta({
517
+ description: "The minimum TLS version that is acceptable.",
518
+ description_zh: "可接受的最低 TLS 版本。"
519
+ }),
520
+ max_version: TLSVersion.optional().meta({
521
+ description: "The maximum TLS version that is acceptable.",
522
+ description_zh: "可接受的最大 TLS 版本。"
523
+ }),
524
+ cipher_suites: listable(TLSCipherSuite).optional().meta({
525
+ description: "A list of enabled TLS 1.0–1.2 cipher suites.",
526
+ description_zh: "启用的 TLS 1.0-1.2 密码套件的列表。"
527
+ }),
528
+ certificate: listableString.optional().meta({
529
+ description: "The server certificate line array, in PEM format.",
530
+ description_zh: "服务器 PEM 证书行数组。"
531
+ }),
532
+ certificate_path: zod.z.string().optional().meta({
533
+ description: "The path to the server certificate, in PEM format.",
534
+ description_zh: "服务器 PEM 证书路径。"
535
+ }),
536
+ key: listableString.optional().meta({
537
+ description: "The server private key line array, in PEM format.",
538
+ description_zh: "服务器 PEM 私钥行数组。"
539
+ }),
540
+ key_path: zod.z.string().optional().meta({
541
+ description: "The path to the server private key, in PEM format.",
542
+ description_zh: "服务器 PEM 私钥路径。"
543
+ }),
544
+ acme: InboundACMEOptions.optional().meta({
545
+ description: "ACME (Automatic Certificate Management Environment) options.",
546
+ description_zh: "ACME(自动证书管理环境)选项。"
547
+ }),
548
+ ech: InboundECHOptions.optional().meta({
549
+ description: "ECH (Encrypted Client Hello) options.",
550
+ description_zh: "ECH(加密客户端 Hello)选项。"
551
+ }),
552
+ reality: InboundRealityOptions.optional().meta({
553
+ description: "Reality options.",
554
+ description_zh: "Reality 选项。"
555
+ })
556
+ }).meta({
557
+ id: "InboundTLSOptions",
558
+ title: "Inbound TLS Options",
559
+ title_zh: "入站 TLS 选项"
560
+ });
561
+ const OutboundECHOptions = zod.z.object({
562
+ enabled: zod.z.boolean().optional().meta({
563
+ description: "Enable ECH.",
564
+ description_zh: "启用 ECH。"
565
+ }),
566
+ config: listableString.optional().meta({
567
+ description: "ECH configuration line array, in PEM format.",
568
+ description_zh: "ECH PEM 配置行数组。"
569
+ }),
570
+ config_path: zod.z.string().optional().meta({
571
+ description: "The path to ECH configuration, in PEM format.",
572
+ description_zh: "ECH PEM 配置路径。"
573
+ })
574
+ }).meta({
575
+ id: "OutboundECHOptions",
576
+ title: "Outbound ECH Options",
577
+ title_zh: "出站 ECH 选项"
578
+ });
579
+ const OutboundUTLSOptions = zod.z.object({
580
+ enabled: zod.z.boolean().optional().meta({
581
+ description: "Enable uTLS.",
582
+ description_zh: "启用 uTLS。"
583
+ }),
584
+ fingerprint: zod.z.string().optional().meta({
585
+ description: "uTLS fingerprint.",
586
+ description_zh: "uTLS 指纹。"
587
+ })
588
+ }).meta({
589
+ id: "OutboundUTLSOptions",
590
+ title: "Outbound uTLS Options",
591
+ title_zh: "出站 uTLS 选项"
592
+ });
593
+ const OutboundRealityOptions = zod.z.object({
594
+ enabled: zod.z.boolean().optional().meta({
595
+ description: "Enable Reality.",
596
+ description_zh: "启用 Reality。"
597
+ }),
598
+ public_key: zod.z.string().optional().meta({
599
+ description: "Public key, generated by `sing-box generate reality-keypair`.",
600
+ description_zh: "公钥,由 `sing-box generate reality-keypair` 生成。"
601
+ }),
602
+ short_id: zod.z.string().optional().meta({
603
+ description: "A hexadecimal string with zero to eight digits.",
604
+ description_zh: "一个零到八位的十六进制字符串。"
605
+ })
606
+ }).meta({
607
+ id: "OutboundRealityOptions",
608
+ title: "Outbound Reality Options",
609
+ title_zh: "出站 Reality 选项"
610
+ });
611
+ const OutboundTLSOptions = zod.z.object({
612
+ enabled: zod.z.boolean().optional().meta({
613
+ description: "Enable TLS.",
614
+ description_zh: "启用 TLS。"
615
+ }),
616
+ disable_sni: zod.z.boolean().optional().meta({
617
+ description: "Do not send server name in ClientHello.",
618
+ description_zh: "不在 ClientHello 中发送服务器名称。"
619
+ }),
620
+ server_name: zod.z.string().optional().meta({
621
+ description: "Used to verify the hostname on the returned certificates unless insecure is given.",
622
+ description_zh: "用于验证返回证书上的主机名,除非设置不安全。"
623
+ }),
624
+ insecure: zod.z.boolean().optional().meta({
625
+ description: "Accepts any server certificate.",
626
+ description_zh: "接受任何服务器证书。"
627
+ }),
628
+ alpn: listableString.optional().meta({
629
+ description: "List of supported application level protocols, in order of preference.",
630
+ description_zh: "支持的应用层协议协商列表,按优先顺序排列。"
631
+ }),
632
+ min_version: TLSVersion.optional().meta({
633
+ description: "The minimum TLS version that is acceptable.",
634
+ description_zh: "可接受的最低 TLS 版本。"
635
+ }),
636
+ max_version: TLSVersion.optional().meta({
637
+ description: "The maximum TLS version that is acceptable.",
638
+ description_zh: "可接受的最大 TLS 版本。"
639
+ }),
640
+ cipher_suites: listable(TLSCipherSuite).optional().meta({
641
+ description: "A list of enabled TLS 1.0–1.2 cipher suites.",
642
+ description_zh: "启用的 TLS 1.0-1.2 密码套件的列表。"
643
+ }),
644
+ certificate: listableString.optional().meta({
645
+ description: "The server certificate line array, in PEM format.",
646
+ description_zh: "服务器 PEM 证书行数组。"
647
+ }),
648
+ certificate_path: zod.z.string().optional().meta({
649
+ description: "The path to the server certificate, in PEM format.",
650
+ description_zh: "服务器 PEM 证书路径。"
651
+ }),
652
+ fragment: zod.z.boolean().optional().meta({
653
+ description: "Fragment TLS handshakes to bypass firewalls.",
654
+ description_zh: "通过分段 TLS 握手数据包来绕过防火墙检测。"
655
+ }),
656
+ fragment_fallback_delay: zod.z.string().optional().meta({
657
+ description: "The fallback value used when TLS segmentation cannot automatically determine the wait time.",
658
+ description_zh: "当 TLS 分片功能无法自动判定等待时间时使用的回退值。"
659
+ }),
660
+ record_fragment: zod.z.boolean().optional().meta({
661
+ description: "Fragment TLS handshake into multiple TLS records to bypass firewalls.",
662
+ description_zh: "通过分段 TLS 握手数据包到多个 TLS 记录来绕过防火墙检测。"
663
+ }),
664
+ ech: OutboundECHOptions.optional().meta({
665
+ description: "ECH (Encrypted Client Hello) options.",
666
+ description_zh: "ECH(加密客户端 Hello)选项。"
667
+ }),
668
+ utls: OutboundUTLSOptions.optional().meta({
669
+ description: "uTLS options.",
670
+ description_zh: "uTLS 选项。"
671
+ }),
672
+ reality: OutboundRealityOptions.optional().meta({
673
+ description: "Reality options.",
674
+ description_zh: "Reality 选项。"
675
+ })
676
+ }).meta({
677
+ id: "OutboundTLSOptions",
678
+ title: "Outbound TLS Options",
679
+ title_zh: "出站 TLS 选项"
680
+ });
681
+ const BrutalOptions = zod.z.object({
682
+ enabled: zod.z.boolean().optional().meta({
683
+ description: "Enable TCP Brutal congestion control algorithm.",
684
+ description_zh: "启用 TCP Brutal 拥塞控制算法。"
685
+ }),
686
+ up_mbps: zod.z.number().int().optional().meta({
687
+ description: "Upload bandwidth, in Mbps.",
688
+ description_zh: "上传带宽,以 Mbps 为单位。"
689
+ }),
690
+ down_mbps: zod.z.number().int().optional().meta({
691
+ description: "Download bandwidth, in Mbps.",
692
+ description_zh: "下载带宽,以 Mbps 为单位。"
693
+ })
694
+ }).meta({
695
+ id: "BrutalOptions",
696
+ title: "Brutal Options",
697
+ title_zh: "Brutal 选项"
698
+ });
699
+ const InboundMultiplexOptions = zod.z.object({
700
+ enabled: zod.z.boolean().optional().meta({
701
+ description: "Enable multiplex support.",
702
+ description_zh: "启用多路复用支持。"
703
+ }),
704
+ padding: zod.z.boolean().optional().meta({
705
+ description: "If enabled, non-padded connections will be rejected.",
706
+ description_zh: "如果启用,将拒绝非填充连接。"
707
+ }),
708
+ brutal: BrutalOptions.optional().meta({
709
+ description: "TCP Brutal options.",
710
+ description_zh: "TCP Brutal 选项。"
711
+ })
712
+ }).meta({
713
+ id: "InboundMultiplexOptions",
714
+ title: "Inbound Multiplex Options",
715
+ title_zh: "入站多路复用选项"
716
+ });
717
+ const OutboundMultiplexOptions = zod.z.object({
718
+ enabled: zod.z.boolean().optional().meta({
719
+ description: "Enable multiplex.",
720
+ description_zh: "启用多路复用。"
721
+ }),
722
+ protocol: zod.z.enum([
723
+ "smux",
724
+ "yamux",
725
+ "h2mux"
726
+ ]).optional().meta({
727
+ description: "Multiplex protocol.",
728
+ description_zh: "多路复用协议。"
729
+ }),
730
+ max_connections: zod.z.number().int().optional().meta({
731
+ description: "Maximum connections.",
732
+ description_zh: "最大连接数量。"
733
+ }),
734
+ min_streams: zod.z.number().int().optional().meta({
735
+ description: "Minimum multiplexed streams in a connection before opening a new connection.",
736
+ description_zh: "在打开新连接之前,连接中的最小多路复用流数量。"
737
+ }),
738
+ max_streams: zod.z.number().int().optional().meta({
739
+ description: "Maximum multiplexed streams in a connection before opening a new connection.",
740
+ description_zh: "在打开新连接之前,连接中的最大多路复用流数量。"
741
+ }),
742
+ padding: zod.z.boolean().optional().meta({
743
+ description: "Enable padding.",
744
+ description_zh: "启用填充。"
745
+ }),
746
+ brutal: BrutalOptions.optional().meta({
747
+ description: "TCP Brutal options.",
748
+ description_zh: "TCP Brutal 选项。"
749
+ })
750
+ }).meta({
751
+ id: "OutboundMultiplexOptions",
752
+ title: "Outbound Multiplex Options",
753
+ title_zh: "出站多路复用选项"
754
+ });
755
+ const V2RayHTTPOptions = zod.z.object({
756
+ type: zod.z.literal("http"),
757
+ host: listableString.optional().meta({
758
+ description: "List of host domain.",
759
+ description_zh: "主机域名列表。"
760
+ }),
761
+ path: zod.z.string().optional().meta({
762
+ description: "Path of HTTP request.",
763
+ description_zh: "HTTP 请求路径。"
764
+ }),
765
+ method: zod.z.string().optional().meta({
766
+ description: "Method of HTTP request.",
767
+ description_zh: "HTTP 请求方法。"
768
+ }),
769
+ headers: HttpHeader.optional().meta({
770
+ description: "Extra headers of HTTP request.",
771
+ description_zh: "HTTP 请求的额外标头。"
772
+ }),
773
+ idle_timeout: zod.z.string().optional().meta({
774
+ description: "Specifies the time until idle clients should be closed with a GOAWAY frame.",
775
+ description_zh: "指定闲置客户端应在多长时间内使用 GOAWAY 帧关闭。"
776
+ }),
777
+ ping_timeout: zod.z.string().optional().meta({
778
+ description: "Specifies the timeout duration after sending a PING frame, within which a response must be received.",
779
+ description_zh: "指定发送 PING 帧后,在指定的超时时间内必须接收到响应。"
780
+ })
781
+ }).meta({
782
+ id: "V2RayHTTPOptions",
783
+ title: "V2Ray HTTP Options",
784
+ title_zh: "V2Ray HTTP 选项"
785
+ });
786
+ const V2RayWebsocketOptions = zod.z.object({
787
+ type: zod.z.literal("ws"),
788
+ path: zod.z.string().optional().meta({
789
+ description: "Path of HTTP request.",
790
+ description_zh: "HTTP 请求路径。"
791
+ }),
792
+ headers: HttpHeader.optional().meta({
793
+ description: "Extra headers of HTTP request.",
794
+ description_zh: "HTTP 请求的额外标头。"
795
+ }),
796
+ max_early_data: zod.z.number().int().optional().meta({
797
+ description: "Allowed payload size is in the request.",
798
+ description_zh: "请求中允许的最大有效负载大小。"
799
+ }),
800
+ early_data_header_name: zod.z.string().optional().meta({
801
+ description: "Early data is sent in path instead of header by default.",
802
+ description_zh: "默认情况下,早期数据在路径而不是标头中发送。"
803
+ })
804
+ }).meta({
805
+ id: "V2RayWebsocketOptions",
806
+ title: "V2Ray WebSocket Options",
807
+ title_zh: "V2Ray WebSocket 选项"
808
+ });
809
+ const V2RayQUICOptions = zod.z.object({ type: zod.z.literal("quic") }).meta({
810
+ id: "V2RayQUICOptions",
811
+ title: "V2Ray QUIC Options",
812
+ title_zh: "V2Ray QUIC 选项"
813
+ });
814
+ const V2RayGRPCOptions = zod.z.object({
815
+ type: zod.z.literal("grpc"),
816
+ service_name: zod.z.string().optional().meta({
817
+ description: "Service name of gRPC.",
818
+ description_zh: "gRPC 服务名称。"
819
+ }),
820
+ idle_timeout: zod.z.string().optional().meta({
821
+ description: "If the transport doesn't see any activity after a duration of this time, it pings the client to check if the connection is still active.",
822
+ description_zh: "如果传输在此时间段后没有看到任何活动,它会向客户端发送 ping 请求以检查连接是否仍然活动。"
823
+ }),
824
+ ping_timeout: zod.z.string().optional().meta({
825
+ description: "The timeout that after performing a keepalive check, the client will wait for activity.",
826
+ description_zh: "经过一段时间之后,客户端将执行 keepalive 检查并等待活动。"
827
+ }),
828
+ permit_without_stream: zod.z.boolean().optional().meta({
829
+ description: "If enabled, the client transport sends keepalive pings even with no active connections.",
830
+ description_zh: "如果启用,客户端传输即使没有活动连接也会发送 keepalive ping。"
831
+ })
832
+ }).meta({
833
+ id: "V2RayGRPCOptions",
834
+ title: "V2Ray gRPC Options",
835
+ title_zh: "V2Ray gRPC 选项"
836
+ });
837
+ const V2RayHTTPUpgradeOptions = zod.z.object({
838
+ type: zod.z.literal("httpupgrade"),
839
+ host: zod.z.string().optional().meta({
840
+ description: "Host domain.",
841
+ description_zh: "主机域名。"
842
+ }),
843
+ path: zod.z.string().optional().meta({
844
+ description: "Path of HTTP request.",
845
+ description_zh: "HTTP 请求路径。"
846
+ }),
847
+ headers: HttpHeader.optional().meta({
848
+ description: "Extra headers of HTTP request.",
849
+ description_zh: "HTTP 请求的额外标头。"
850
+ })
851
+ }).meta({
852
+ id: "V2RayHTTPUpgradeOptions",
853
+ title: "V2Ray HTTPUpgrade Options",
854
+ title_zh: "V2Ray HTTPUpgrade 选项"
855
+ });
856
+ const V2RayTransportOptions = zod.z.discriminatedUnion("type", [
857
+ V2RayHTTPOptions,
858
+ V2RayWebsocketOptions,
859
+ V2RayQUICOptions,
860
+ V2RayGRPCOptions,
861
+ V2RayHTTPUpgradeOptions
862
+ ]).meta({
863
+ id: "V2RayTransportOptions",
864
+ title: "V2Ray Transport Options",
865
+ title_zh: "V2Ray 传输选项"
866
+ });
867
+ const UDPOverTCPOptions = zod.z.object({
868
+ enabled: zod.z.boolean().optional().meta({
869
+ description: "Enable the UDP over TCP protocol.",
870
+ description_zh: "启用 UDP over TCP 协议。"
871
+ }),
872
+ version: zod.z.number().int().optional().meta({
873
+ description: "The protocol version, `1` or `2`.",
874
+ description_zh: "协议版本,`1` 或 `2`。"
875
+ })
876
+ }).meta({
877
+ id: "UDPOverTCPOptions",
878
+ title: "UDP Over TCP Options",
879
+ title_zh: "UDP Over TCP 选项"
880
+ });
881
+
882
+ //#endregion
883
+ //#region src/schema/rules/dns-rule.ts
884
+ const DNSRouteAction = zod.z.object({
885
+ action: zod.z.literal("route").optional().meta({
886
+ description: "Action type.",
887
+ description_zh: "动作类型。"
888
+ }),
889
+ server: zod.z.string().meta({
890
+ description: "Tag of target server.",
891
+ description_zh: "目标服务器的标签。"
892
+ }),
893
+ strategy: DomainStrategy.optional().meta({
894
+ description: "Set domain strategy for this query.",
895
+ description_zh: "为此查询设置域名策略。"
896
+ }),
897
+ disable_cache: zod.z.boolean().optional().meta({
898
+ description: "Disable cache and save cache in this query.",
899
+ description_zh: "在此查询中禁用缓存。"
900
+ }),
901
+ rewrite_ttl: zod.z.number().int().optional().meta({
902
+ description: "Rewrite TTL in DNS responses.",
903
+ description_zh: "重写 DNS 回应中的 TTL。"
904
+ }),
905
+ client_subnet: zod.z.string().optional().meta({
906
+ description: "Append a `edns0-subnet` OPT extra record.",
907
+ description_zh: "附加 `edns0-subnet` OPT 附加记录。"
908
+ })
909
+ }).meta({
910
+ id: "DNSRouteAction",
911
+ title: "DNS Route Action",
912
+ title_zh: "DNS 路由动作"
913
+ });
914
+ const DNSRejectAction = zod.z.object({
915
+ action: zod.z.literal("reject").meta({
916
+ description: "Action type.",
917
+ description_zh: "动作类型。"
918
+ }),
919
+ method: zod.z.enum(["default", "drop"]).optional().meta({
920
+ description: "Reply with REFUSED or drop the request.",
921
+ description_zh: "返回 REFUSED 或丢弃请求。"
922
+ }),
923
+ no_drop: zod.z.boolean().optional().meta({
924
+ description: "If not enabled, `method` will be temporarily overwritten to `drop` after 50 triggers in 30s.",
925
+ description_zh: "如果未启用,则 30 秒内触发 50 次后,`method` 将被暂时覆盖为 `drop`。"
926
+ })
927
+ }).meta({
928
+ id: "DNSRejectAction",
929
+ title: "DNS Reject Action",
930
+ title_zh: "DNS 拒绝动作"
931
+ });
932
+ const DNSRouteOptionsAction = zod.z.object({
933
+ action: zod.z.literal("route-options").meta({
934
+ description: "Action type.",
935
+ description_zh: "动作类型。"
936
+ }),
937
+ disable_cache: zod.z.boolean().optional().meta({
938
+ description: "Disable cache and save cache in this query.",
939
+ description_zh: "在此查询中禁用缓存。"
940
+ }),
941
+ rewrite_ttl: zod.z.number().int().optional().meta({
942
+ description: "Rewrite TTL in DNS responses.",
943
+ description_zh: "重写 DNS 回应中的 TTL。"
944
+ }),
945
+ client_subnet: zod.z.string().optional().meta({
946
+ description: "Append a `edns0-subnet` OPT extra record.",
947
+ description_zh: "附加 `edns0-subnet` OPT 附加记录。"
948
+ })
949
+ }).meta({
950
+ id: "DNSRouteOptionsAction",
951
+ title: "DNS Route Options Action",
952
+ title_zh: "DNS 路由选项动作"
953
+ });
954
+ const DNSRecord = zod.z.string().meta({
955
+ description: "Text DNS record.",
956
+ description_zh: "文本 DNS 记录。"
957
+ });
958
+ const DNSRouteActionPredefined = zod.z.object({
959
+ action: zod.z.literal("predefined").meta({
960
+ description: "Action type.",
961
+ description_zh: "动作类型。"
962
+ }),
963
+ rcode: zod.z.enum([
964
+ "NOERROR",
965
+ "FORMERR",
966
+ "SERVFAIL",
967
+ "NXDOMAIN",
968
+ "NOTIMP",
969
+ "REFUSED"
970
+ ]).optional().meta({
971
+ description: "The response code.",
972
+ description_zh: "响应码。"
973
+ }),
974
+ answer: listable(DNSRecord).optional().meta({
975
+ description: "List of text DNS record to respond as answers.",
976
+ description_zh: "用于作为回答响应的文本 DNS 记录列表。"
977
+ }),
978
+ ns: listable(DNSRecord).optional().meta({
979
+ description: "List of text DNS record to respond as name servers.",
980
+ description_zh: "用于作为名称服务器响应的文本 DNS 记录列表。"
981
+ }),
982
+ extra: listable(DNSRecord).optional().meta({
983
+ description: "List of text DNS record to respond as extra records.",
984
+ description_zh: "用于作为额外记录响应的文本 DNS 记录列表。"
985
+ })
986
+ }).meta({
987
+ id: "DNSRouteActionPredefined",
988
+ title: "DNS Route Action Predefined",
989
+ title_zh: "DNS 路由动作预定义"
990
+ });
991
+ const DNSQueryType$1 = zod.z.union([zod.z.string(), zod.z.number().int()]).meta({
992
+ description: "DNS query type. Values can be integers or type name strings.",
993
+ description_zh: "DNS 查询类型。值可以为整数或者类型名称字符串。"
994
+ });
995
+ const BaseDNSRule = zod.z.object({
996
+ inbound: listableString.optional().meta({
997
+ description: "Tags of Inbound.",
998
+ description_zh: "入站标签。"
999
+ }),
1000
+ ip_version: IpVersion.optional().meta({
1001
+ description: "4 (A DNS query) or 6 (AAAA DNS query).",
1002
+ description_zh: "4 (A DNS 查询) 或 6 (AAAA DNS 查询)。"
1003
+ }),
1004
+ query_type: listable(DNSQueryType$1).optional().meta({
1005
+ description: "DNS query type.",
1006
+ description_zh: "DNS 查询类型。"
1007
+ }),
1008
+ network: Network.optional().meta({
1009
+ description: "`tcp` or `udp`.",
1010
+ description_zh: "`tcp` 或 `udp`。"
1011
+ }),
1012
+ auth_user: listableString.optional().meta({
1013
+ description: "Username.",
1014
+ description_zh: "用户名。"
1015
+ }),
1016
+ protocol: listableString.optional().meta({
1017
+ description: "Sniffed protocol.",
1018
+ description_zh: "探测到的协议。"
1019
+ }),
1020
+ domain: listableString.optional().meta({
1021
+ description: "Match full domain.",
1022
+ description_zh: "匹配完整域名。"
1023
+ }),
1024
+ domain_suffix: listableString.optional().meta({
1025
+ description: "Match domain suffix.",
1026
+ description_zh: "匹配域名后缀。"
1027
+ }),
1028
+ domain_keyword: listableString.optional().meta({
1029
+ description: "Match domain using keyword.",
1030
+ description_zh: "匹配域名关键字。"
1031
+ }),
1032
+ domain_regex: listableString.optional().meta({
1033
+ description: "Match domain using regular expression.",
1034
+ description_zh: "匹配域名正则表达式。"
1035
+ }),
1036
+ source_ip_cidr: listableString.optional().meta({
1037
+ description: "Match source IP CIDR.",
1038
+ description_zh: "匹配源 IP CIDR。"
1039
+ }),
1040
+ source_ip_is_private: zod.z.boolean().optional().meta({
1041
+ description: "Match non-public source IP.",
1042
+ description_zh: "匹配非公开源 IP。"
1043
+ }),
1044
+ ip_cidr: listableString.optional().meta({
1045
+ description: "Match IP CIDR with query response.",
1046
+ description_zh: "与查询响应匹配 IP CIDR。"
1047
+ }),
1048
+ ip_is_private: zod.z.boolean().optional().meta({
1049
+ description: "Match private IP with query response.",
1050
+ description_zh: "与查询响应匹配非公开 IP。"
1051
+ }),
1052
+ ip_accept_any: zod.z.boolean().optional().meta({
1053
+ description: "Match any IP with query response.",
1054
+ description_zh: "匹配任意 IP。"
1055
+ }),
1056
+ source_port: listableInts.optional().meta({
1057
+ description: "Match source port.",
1058
+ description_zh: "匹配源端口。"
1059
+ }),
1060
+ source_port_range: listableString.optional().meta({
1061
+ description: "Match source port range.",
1062
+ description_zh: "匹配源端口范围。"
1063
+ }),
1064
+ port: listableInts.optional().meta({
1065
+ description: "Match port.",
1066
+ description_zh: "匹配端口。"
1067
+ }),
1068
+ port_range: listableString.optional().meta({
1069
+ description: "Match port range.",
1070
+ description_zh: "匹配端口范围。"
1071
+ }),
1072
+ process_name: listableString.optional().meta({
1073
+ description: "Match process name.",
1074
+ description_zh: "匹配进程名称。"
1075
+ }),
1076
+ process_path: listableString.optional().meta({
1077
+ description: "Match process path.",
1078
+ description_zh: "匹配进程路径。"
1079
+ }),
1080
+ process_path_regex: listableString.optional().meta({
1081
+ description: "Match process path using regular expression.",
1082
+ description_zh: "使用正则表达式匹配进程路径。"
1083
+ }),
1084
+ package_name: listableString.optional().meta({
1085
+ description: "Match android package name.",
1086
+ description_zh: "匹配 Android 应用包名。"
1087
+ }),
1088
+ user: listableString.optional().meta({
1089
+ description: "Match user name.",
1090
+ description_zh: "匹配用户名。"
1091
+ }),
1092
+ user_id: listableInts.optional().meta({
1093
+ description: "Match user id.",
1094
+ description_zh: "匹配用户 ID。"
1095
+ }),
1096
+ clash_mode: zod.z.string().optional().meta({
1097
+ description: "Match Clash mode.",
1098
+ description_zh: "匹配 Clash 模式。"
1099
+ }),
1100
+ network_type: listable(NetworkType).optional().meta({
1101
+ description: "Match network type.",
1102
+ description_zh: "匹配网络类型。"
1103
+ }),
1104
+ network_is_expensive: zod.z.boolean().optional().meta({
1105
+ description: "Match if network is considered Metered.",
1106
+ description_zh: "匹配如果网络被视为计费。"
1107
+ }),
1108
+ network_is_constrained: zod.z.boolean().optional().meta({
1109
+ description: "Match if network is in Low Data Mode.",
1110
+ description_zh: "匹配如果网络在低数据模式下。"
1111
+ }),
1112
+ wifi_ssid: listableString.optional().meta({
1113
+ description: "Match WiFi SSID.",
1114
+ description_zh: "匹配 WiFi SSID。"
1115
+ }),
1116
+ wifi_bssid: listableString.optional().meta({
1117
+ description: "Match WiFi BSSID.",
1118
+ description_zh: "匹配 WiFi BSSID。"
1119
+ }),
1120
+ rule_set: listableString.optional().meta({
1121
+ description: "Match rule-set.",
1122
+ description_zh: "匹配规则集。"
1123
+ }),
1124
+ rule_set_ip_cidr_match_source: zod.z.boolean().optional().meta({
1125
+ description: "Make `ip_cidr` rule items in rule-sets match the source IP.",
1126
+ description_zh: "使规则集中的 `ip_cidr` 规则匹配源 IP。"
1127
+ }),
1128
+ rule_set_ip_cidr_accept_empty: zod.z.boolean().optional().meta({
1129
+ description: "Make `ip_cidr` rules in rule-sets accept empty query response.",
1130
+ description_zh: "使规则集中的 `ip_cidr` 规则接受空查询响应。"
1131
+ }),
1132
+ invert: zod.z.boolean().optional().meta({
1133
+ description: "Invert match result.",
1134
+ description_zh: "反选匹配结果。"
1135
+ }),
1136
+ outbound: listableString.optional().meta({
1137
+ description: "Match outbound.",
1138
+ description_zh: "匹配出站。",
1139
+ deprecated: true
1140
+ })
1141
+ });
1142
+ const DefaultDNSRule = zod.z.union([
1143
+ BaseDNSRule.extend(DNSRouteAction.shape),
1144
+ BaseDNSRule.extend(DNSRouteOptionsAction.shape),
1145
+ BaseDNSRule.extend(DNSRejectAction.shape),
1146
+ BaseDNSRule.extend(DNSRouteActionPredefined.shape)
1147
+ ]);
1148
+ const LogicalDNSRule = zod.z.object({
1149
+ type: zod.z.literal("logical").meta({
1150
+ description: "Rule type.",
1151
+ description_zh: "规则类型。"
1152
+ }),
1153
+ mode: zod.z.enum(["and", "or"]).meta({
1154
+ description: "`and` or `or`.",
1155
+ description_zh: "`and` 或 `or`。"
1156
+ }),
1157
+ get rules() {
1158
+ return zod.z.array(DNSRule).optional().meta({
1159
+ description: "Included rules.",
1160
+ description_zh: "包括的规则。"
1161
+ });
1162
+ },
1163
+ invert: zod.z.boolean().optional().meta({
1164
+ description: "Invert match result.",
1165
+ description_zh: "反选匹配结果。"
1166
+ })
1167
+ }).meta({
1168
+ id: "LogicalDNSRule",
1169
+ title: "Logical DNS Rule",
1170
+ title_zh: "逻辑 DNS 规则"
1171
+ });
1172
+ const DNSRule = zod.z.union([DefaultDNSRule, LogicalDNSRule]).meta({
1173
+ id: "DNSRule",
1174
+ title: "DNS Rule",
1175
+ title_zh: "DNS 规则"
1176
+ });
1177
+
1178
+ //#endregion
1179
+ //#region src/schema/dns.ts
1180
+ const LocalDNSServerOptions = zod.z.object({
1181
+ type: zod.z.literal("local"),
1182
+ tag: zod.z.string(),
1183
+ ...DialerOptions.shape
1184
+ }).meta({
1185
+ id: "LocalDNSServerOptions",
1186
+ title: "Local DNS Server"
1187
+ });
1188
+ const HostsDNSServerOptions = zod.z.object({
1189
+ type: zod.z.literal("hosts"),
1190
+ tag: zod.z.string(),
1191
+ path: listableString.optional().meta({ description: "List of paths to hosts files." }),
1192
+ predefined: zod.z.record(zod.z.string(), listableString).optional().meta({ description: "Predefined hosts." })
1193
+ }).meta({
1194
+ id: "HostsDNSServerOptions",
1195
+ title: "Hosts DNS Server"
1196
+ });
1197
+ const TCPDNSServerOptions = zod.z.object({
1198
+ type: zod.z.literal("tcp"),
1199
+ tag: zod.z.string(),
1200
+ server: zod.z.string().meta({ description: "The address of the TCP DNS server." }),
1201
+ server_port: zod.z.number().int().optional().meta({ description: "The port of the TCP DNS server." }),
1202
+ ...DialerOptions.shape
1203
+ }).meta({
1204
+ id: "TCPDNSServerOptions",
1205
+ title: "TCP DNS Server"
1206
+ });
1207
+ const UDPDNSServerOptions = zod.z.object({
1208
+ type: zod.z.literal("udp"),
1209
+ tag: zod.z.string(),
1210
+ server: zod.z.string().meta({ description: "The address of the UDP DNS server." }),
1211
+ server_port: zod.z.number().int().optional().meta({ description: "The port of the UDP DNS server." }),
1212
+ ...DialerOptions.shape
1213
+ }).meta({
1214
+ id: "UDPDNSServerOptions",
1215
+ title: "UDP DNS Server"
1216
+ });
1217
+ const TLSDNSServerOptions = zod.z.object({
1218
+ type: zod.z.literal("tls"),
1219
+ tag: zod.z.string(),
1220
+ server: zod.z.string().meta({ description: "The address of the TLS DNS server." }),
1221
+ server_port: zod.z.number().int().optional().meta({ description: "The port of the TLS DNS server." }),
1222
+ tls: OutboundTLSOptions.optional().meta({ description: "TLS configuration." }),
1223
+ ...DialerOptions.shape
1224
+ }).meta({
1225
+ id: "TLSDNSServerOptions",
1226
+ title: "TLS DNS Server"
1227
+ });
1228
+ const QUICDNSServerOptions = zod.z.object({
1229
+ type: zod.z.literal("quic"),
1230
+ tag: zod.z.string(),
1231
+ server: zod.z.string().meta({ description: "The address of the QUIC DNS server." }),
1232
+ server_port: zod.z.number().int().optional().meta({ description: "The port of the QUIC DNS server." }),
1233
+ tls: OutboundTLSOptions.optional().meta({ description: "TLS configuration." }),
1234
+ ...DialerOptions.shape
1235
+ }).meta({
1236
+ id: "QUICDNSServerOptions",
1237
+ title: "QUIC DNS Server"
1238
+ });
1239
+ const HTTPSDNSServerOptions = zod.z.object({
1240
+ type: zod.z.literal("https"),
1241
+ tag: zod.z.string(),
1242
+ server: zod.z.string().meta({ description: "The address of the HTTPS DNS server." }),
1243
+ server_port: zod.z.number().int().optional().meta({ description: "The port of the HTTPS DNS server." }),
1244
+ path: zod.z.string().optional().meta({ description: "The path of the HTTPS DNS server. `/dns-query` will be used by default." }),
1245
+ headers: HttpHeader.optional().meta({ description: "Additional headers to be sent to the DNS server." }),
1246
+ tls: OutboundTLSOptions.optional().meta({ description: "TLS configuration." }),
1247
+ ...DialerOptions.shape
1248
+ }).meta({
1249
+ id: "HTTPSDNSServerOptions",
1250
+ title: "HTTPS DNS Server"
1251
+ });
1252
+ const HTTP3DNSServerOptions = zod.z.object({
1253
+ type: zod.z.literal("h3"),
1254
+ tag: zod.z.string(),
1255
+ server: zod.z.string().meta({ description: "The address of the HTTP3 DNS server." }),
1256
+ server_port: zod.z.number().int().optional().meta({ description: "The port of the HTTP3 DNS server." }),
1257
+ path: zod.z.string().optional().meta({ description: "The path of the HTTP3 DNS server. `/dns-query` will be used by default." }),
1258
+ headers: HttpHeader.optional().meta({ description: "Additional headers to be sent to the DNS server." }),
1259
+ tls: OutboundTLSOptions.optional().meta({ description: "TLS configuration." }),
1260
+ ...DialerOptions.shape
1261
+ }).meta({
1262
+ id: "HTTP3DNSServerOptions",
1263
+ title: "HTTP3 DNS Server"
1264
+ });
1265
+ const DHCPDNSServerOptions = zod.z.object({
1266
+ type: zod.z.literal("dhcp"),
1267
+ tag: zod.z.string(),
1268
+ interface: zod.z.string().optional().meta({ description: "Interface name to listen on." }),
1269
+ ...DialerOptions.shape
1270
+ }).meta({
1271
+ id: "DHCPDNSServerOptions",
1272
+ title: "DHCP DNS Server"
1273
+ });
1274
+ const FakeIPDNSServerOptions = zod.z.object({
1275
+ type: zod.z.literal("fakeip"),
1276
+ tag: zod.z.string(),
1277
+ inet4_range: zod.z.string().optional().meta({
1278
+ description: "IPv4 address range for FakeIP.",
1279
+ description_zh: "用于 FakeIP 的 IPv4 地址范围。"
1280
+ }),
1281
+ inet6_range: zod.z.string().optional().meta({
1282
+ description: "IPv6 address range for FakeIP.",
1283
+ description_zh: "用于 FakeIP 的 IPv6 地址范围。"
1284
+ })
1285
+ }).meta({
1286
+ id: "FakeIPDNSServerOptions",
1287
+ title: "FakeIP DNS Server"
1288
+ });
1289
+ const TailscaleDNSServerOptions = zod.z.object({
1290
+ type: zod.z.literal("tailscale"),
1291
+ tag: zod.z.string(),
1292
+ endpoint: zod.z.string().meta({ description: "The tag of the Tailscale Endpoint." }),
1293
+ accept_default_resolvers: zod.z.boolean().optional().meta({ description: "Indicates whether default DNS resolvers should be accepted for fallback queries in addition to MagicDNS," })
1294
+ }).meta({
1295
+ id: "TailscaleDNSServerOptions",
1296
+ title: "Tailscale DNS Server"
1297
+ });
1298
+ const ResolvedDNSServerOptions = zod.z.object({
1299
+ type: zod.z.literal("resolved"),
1300
+ tag: zod.z.string(),
1301
+ service: zod.z.string().meta({ description: "The tag of the Resolved Service." }),
1302
+ accept_default_resolvers: zod.z.boolean().optional().meta({ description: "Indicates whether the default DNS resolvers should be accepted for fallback queries in addition to matching domains." })
1303
+ }).meta({
1304
+ id: "ResolvedDNSServerOptions",
1305
+ title: "Resolved DNS Server"
1306
+ });
1307
+ const DNSServer = zod.z.discriminatedUnion("type", [
1308
+ LocalDNSServerOptions,
1309
+ HostsDNSServerOptions,
1310
+ TCPDNSServerOptions,
1311
+ UDPDNSServerOptions,
1312
+ TLSDNSServerOptions,
1313
+ QUICDNSServerOptions,
1314
+ HTTPSDNSServerOptions,
1315
+ HTTP3DNSServerOptions,
1316
+ DHCPDNSServerOptions,
1317
+ FakeIPDNSServerOptions,
1318
+ TailscaleDNSServerOptions,
1319
+ ResolvedDNSServerOptions
1320
+ ]).meta({
1321
+ id: "DNSServer",
1322
+ title: "DNS Server",
1323
+ title_zh: "DNS 服务器"
1324
+ });
1325
+ const DNSClientOptions = zod.z.object({
1326
+ strategy: DomainStrategy.optional().meta({
1327
+ description: "Default domain strategy for resolving the domain names.",
1328
+ description_zh: "默认解析域名策略。"
1329
+ }),
1330
+ disable_cache: zod.z.boolean().optional().meta({
1331
+ description: "Disable dns cache.",
1332
+ description_zh: "禁用 DNS 缓存。"
1333
+ }),
1334
+ disable_expire: zod.z.boolean().optional().meta({
1335
+ description: "Disable dns cache expire.",
1336
+ description_zh: "禁用 DNS 缓存过期。"
1337
+ }),
1338
+ independent_cache: zod.z.boolean().optional().meta({
1339
+ description: "Make each DNS server's cache independent for special purposes. If enabled, will slightly degrade performance.",
1340
+ description_zh: "使每个 DNS 服务器的缓存独立,以满足特殊目的。如果启用,将轻微降低性能。"
1341
+ }),
1342
+ cache_capacity: zod.z.number().int().optional().meta({
1343
+ description: "LRU cache capacity.",
1344
+ description_zh: "LRU 缓存容量。"
1345
+ }),
1346
+ client_subnet: zod.z.string().optional().meta({
1347
+ description: "Append a `edns0-subnet` OPT extra record with the specified IP prefix to every query by default.",
1348
+ description_zh: "默认情况下,将带有指定 IP 前缀的 `edns0-subnet` OPT 附加记录附加到每个查询。"
1349
+ })
1350
+ });
1351
+ const LegacyDNSFakeIPOptions = zod.z.object({
1352
+ enabled: zod.z.boolean().optional().meta({
1353
+ description: "Enable FakeIP service.",
1354
+ description_zh: "启用 FakeIP 服务。"
1355
+ }),
1356
+ inet4_range: zod.z.string().optional().meta({
1357
+ description: "IPv4 address range for FakeIP.",
1358
+ description_zh: "用于 FakeIP 的 IPv4 地址范围。"
1359
+ }),
1360
+ inet6_range: zod.z.string().optional().meta({
1361
+ description: "IPv6 address range for FakeIP.",
1362
+ description_zh: "用于 FakeIP 的 IPv6 地址范围。"
1363
+ })
1364
+ }).meta({
1365
+ id: "LegacyDNSFakeIPOptions",
1366
+ title: "Legacy DNS FakeIP",
1367
+ title_zh: "旧版 DNS FakeIP",
1368
+ description: "Legacy fake-ip configuration is deprecated",
1369
+ description_zh: "旧的 fake-ip 配置已废弃",
1370
+ deprecated: true
1371
+ });
1372
+ const DNSOptions = zod.z.object({
1373
+ servers: zod.z.array(DNSServer).optional().meta({
1374
+ description: "List of DNS Servers",
1375
+ description_zh: "一组 DNS 服务器"
1376
+ }),
1377
+ rules: zod.z.array(DNSRule).optional().meta({
1378
+ description: "List of DNS Rules",
1379
+ description_zh: "一组 DNS 规则"
1380
+ }),
1381
+ final: zod.z.string().optional().meta({
1382
+ description: "Default dns server tag.",
1383
+ description_zh: "默认 DNS 服务器的标签。"
1384
+ }),
1385
+ reverse_mapping: zod.z.boolean().optional().meta({
1386
+ description: "Stores a reverse mapping of IP addresses after responding to a DNS query in order to provide domain names when routing.",
1387
+ description_zh: "在响应 DNS 查询后存储 IP 地址的反向映射以为路由目的提供域名。"
1388
+ }),
1389
+ fakeip: LegacyDNSFakeIPOptions.optional().meta({
1390
+ description: "FakeIP settings.",
1391
+ description_zh: "FakeIP 设置。"
1392
+ }),
1393
+ ...DNSClientOptions.shape
1394
+ }).meta({
1395
+ id: "DNSOptions",
1396
+ title: "DNS",
1397
+ title_zh: "DNS"
1398
+ });
1399
+
1400
+ //#endregion
1401
+ //#region src/schema/protocols/tailscale.ts
1402
+ const TailscaleEndpointOptions = zod.z.object({
1403
+ type: zod.z.literal("tailscale"),
1404
+ tag: zod.z.string().optional(),
1405
+ state_directory: zod.z.string().optional().meta({
1406
+ description: "The directory where the Tailscale state is stored.",
1407
+ description_zh: "存储 Tailscale 状态的目录。"
1408
+ }),
1409
+ auth_key: zod.z.string().optional().meta({
1410
+ description: "The auth key to create the node.",
1411
+ description_zh: "用于创建节点的验证密钥。"
1412
+ }),
1413
+ control_url: zod.z.string().optional().meta({
1414
+ description: "The coordination server URL.",
1415
+ description_zh: "协调服务器 URL。"
1416
+ }),
1417
+ ephemeral: zod.z.boolean().optional().meta({
1418
+ description: "Indicates whether the instance should register as an Ephemeral node.",
1419
+ description_zh: "指示实例是否应注册为临时节点。"
1420
+ }),
1421
+ hostname: zod.z.string().optional().meta({
1422
+ description: "The hostname of the node.",
1423
+ description_zh: "节点的主机名。"
1424
+ }),
1425
+ accept_routes: zod.z.boolean().optional().meta({
1426
+ description: "Indicates whether the node should accept routes advertised by other nodes.",
1427
+ description_zh: "指示节点是否应接受其他节点通告的路由。"
1428
+ }),
1429
+ exit_node: zod.z.string().optional().meta({
1430
+ description: "The exit node name or IP address to use.",
1431
+ description_zh: "要使用的出口节点的名称或 IP 地址。"
1432
+ }),
1433
+ exit_node_allow_lan_access: zod.z.boolean().optional().meta({
1434
+ description: "Indicates whether locally accessible subnets should be routed directly or via the exit node.",
1435
+ description_zh: "指示本地可访问的子网应直接路由还是通过出口节点路由。"
1436
+ }),
1437
+ advertise_routes: zod.z.array(zod.z.string()).optional().meta({
1438
+ description: "CIDR prefixes to advertise into the Tailscale network as reachable through the current node.",
1439
+ description_zh: "要通告到 Tailscale 网络中的 CIDR 前缀,作为可通过当前节点访问。"
1440
+ }),
1441
+ advertise_exit_node: zod.z.boolean().optional().meta({
1442
+ description: "Indicates whether the node should advertise itself as an exit node.",
1443
+ description_zh: "指示节点是否应将自己通告为出口节点。"
1444
+ }),
1445
+ udp_timeout: zod.z.union([zod.z.string(), zod.z.number()]).optional().meta({
1446
+ description: "UDP NAT expiration time.",
1447
+ description_zh: "UDP NAT 过期时间。"
1448
+ }),
1449
+ ...DialerOptions.shape
1450
+ }).meta({
1451
+ id: "TailscaleEndpointOptions",
1452
+ title: "Tailscale Endpoint",
1453
+ title_zh: "Tailscale 端点"
1454
+ });
1455
+
1456
+ //#endregion
1457
+ //#region src/schema/protocols/wireguard.ts
1458
+ const Reserved = zod.default.union([zod.default.string().max(4), zod.default.array(zod.default.number().int().min(0).max(255)).length(3)]);
1459
+ const WireGuardPeer = zod.default.object({
1460
+ address: zod.default.string().optional().meta({
1461
+ description: "WireGuard peer address.",
1462
+ description_zh: "对等方的 IP 地址。"
1463
+ }),
1464
+ port: zod.default.number().int().optional().meta({
1465
+ description: "WireGuard peer port.",
1466
+ description_zh: "对等方的 WireGuard 端口。"
1467
+ }),
1468
+ public_key: zod.default.string().optional().meta({
1469
+ description: "WireGuard peer public key.",
1470
+ description_zh: "对等方的 WireGuard 公钥。"
1471
+ }),
1472
+ pre_shared_key: zod.default.string().optional().meta({
1473
+ description: "WireGuard peer pre-shared key.",
1474
+ description_zh: "对等方的预共享密钥。"
1475
+ }),
1476
+ allowed_ips: zod.default.union([zod.default.string(), zod.default.array(zod.default.string())]).optional().meta({
1477
+ description: "WireGuard allowed IPs.",
1478
+ description_zh: "对等方的允许 IP 地址。"
1479
+ }),
1480
+ persistent_keepalive_interval: zod.default.number().int().optional().meta({
1481
+ description: "WireGuard persistent keepalive interval, in seconds.",
1482
+ description_zh: "对等方的持久性保持活动间隔,以秒为单位。"
1483
+ }),
1484
+ reserved: Reserved.optional().meta({
1485
+ description: "WireGuard reserved field bytes.",
1486
+ description_zh: "对等方的保留字段字节。"
1487
+ })
1488
+ });
1489
+ const WireGuardEndpointOptions = zod.default.object({
1490
+ type: zod.default.literal("wireguard"),
1491
+ tag: zod.default.string().optional(),
1492
+ system: zod.default.boolean().optional().meta({
1493
+ description: "Use system interface.",
1494
+ description_zh: "使用系统设备。"
1495
+ }),
1496
+ name: zod.default.string().optional().meta({
1497
+ description: "Custom interface name for system interface.",
1498
+ description_zh: "为系统接口自定义设备名称。"
1499
+ }),
1500
+ mtu: zod.default.number().int().optional().meta({
1501
+ description: "WireGuard MTU.",
1502
+ description_zh: "WireGuard MTU。"
1503
+ }),
1504
+ address: zod.default.union([zod.default.string(), zod.default.array(zod.default.string())]).meta({
1505
+ description: "List of IP (v4 or v6) address prefixes to be assigned to the interface.",
1506
+ description_zh: "接口的 IPv4/IPv6 地址或地址段的列表。"
1507
+ }),
1508
+ private_key: zod.default.string().meta({
1509
+ description: "WireGuard requires base64-encoded public and private keys.",
1510
+ description_zh: "WireGuard 需要 base64 编码的公钥和私钥。"
1511
+ }),
1512
+ listen_port: zod.default.number().int().optional().meta({
1513
+ description: "Listen port.",
1514
+ description_zh: "监听端口。"
1515
+ }),
1516
+ peers: zod.default.array(WireGuardPeer).optional().meta({
1517
+ description: "List of WireGuard peers.",
1518
+ description_zh: "WireGuard 对等方的列表。"
1519
+ }),
1520
+ udp_timeout: zod.default.string().optional().meta({
1521
+ description: "UDP NAT expiration time.",
1522
+ description_zh: "UDP NAT 过期时间。"
1523
+ }),
1524
+ workers: zod.default.number().int().optional().meta({
1525
+ description: "WireGuard worker count.",
1526
+ description_zh: "WireGuard worker 数量。"
1527
+ }),
1528
+ ...DialerOptions.shape
1529
+ }).meta({
1530
+ id: "WireGuardEndpointOptions",
1531
+ title: "WireGuard Endpoint",
1532
+ title_zh: "WireGuard 端点"
1533
+ });
1534
+ const LegacyWireGuardPeer = zod.default.object({
1535
+ public_key: zod.default.string().optional().meta({
1536
+ description: "WireGuard peer public key.",
1537
+ description_zh: "WireGuard 对等公钥。"
1538
+ }),
1539
+ pre_shared_key: zod.default.string().optional().meta({
1540
+ description: "WireGuard pre-shared key.",
1541
+ description_zh: "WireGuard 预共享密钥。"
1542
+ }),
1543
+ allowed_ips: zod.default.union([zod.default.string(), zod.default.array(zod.default.string())]).optional().meta({
1544
+ description: "WireGuard allowed IPs.",
1545
+ description_zh: "WireGuard 允许 IP。"
1546
+ }),
1547
+ reserved: Reserved.optional().meta({
1548
+ description: "WireGuard reserved field bytes.",
1549
+ description_zh: "WireGuard 保留字段字节。"
1550
+ }),
1551
+ ...ServerOptions.shape
1552
+ });
1553
+ const LegacyWireGuardOutboundOptions = zod.default.object({
1554
+ type: zod.default.literal("wireguard"),
1555
+ tag: zod.default.string().optional(),
1556
+ system_interface: zod.default.boolean().optional().meta({
1557
+ description: "Use system interface.",
1558
+ description_zh: "使用系统设备。"
1559
+ }),
1560
+ gso: zod.default.boolean().optional().meta({
1561
+ description: "Enable generic segmentation offload.",
1562
+ description_zh: "启用通用分段卸载。",
1563
+ deprecated: true
1564
+ }),
1565
+ interface_name: zod.default.string().optional().meta({
1566
+ description: "Custom interface name for system interface.",
1567
+ description_zh: "为系统接口自定义设备名称。"
1568
+ }),
1569
+ local_address: zod.default.union([zod.default.string(), zod.default.array(zod.default.string())]).meta({
1570
+ description: "List of IP (v4 or v6) address prefixes to be assigned to the interface.",
1571
+ description_zh: "接口的 IPv4/IPv6 地址或地址段的列表。"
1572
+ }),
1573
+ private_key: zod.default.string().meta({
1574
+ description: "WireGuard requires base64-encoded public and private keys.",
1575
+ description_zh: "WireGuard 需要 base64 编码的公钥和私钥。"
1576
+ }),
1577
+ peers: zod.default.array(LegacyWireGuardPeer).optional().meta({
1578
+ description: "Multi-peer support.",
1579
+ description_zh: "多对等支持。"
1580
+ }),
1581
+ peer_public_key: zod.default.string().meta({
1582
+ description: "WireGuard peer public key.",
1583
+ description_zh: "WireGuard 对等公钥。"
1584
+ }),
1585
+ pre_shared_key: zod.default.string().optional().meta({
1586
+ description: "WireGuard pre-shared key.",
1587
+ description_zh: "WireGuard 预共享密钥。"
1588
+ }),
1589
+ reserved: Reserved.optional().meta({
1590
+ description: "WireGuard reserved field bytes.",
1591
+ description_zh: "WireGuard 保留字段字节。"
1592
+ }),
1593
+ workers: zod.default.number().int().optional().meta({
1594
+ description: "WireGuard worker count.",
1595
+ description_zh: "WireGuard worker 数量。"
1596
+ }),
1597
+ mtu: zod.default.number().int().optional().meta({
1598
+ description: "WireGuard MTU.",
1599
+ description_zh: "WireGuard MTU。"
1600
+ }),
1601
+ network: Network.optional().meta({
1602
+ description: "Enabled network.",
1603
+ description_zh: "启用的网络协议。"
1604
+ }),
1605
+ ...ServerOptions.shape,
1606
+ ...DialerOptions.shape
1607
+ }).meta({
1608
+ id: "LegacyWireGuardOutboundOptions",
1609
+ title: "Legacy WireGuard Outbound",
1610
+ title_zh: "旧版 WireGuard 出站"
1611
+ });
1612
+
1613
+ //#endregion
1614
+ //#region src/schema/endpoint.ts
1615
+ const Endpoint = zod.z.discriminatedUnion("type", [WireGuardEndpointOptions, TailscaleEndpointOptions]).meta({
1616
+ id: "Endpoint",
1617
+ title: "Endpoint",
1618
+ title_zh: "端点"
1619
+ });
1620
+
1621
+ //#endregion
1622
+ //#region src/schema/experimentals/cache-file.ts
1623
+ /**
1624
+ * Cache file settings.
1625
+ */
1626
+ const CacheFileOptions = zod.z.object({
1627
+ enabled: zod.z.boolean().optional().meta({
1628
+ description: "Enable cache file.",
1629
+ description_zh: "启用缓存文件。"
1630
+ }),
1631
+ path: zod.z.string().optional().meta({
1632
+ description: "Path to the cache file.",
1633
+ description_zh: "缓存文件路径。"
1634
+ }),
1635
+ cache_id: zod.z.string().optional().meta({
1636
+ description: "Identifier in the cache file.",
1637
+ description_zh: "缓存文件中的标识符。"
1638
+ }),
1639
+ store_fakeip: zod.z.boolean().optional().meta({
1640
+ description: "Store fakeip in the cache file.",
1641
+ description_zh: "将 fakeip 存储在缓存文件中。"
1642
+ }),
1643
+ store_rdrc: zod.z.boolean().optional().meta({
1644
+ description: "Store rejected DNS response cache in the cache file.",
1645
+ description_zh: "将拒绝的 DNS 响应缓存存储在缓存文件中。"
1646
+ }),
1647
+ rdrc_timeout: zod.z.string().optional().meta({
1648
+ description: "Timeout of rejected DNS response cache.",
1649
+ description_zh: "拒绝的 DNS 响应缓存超时。"
1650
+ })
1651
+ }).meta({
1652
+ id: "CacheFileOptions",
1653
+ title: "Cache File",
1654
+ title_zh: "缓存文件"
1655
+ });
1656
+
1657
+ //#endregion
1658
+ //#region src/schema/experimentals/clash-api.ts
1659
+ /**
1660
+ * Clash API settings.
1661
+ */
1662
+ const ClashAPIOptions = zod.z.object({
1663
+ external_controller: zod.z.string().optional().meta({
1664
+ description: "RESTful web API listening address. Clash API will be disabled if empty.",
1665
+ description_zh: "RESTful web API 监听地址。如果为空,则禁用 Clash API。"
1666
+ }),
1667
+ external_ui: zod.z.string().optional().meta({
1668
+ description: "A relative path to the configuration directory or an absolute path to a directory in which you put some static web resource.",
1669
+ description_zh: "到静态网页资源目录的相对路径或绝对路径。"
1670
+ }),
1671
+ external_ui_download_url: zod.z.string().optional().meta({
1672
+ description: "ZIP download URL for the external UI, will be used if the specified `external_ui` directory is empty.",
1673
+ description_zh: "静态网页资源的 ZIP 下载 URL,如果指定的 `external_ui` 目录为空,将使用。"
1674
+ }),
1675
+ external_ui_download_detour: zod.z.string().optional().meta({
1676
+ description: "The tag of the outbound to download the external UI.",
1677
+ description_zh: "用于下载静态网页资源的出站的标签。"
1678
+ }),
1679
+ secret: zod.z.string().optional().meta({
1680
+ description: "Secret for the RESTful API (optional).",
1681
+ description_zh: "RESTful API 的密钥(可选)。"
1682
+ }),
1683
+ default_mode: zod.z.string().optional().meta({
1684
+ description: "Default mode in clash, `Rule` will be used if empty.",
1685
+ description_zh: "Clash 中的默认模式,默认使用 `Rule`。"
1686
+ }),
1687
+ access_control_allow_origin: listableString.optional().meta({
1688
+ description: "CORS allowed origins, `*` will be used if empty.",
1689
+ description_zh: "允许的 CORS 来源,默认使用 `*`。"
1690
+ }),
1691
+ access_control_allow_private_network: zod.z.boolean().optional().meta({
1692
+ description: "Allow access from private network.",
1693
+ description_zh: "允许从私有网络访问。"
1694
+ })
1695
+ }).meta({
1696
+ id: "ClashAPIOptions",
1697
+ title: "Clash API",
1698
+ title_zh: "Clash API"
1699
+ });
1700
+
1701
+ //#endregion
1702
+ //#region src/schema/experimentals/v2ray-api.ts
1703
+ const V2RayAPIStatsOptions = zod.z.object({
1704
+ enabled: zod.z.boolean().optional().meta({
1705
+ description: "Enable statistics service.",
1706
+ description_zh: "启用统计服务。"
1707
+ }),
1708
+ inbounds: listableString.optional().meta({
1709
+ description: "Inbound list to count traffic.",
1710
+ description_zh: "统计流量的入站列表。"
1711
+ }),
1712
+ outbounds: listableString.optional().meta({
1713
+ description: "Outbound list to count traffic.",
1714
+ description_zh: "统计流量的出站列表。"
1715
+ }),
1716
+ users: listableString.optional().meta({
1717
+ description: "User list to count traffic.",
1718
+ description_zh: "统计流量的用户列表。"
1719
+ })
1720
+ });
1721
+ /**
1722
+ * V2Ray API settings.
1723
+ */
1724
+ const V2RayAPIOptions = zod.z.object({
1725
+ listen: zod.z.string().optional().meta({
1726
+ description: "gRPC API listening address. V2Ray API will be disabled if empty.",
1727
+ description_zh: "gRPC API 监听地址。如果为空,则禁用 V2Ray API。"
1728
+ }),
1729
+ stats: V2RayAPIStatsOptions.optional().meta({
1730
+ description: "Traffic statistics service settings.",
1731
+ description_zh: "流量统计服务设置。"
1732
+ })
1733
+ }).meta({
1734
+ id: "V2RayAPIOptions",
1735
+ title: "V2Ray API",
1736
+ title_zh: "V2Ray API"
1737
+ });
1738
+
1739
+ //#endregion
1740
+ //#region src/schema/experimental.ts
1741
+ /**
1742
+ * Experimental features settings.
1743
+ */
1744
+ const ExperimentalOptions = zod.z.object({
1745
+ cache_file: CacheFileOptions.optional().meta({
1746
+ description: "Cache file settings.",
1747
+ description_zh: "缓存文件设置。"
1748
+ }),
1749
+ clash_api: ClashAPIOptions.optional().meta({
1750
+ description: "Clash API settings.",
1751
+ description_zh: "Clash API 设置。"
1752
+ }),
1753
+ v2ray_api: V2RayAPIOptions.optional().meta({
1754
+ description: "V2Ray API settings.",
1755
+ description_zh: "V2Ray API 设置。"
1756
+ })
1757
+ }).meta({
1758
+ id: "ExperimentalOptions",
1759
+ title: "Experimental",
1760
+ title_zh: "实验性选项"
1761
+ });
1762
+
1763
+ //#endregion
1764
+ //#region src/schema/protocols/anytls.ts
1765
+ const AnyTLSUser = zod.z.object({
1766
+ name: zod.z.string().optional(),
1767
+ password: zod.z.string().optional()
1768
+ });
1769
+ const AnyTLSInboundOptions = zod.z.object({
1770
+ type: zod.z.literal("anytls"),
1771
+ tag: zod.z.string(),
1772
+ users: zod.z.array(AnyTLSUser).optional().meta({
1773
+ description: "AnyTLS users.",
1774
+ description_zh: "AnyTLS 用户。"
1775
+ }),
1776
+ padding_scheme: listableString.optional().meta({
1777
+ description: "AnyTLS padding scheme line array.",
1778
+ description_zh: "AnyTLS 填充方案行数组。"
1779
+ }),
1780
+ tls: InboundTLSOptions.optional().meta({
1781
+ description: "TLS configuration.",
1782
+ description_zh: "TLS 配置。"
1783
+ }),
1784
+ ...ListenOptions.shape
1785
+ }).meta({
1786
+ id: "AnyTLSInboundOptions",
1787
+ title: "AnyTLS Inbound",
1788
+ title_zh: "AnyTLS 入站"
1789
+ });
1790
+ const AnyTLSOutboundOptions = zod.z.object({
1791
+ type: zod.z.literal("anytls"),
1792
+ tag: zod.z.string(),
1793
+ password: zod.z.string().meta({
1794
+ description: "The AnyTLS password.",
1795
+ description_zh: "AnyTLS 密码。"
1796
+ }),
1797
+ idle_session_check_interval: zod.z.string().optional().meta({
1798
+ description: "Interval checking for idle sessions.",
1799
+ description_zh: "检查空闲会话的时间间隔。"
1800
+ }),
1801
+ idle_session_timeout: zod.z.string().optional().meta({
1802
+ description: "In the check, close sessions that have been idle for longer than this.",
1803
+ description_zh: "在检查中,关闭闲置时间超过此值的会话。"
1804
+ }),
1805
+ min_idle_session: zod.z.number().int().optional().meta({
1806
+ description: "In the check, at least the first `n` idle sessions are kept open.",
1807
+ description_zh: "在检查中,至少前 `n` 个空闲会话保持打开状态。"
1808
+ }),
1809
+ tls: OutboundTLSOptions.optional().meta({
1810
+ description: "TLS configuration.",
1811
+ description_zh: "TLS 配置。"
1812
+ }),
1813
+ ...ServerOptions.shape,
1814
+ ...DialerOptions.shape
1815
+ }).meta({
1816
+ id: "AnyTLSOutboundOptions",
1817
+ title: "AnyTLS Outbound",
1818
+ title_zh: "AnyTLS 出站"
1819
+ });
1820
+
1821
+ //#endregion
1822
+ //#region src/schema/protocols/direct.ts
1823
+ const DirectInboundOptions = zod.z.object({
1824
+ type: zod.z.literal("direct"),
1825
+ tag: zod.z.string().optional(),
1826
+ network: Network.optional().meta({
1827
+ description: "Listen network, one of `tcp` `udp`.",
1828
+ description_zh: "监听的网络协议,`tcp` `udp` 之一。"
1829
+ }),
1830
+ override_address: zod.z.string().optional().meta({
1831
+ description: "Override the connection destination address.",
1832
+ description_zh: "覆盖连接目标地址。"
1833
+ }),
1834
+ override_port: zod.z.number().int().optional().meta({
1835
+ description: "Override the connection destination port.",
1836
+ description_zh: "覆盖连接目标端口。"
1837
+ }),
1838
+ ...ListenOptions.shape
1839
+ }).meta({
1840
+ id: "DirectInboundOptions",
1841
+ title: "Direct Inbound",
1842
+ title_zh: "Direct 入站",
1843
+ description: "Direct inbound is a tunnel server.",
1844
+ description_zh: "Direct 入站是一个隧道服务器。"
1845
+ });
1846
+ const DirectOutboundOptions = zod.z.object({
1847
+ type: zod.z.literal("direct"),
1848
+ tag: zod.z.string().optional(),
1849
+ override_address: zod.z.string().optional().meta({
1850
+ description: "Override the connection destination address.",
1851
+ description_zh: "覆盖连接目标地址。",
1852
+ deprecated: true
1853
+ }),
1854
+ override_port: zod.z.number().int().optional().meta({
1855
+ description: "Override the connection destination port.",
1856
+ description_zh: "覆盖连接目标端口。",
1857
+ deprecated: true
1858
+ }),
1859
+ ...DialerOptions.shape
1860
+ }).meta({
1861
+ id: "DirectOutboundOptions",
1862
+ title: "Direct Outbound",
1863
+ title_zh: "Direct 出站",
1864
+ description: "Direct outbound send requests directly.",
1865
+ description_zh: "Direct 出站直接发送请求。"
1866
+ });
1867
+
1868
+ //#endregion
1869
+ //#region src/schema/protocols/http.ts
1870
+ const HTTPUser = zod.z.object({
1871
+ username: zod.z.string(),
1872
+ password: zod.z.string()
1873
+ });
1874
+ const HTTPInboundOptions = zod.z.object({
1875
+ type: zod.z.literal("http"),
1876
+ tag: zod.z.string().optional(),
1877
+ users: zod.z.array(HTTPUser).optional().meta({
1878
+ description: "HTTP users.",
1879
+ description_zh: "HTTP 用户。"
1880
+ }),
1881
+ tls: InboundTLSOptions.optional().meta({
1882
+ description: "TLS configuration.",
1883
+ description_zh: "TLS 配置。"
1884
+ }),
1885
+ set_system_proxy: zod.z.boolean().optional().meta({
1886
+ description: "Automatically set system proxy configuration.",
1887
+ description_zh: "启动时自动设置系统代理,停止时自动清理。"
1888
+ }),
1889
+ ...ListenOptions.shape
1890
+ }).meta({
1891
+ id: "HTTPInboundOptions",
1892
+ title: "HTTP Inbound",
1893
+ title_zh: "HTTP 入站"
1894
+ });
1895
+ const HTTPOutboundOptions = zod.z.object({
1896
+ type: zod.z.literal("http"),
1897
+ tag: zod.z.string().optional(),
1898
+ username: zod.z.string().optional().meta({
1899
+ description: "Basic authorization username.",
1900
+ description_zh: "Basic 认证用户名。"
1901
+ }),
1902
+ password: zod.z.string().optional().meta({
1903
+ description: "Basic authorization password.",
1904
+ description_zh: "Basic 认证密码。"
1905
+ }),
1906
+ path: zod.z.string().optional().meta({
1907
+ description: "Path of HTTP request.",
1908
+ description_zh: "HTTP 请求路径。"
1909
+ }),
1910
+ headers: HttpHeader.optional().meta({
1911
+ description: "Extra headers of HTTP request.",
1912
+ description_zh: "HTTP 请求的额外标头。"
1913
+ }),
1914
+ tls: OutboundTLSOptions.optional().meta({
1915
+ description: "TLS configuration.",
1916
+ description_zh: "TLS 配置。"
1917
+ }),
1918
+ ...ServerOptions.shape,
1919
+ ...DialerOptions.shape
1920
+ }).meta({
1921
+ id: "HTTPOutboundOptions",
1922
+ title: "HTTP Outbound",
1923
+ title_zh: "HTTP 出站",
1924
+ description: "HTTP outbound is a HTTP CONNECT proxy client.",
1925
+ description_zh: "HTTP 出站是一个 HTTP CONNECT 代理客户端。"
1926
+ });
1927
+
1928
+ //#endregion
1929
+ //#region src/schema/protocols/hysteria.ts
1930
+ const HysteriaUser = zod.z.object({
1931
+ name: zod.z.string().optional(),
1932
+ auth: zod.z.array(zod.z.number()).optional().meta({
1933
+ description: "Authentication password, in base64.",
1934
+ description_zh: "base64 编码的认证密码。"
1935
+ }),
1936
+ auth_str: zod.z.string().optional().meta({
1937
+ description: "Authentication password.",
1938
+ description_zh: "认证密码。"
1939
+ })
1940
+ });
1941
+ const HysteriaInboundOptions = zod.z.object({
1942
+ type: zod.z.literal("hysteria"),
1943
+ tag: zod.z.string().optional(),
1944
+ up: zod.z.string().optional(),
1945
+ up_mbps: zod.z.number().int().optional(),
1946
+ down: zod.z.string().optional(),
1947
+ down_mbps: zod.z.number().int().optional(),
1948
+ obfs: zod.z.string().optional().meta({
1949
+ description: "Obfuscated password.",
1950
+ description_zh: "混淆密码。"
1951
+ }),
1952
+ users: zod.z.array(HysteriaUser).optional().meta({
1953
+ description: "Hysteria users",
1954
+ description_zh: "Hysteria 用户"
1955
+ }),
1956
+ recv_window_conn: zod.z.number().int().optional().meta({
1957
+ description: "The QUIC stream-level flow control window for receiving data.",
1958
+ description_zh: "用于接收数据的 QUIC 流级流控制窗口。"
1959
+ }),
1960
+ recv_window_client: zod.z.number().int().optional().meta({
1961
+ description: "The QUIC connection-level flow control window for receiving data.",
1962
+ description_zh: "用于接收数据的 QUIC 连接级流控制窗口。"
1963
+ }),
1964
+ max_conn_client: zod.z.number().int().optional().meta({
1965
+ description: "The maximum number of QUIC concurrent bidirectional streams that a peer is allowed to open.",
1966
+ description_zh: "允许对等点打开的 QUIC 并发双向流的最大数量。"
1967
+ }),
1968
+ disable_mtu_discovery: zod.z.boolean().optional().meta({
1969
+ description: "Disables Path MTU Discovery (RFC 8899).",
1970
+ description_zh: "禁用路径 MTU 发现 (RFC 8899)。"
1971
+ }),
1972
+ tls: InboundTLSOptions.optional(),
1973
+ ...ListenOptions.shape
1974
+ }).meta({
1975
+ id: "HysteriaInboundOptions",
1976
+ title: "Hysteria Inbound",
1977
+ title_zh: "Hysteria 入站"
1978
+ });
1979
+ const HysteriaOutboundOptions = zod.z.object({
1980
+ type: zod.z.literal("hysteria"),
1981
+ tag: zod.z.string().optional(),
1982
+ server_ports: zod.z.union([zod.z.string(), zod.z.array(zod.z.string())]).optional().meta({
1983
+ description: "Server port range list.",
1984
+ description_zh: "服务器端口范围列表。"
1985
+ }),
1986
+ hop_interval: zod.z.string().optional().meta({
1987
+ description: "Port hopping interval.",
1988
+ description_zh: "端口跳跃间隔。"
1989
+ }),
1990
+ up: zod.z.string().optional(),
1991
+ up_mbps: zod.z.number().int().optional(),
1992
+ down: zod.z.string().optional(),
1993
+ down_mbps: zod.z.number().int().optional(),
1994
+ obfs: zod.z.string().optional().meta({
1995
+ description: "Obfuscated password.",
1996
+ description_zh: "混淆密码。"
1997
+ }),
1998
+ auth: zod.z.array(zod.z.number()).optional().meta({
1999
+ description: "Authentication password, in base64.",
2000
+ description_zh: "base64 编码的认证密码。"
2001
+ }),
2002
+ auth_str: zod.z.string().optional().meta({
2003
+ description: "Authentication password.",
2004
+ description_zh: "认证密码。"
2005
+ }),
2006
+ recv_window_conn: zod.z.number().int().optional().meta({
2007
+ description: "The QUIC stream-level flow control window for receiving data.",
2008
+ description_zh: "用于接收数据的 QUIC 流级流控制窗口。"
2009
+ }),
2010
+ recv_window: zod.z.number().int().optional().meta({
2011
+ description: "The QUIC connection-level flow control window for receiving data.",
2012
+ description_zh: "用于接收数据的 QUIC 连接级流控制窗口。"
2013
+ }),
2014
+ disable_mtu_discovery: zod.z.boolean().optional().meta({
2015
+ description: "Disables Path MTU Discovery (RFC 8899).",
2016
+ description_zh: "禁用路径 MTU 发现 (RFC 8899)。"
2017
+ }),
2018
+ network: Network.optional().meta({
2019
+ description: "Enabled network",
2020
+ description_zh: "启用的网络协议。"
2021
+ }),
2022
+ tls: OutboundTLSOptions.optional(),
2023
+ ...ServerOptions.shape,
2024
+ ...DialerOptions.shape
2025
+ }).meta({
2026
+ id: "HysteriaOutboundOptions",
2027
+ title: "Hysteria Outbound",
2028
+ title_zh: "Hysteria 出站"
2029
+ });
2030
+
2031
+ //#endregion
2032
+ //#region src/schema/protocols/hysteria2.ts
2033
+ const Hysteria2Obfs = zod.z.object({
2034
+ type: zod.z.string().optional().meta({
2035
+ description: "QUIC traffic obfuscator type, only available with `salamander`.",
2036
+ description_zh: "QUIC 流量混淆器类型,仅可设为 `salamander`。"
2037
+ }),
2038
+ password: zod.z.string().optional().meta({
2039
+ description: "QUIC traffic obfuscator password.",
2040
+ description_zh: "QUIC 流量混淆器密码。"
2041
+ })
2042
+ });
2043
+ const Hysteria2User = zod.z.object({
2044
+ name: zod.z.string().optional(),
2045
+ password: zod.z.string().optional().meta({
2046
+ description: "Authentication password",
2047
+ description_zh: "认证密码。"
2048
+ })
2049
+ });
2050
+ const Hysteria2MasqueradeFile = zod.z.object({
2051
+ type: zod.z.literal("file"),
2052
+ directory: zod.z.string().meta({
2053
+ description: "File server root directory.",
2054
+ description_zh: "文件服务器根目录。"
2055
+ })
2056
+ });
2057
+ const Hysteria2MasqueradeProxy = zod.z.object({
2058
+ type: zod.z.literal("proxy"),
2059
+ url: zod.z.string().meta({
2060
+ description: "Reverse proxy target URL.",
2061
+ description_zh: "反向代理目标 URL。"
2062
+ }),
2063
+ rewrite_host: zod.z.boolean().optional().meta({
2064
+ description: "Rewrite the `Host` header to the target URL.",
2065
+ description_zh: "重写请求头中的 Host 字段到目标 URL。"
2066
+ })
2067
+ });
2068
+ const Hysteria2MasqueradeString = zod.z.object({
2069
+ type: zod.z.literal("string"),
2070
+ status_code: zod.z.number().int().optional().meta({
2071
+ description: "Fixed response status code.",
2072
+ description_zh: "固定响应状态码。"
2073
+ }),
2074
+ headers: HttpHeader.optional().meta({
2075
+ description: "Fixed response headers.",
2076
+ description_zh: "固定响应头。"
2077
+ }),
2078
+ content: zod.z.string().meta({
2079
+ description: "Fixed response content.",
2080
+ description_zh: "固定响应内容。"
2081
+ })
2082
+ });
2083
+ const Hysteria2Masquerade = zod.z.discriminatedUnion("type", [
2084
+ Hysteria2MasqueradeFile,
2085
+ Hysteria2MasqueradeProxy,
2086
+ Hysteria2MasqueradeString
2087
+ ]).meta({
2088
+ description: "HTTP3 server behavior (Object configuration) when authentication fails.",
2089
+ description_zh: "HTTP3 服务器认证失败时的行为 (对象配置)。"
2090
+ });
2091
+ const Hysteria2InboundOptions = zod.z.object({
2092
+ type: zod.z.literal("hysteria2"),
2093
+ tag: zod.z.string().optional(),
2094
+ up_mbps: zod.z.number().int().optional(),
2095
+ down_mbps: zod.z.number().int().optional(),
2096
+ obfs: Hysteria2Obfs.optional(),
2097
+ users: zod.z.array(Hysteria2User).optional(),
2098
+ ignore_client_bandwidth: zod.z.boolean().optional().meta({
2099
+ description: "Commands clients to use the BBR CC instead of Hysteria CC.",
2100
+ description_zh: "命令客户端使用 BBR 拥塞控制算法而不是 Hysteria CC。"
2101
+ }),
2102
+ tls: InboundTLSOptions.optional(),
2103
+ masquerade: Hysteria2Masquerade.optional(),
2104
+ brutal_debug: zod.z.boolean().optional().meta({
2105
+ description: "Enable debug information logging for Hysteria Brutal CC.",
2106
+ description_zh: "启用 Hysteria Brutal CC 的调试信息日志记录。"
2107
+ }),
2108
+ ...ListenOptions.shape
2109
+ }).meta({
2110
+ id: "Hysteria2InboundOptions",
2111
+ title: "Hysteria2 Inbound",
2112
+ title_zh: "Hysteria2 入站"
2113
+ });
2114
+ const Hysteria2OutboundOptions = zod.z.object({
2115
+ type: zod.z.literal("hysteria2"),
2116
+ tag: zod.z.string().optional(),
2117
+ server_ports: zod.z.union([zod.z.string(), zod.z.array(zod.z.string())]).optional().meta({
2118
+ description: "Server port range list.",
2119
+ description_zh: "服务器端口范围列表。"
2120
+ }),
2121
+ hop_interval: zod.z.string().optional().meta({
2122
+ description: "Port hopping interval.",
2123
+ description_zh: "端口跳跃间隔。"
2124
+ }),
2125
+ up_mbps: zod.z.number().int().optional(),
2126
+ down_mbps: zod.z.number().int().optional(),
2127
+ obfs: Hysteria2Obfs.optional(),
2128
+ password: zod.z.string().optional(),
2129
+ network: Network.optional(),
2130
+ tls: OutboundTLSOptions.optional(),
2131
+ brutal_debug: zod.z.boolean().optional().meta({
2132
+ description: "Enable debug information logging for Hysteria Brutal CC.",
2133
+ description_zh: "启用 Hysteria Brutal CC 的调试信息日志记录。"
2134
+ }),
2135
+ ...ServerOptions.shape,
2136
+ ...DialerOptions.shape
2137
+ }).meta({
2138
+ id: "Hysteria2OutboundOptions",
2139
+ title: "Hysteria2 Outbound",
2140
+ title_zh: "Hysteria2 出站"
2141
+ });
2142
+
2143
+ //#endregion
2144
+ //#region src/schema/protocols/mixed.ts
2145
+ const MixedUser = zod.z.object({
2146
+ username: zod.z.string(),
2147
+ password: zod.z.string()
2148
+ });
2149
+ const MixedInboundOptions = zod.z.object({
2150
+ type: zod.z.literal("mixed"),
2151
+ tag: zod.z.string().optional(),
2152
+ users: zod.z.array(MixedUser).optional().meta({
2153
+ description: "SOCKS and HTTP users.",
2154
+ description_zh: "SOCKS 和 HTTP 用户。"
2155
+ }),
2156
+ set_system_proxy: zod.z.boolean().optional().meta({
2157
+ description: "Automatically set system proxy configuration.",
2158
+ description_zh: "启动时自动设置系统代理,停止时自动清理。"
2159
+ }),
2160
+ ...ListenOptions.shape
2161
+ }).meta({
2162
+ id: "MixedInboundOptions",
2163
+ title: "Mixed Inbound",
2164
+ title_zh: "Mixed 入站",
2165
+ description: "Mixed inbound is a socks4, socks4a, socks5 and http server.",
2166
+ description_zh: "Mixed 入站是一个 socks4, socks4a, socks5 和 http 服务器。"
2167
+ });
2168
+
2169
+ //#endregion
2170
+ //#region src/schema/protocols/naive.ts
2171
+ const NaiveUser = zod.z.object({
2172
+ username: zod.z.string(),
2173
+ password: zod.z.string()
2174
+ });
2175
+ const NaiveInboundOptions = zod.z.object({
2176
+ type: zod.z.literal("naive"),
2177
+ tag: zod.z.string().optional(),
2178
+ network: Network.optional().meta({
2179
+ description: "Listen network.",
2180
+ description_zh: "监听的网络协议。"
2181
+ }),
2182
+ users: zod.z.array(NaiveUser).meta({
2183
+ description: "Naive users.",
2184
+ description_zh: "Naive 用户。"
2185
+ }),
2186
+ tls: InboundTLSOptions.optional().meta({
2187
+ description: "TLS configuration.",
2188
+ description_zh: "TLS 配置。"
2189
+ }),
2190
+ ...ListenOptions.shape
2191
+ }).meta({
2192
+ id: "NaiveInboundOptions",
2193
+ title: "Naive Inbound",
2194
+ title_zh: "Naive 入站"
2195
+ });
2196
+
2197
+ //#endregion
2198
+ //#region src/schema/protocols/redirect.ts
2199
+ const RedirectInboundOptions = zod.z.object({
2200
+ type: zod.z.literal("redirect"),
2201
+ tag: zod.z.string().optional(),
2202
+ ...ListenOptions.shape
2203
+ }).meta({
2204
+ id: "RedirectInboundOptions",
2205
+ title: "Redirect Inbound",
2206
+ title_zh: "Redirect 入站"
2207
+ });
2208
+
2209
+ //#endregion
2210
+ //#region src/schema/protocols/shadowsocks.ts
2211
+ const ShadowsocksUser = zod.z.object({
2212
+ name: zod.z.string(),
2213
+ password: zod.z.string()
2214
+ });
2215
+ const ShadowsocksDestination = zod.z.object({
2216
+ name: zod.z.string(),
2217
+ password: zod.z.string(),
2218
+ ...ServerOptions.shape
2219
+ });
2220
+ const ShadowsocksInboundOptions = zod.z.object({
2221
+ type: zod.z.literal("shadowsocks"),
2222
+ tag: zod.z.string().optional(),
2223
+ network: Network.optional().meta({
2224
+ description: "Listen network, one of `tcp` `udp`.",
2225
+ description_zh: "监听的网络协议,`tcp` `udp` 之一。"
2226
+ }),
2227
+ method: zod.z.string(),
2228
+ password: zod.z.string().optional(),
2229
+ users: zod.z.array(ShadowsocksUser).optional(),
2230
+ destinations: zod.z.array(ShadowsocksDestination).optional(),
2231
+ multiplex: InboundMultiplexOptions.optional(),
2232
+ managed: zod.z.boolean().optional(),
2233
+ ...ListenOptions.shape
2234
+ }).meta({
2235
+ id: "ShadowsocksInboundOptions",
2236
+ title: "Shadowsocks Inbound",
2237
+ title_zh: "Shadowsocks 入站"
2238
+ });
2239
+ const ShadowsocksOutboundOptions = zod.z.object({
2240
+ type: zod.z.literal("shadowsocks"),
2241
+ tag: zod.z.string().optional(),
2242
+ method: zod.z.string(),
2243
+ password: zod.z.string(),
2244
+ plugin: zod.z.string().optional().meta({
2245
+ description: "Shadowsocks SIP003 plugin, implemented in internal.",
2246
+ description_zh: "Shadowsocks SIP003 插件,由内部实现。"
2247
+ }),
2248
+ plugin_opts: zod.z.string().optional().meta({
2249
+ description: "Shadowsocks SIP003 plugin options.",
2250
+ description_zh: "Shadowsocks SIP003 插件参数。"
2251
+ }),
2252
+ network: Network.optional().meta({
2253
+ description: "Enabled network",
2254
+ description_zh: "启用的网络协议。"
2255
+ }),
2256
+ udp_over_tcp: UDPOverTCPOptions.optional(),
2257
+ multiplex: OutboundMultiplexOptions.optional(),
2258
+ ...ServerOptions.shape,
2259
+ ...DialerOptions.shape
2260
+ }).meta({
2261
+ id: "ShadowsocksOutboundOptions",
2262
+ title: "Shadowsocks Outbound",
2263
+ title_zh: "Shadowsocks 出站"
2264
+ });
2265
+
2266
+ //#endregion
2267
+ //#region src/schema/protocols/shadowtls.ts
2268
+ const ShadowTLSUser = zod.z.object({
2269
+ name: zod.z.string(),
2270
+ password: zod.z.string()
2271
+ });
2272
+ const ShadowTLSHandshakeOptions = zod.z.object({
2273
+ ...ServerOptions.shape,
2274
+ ...DialerOptions.shape
2275
+ });
2276
+ const ShadowTLSInboundOptions = zod.z.object({
2277
+ type: zod.z.literal("shadowtls"),
2278
+ tag: zod.z.string().optional(),
2279
+ version: zod.z.number().int().min(1).max(3).optional().meta({
2280
+ description: "ShadowTLS protocol version.",
2281
+ description_zh: "ShadowTLS 协议版本。"
2282
+ }),
2283
+ password: zod.z.string().optional().meta({
2284
+ description: "ShadowTLS password.",
2285
+ description_zh: "ShadowTLS 密码。"
2286
+ }),
2287
+ users: zod.z.array(ShadowTLSUser).optional().meta({
2288
+ description: "ShadowTLS users.",
2289
+ description_zh: "ShadowTLS 用户。"
2290
+ }),
2291
+ handshake: ShadowTLSHandshakeOptions,
2292
+ handshake_for_server_name: zod.z.record(zod.z.string(), ShadowTLSHandshakeOptions).optional().meta({
2293
+ description: "Handshake server address for specific server name.",
2294
+ description_zh: "对于特定服务器名称的握手服务器地址。"
2295
+ }),
2296
+ strict_mode: zod.z.boolean().optional().meta({
2297
+ description: "ShadowTLS strict mode.",
2298
+ description_zh: "ShadowTLS 严格模式。"
2299
+ }),
2300
+ wildcard_sni: zod.z.enum([
2301
+ "off",
2302
+ "authed",
2303
+ "all"
2304
+ ]).optional().meta({
2305
+ description: "ShadowTLS wildcard SNI mode.",
2306
+ description_zh: "ShadowTLS 通配符 SNI 模式。"
2307
+ }),
2308
+ ...ListenOptions.shape
2309
+ }).meta({
2310
+ id: "ShadowTLSInboundOptions",
2311
+ title: "ShadowTLS Inbound",
2312
+ title_zh: "ShadowTLS 入站"
2313
+ });
2314
+ const ShadowTLSOutboundOptions = zod.z.object({
2315
+ type: zod.z.literal("shadowtls"),
2316
+ tag: zod.z.string().optional(),
2317
+ version: zod.z.number().int().min(1).max(3).optional().meta({
2318
+ description: "ShadowTLS protocol version.",
2319
+ description_zh: "ShadowTLS 协议版本。"
2320
+ }),
2321
+ password: zod.z.string().optional().meta({
2322
+ description: "Set password.",
2323
+ description_zh: "设置密码。"
2324
+ }),
2325
+ tls: OutboundTLSOptions.meta({
2326
+ description: "TLS configuration.",
2327
+ description_zh: "TLS 配置。"
2328
+ }),
2329
+ ...ServerOptions.shape,
2330
+ ...DialerOptions.shape
2331
+ }).meta({
2332
+ id: "ShadowTLSOutboundOptions",
2333
+ title: "ShadowTLS Outbound",
2334
+ title_zh: "ShadowTLS 出站"
2335
+ });
2336
+
2337
+ //#endregion
2338
+ //#region src/schema/protocols/socks.ts
2339
+ const SocksUser = zod.z.object({
2340
+ username: zod.z.string(),
2341
+ password: zod.z.string()
2342
+ });
2343
+ const SocksInboundOptions = zod.z.object({
2344
+ type: zod.z.literal("socks"),
2345
+ tag: zod.z.string().optional(),
2346
+ users: zod.z.array(SocksUser).optional().meta({
2347
+ description: "SOCKS users.",
2348
+ description_zh: "SOCKS 用户。"
2349
+ }),
2350
+ ...ListenOptions.shape
2351
+ }).meta({
2352
+ id: "SocksInboundOptions",
2353
+ title: "SOCKS Inbound",
2354
+ title_zh: "SOCKS 入站",
2355
+ description: "SOCKS inbound is a socks4, socks4a, socks5 server.",
2356
+ description_zh: "SOCKS 入站是一个 socks4, socks4a 和 socks5 服务器。"
2357
+ });
2358
+ const SocksOutboundOptions = zod.z.object({
2359
+ type: zod.z.literal("socks"),
2360
+ tag: zod.z.string().optional(),
2361
+ version: zod.z.enum([
2362
+ "4",
2363
+ "4a",
2364
+ "5"
2365
+ ]).optional().meta({
2366
+ description: "The SOCKS version.",
2367
+ description_zh: "SOCKS 版本。"
2368
+ }),
2369
+ username: zod.z.string().optional().meta({
2370
+ description: "SOCKS username.",
2371
+ description_zh: "SOCKS 用户名。"
2372
+ }),
2373
+ password: zod.z.string().optional().meta({
2374
+ description: "SOCKS5 password.",
2375
+ description_zh: "SOCKS5 密码。"
2376
+ }),
2377
+ network: Network.optional().meta({
2378
+ description: "Enabled network.",
2379
+ description_zh: "启用的网络协议。"
2380
+ }),
2381
+ udp_over_tcp: zod.z.union([zod.z.boolean(), UDPOverTCPOptions]).optional().meta({
2382
+ description: "UDP over TCP protocol settings.",
2383
+ description_zh: "UDP over TCP 协议设置。"
2384
+ }),
2385
+ ...ServerOptions.shape,
2386
+ ...DialerOptions.shape
2387
+ }).meta({
2388
+ id: "SocksOutboundOptions",
2389
+ title: "SOCKS Outbound",
2390
+ title_zh: "SOCKS 出站",
2391
+ description: "SOCKS outbound is a socks4/socks4a/socks5 client.",
2392
+ description_zh: "SOCKS 出站是 socks4/socks4a/socks5 客户端。"
2393
+ });
2394
+
2395
+ //#endregion
2396
+ //#region src/schema/protocols/tproxy.ts
2397
+ const TProxyInboundOptions = zod.z.object({
2398
+ type: zod.z.literal("tproxy"),
2399
+ tag: zod.z.string().optional(),
2400
+ network: Network.optional().meta({
2401
+ description: "Listen network, one of `tcp` `udp`. Both if empty.",
2402
+ description_zh: "监听的网络协议,`tcp` `udp` 之一。默认所有。"
2403
+ }),
2404
+ ...ListenOptions.shape
2405
+ }).meta({
2406
+ id: "TProxyInboundOptions",
2407
+ title: "TProxy Inbound",
2408
+ title_zh: "TProxy 入站"
2409
+ });
2410
+
2411
+ //#endregion
2412
+ //#region src/schema/protocols/trojan.ts
2413
+ const TrojanUser = zod.z.object({
2414
+ name: zod.z.string(),
2415
+ password: zod.z.string()
2416
+ });
2417
+ const TrojanInboundOptions = zod.z.object({
2418
+ type: zod.z.literal("trojan"),
2419
+ tag: zod.z.string().optional(),
2420
+ users: zod.z.array(TrojanUser).optional().meta({
2421
+ description: "Trojan users.",
2422
+ description_zh: "Trojan 用户。"
2423
+ }),
2424
+ tls: InboundTLSOptions.optional().meta({
2425
+ description: "TLS configuration.",
2426
+ description_zh: "TLS 配置。"
2427
+ }),
2428
+ fallback: ServerOptions.optional().meta({
2429
+ description: "Fallback server configuration.",
2430
+ description_zh: "回退服务器配置。"
2431
+ }),
2432
+ fallback_for_alpn: zod.z.record(zod.z.string(), ServerOptions).optional().meta({
2433
+ description: "Fallback server configuration for specified ALPN.",
2434
+ description_zh: "为 ALPN 指定回退服务器配置。"
2435
+ }),
2436
+ multiplex: InboundMultiplexOptions.optional().meta({
2437
+ description: "Multiplex configuration.",
2438
+ description_zh: "多路复用配置。"
2439
+ }),
2440
+ transport: V2RayTransportOptions.optional().meta({
2441
+ description: "V2Ray Transport configuration.",
2442
+ description_zh: "V2Ray 传输配置。"
2443
+ }),
2444
+ ...ListenOptions.shape
2445
+ }).meta({
2446
+ id: "TrojanInboundOptions",
2447
+ title: "Trojan Inbound",
2448
+ title_zh: "Trojan 入站"
2449
+ });
2450
+ const TrojanOutboundOptions = zod.z.object({
2451
+ type: zod.z.literal("trojan"),
2452
+ tag: zod.z.string().optional(),
2453
+ password: zod.z.string().meta({
2454
+ description: "The Trojan password.",
2455
+ description_zh: "Trojan 密码。"
2456
+ }),
2457
+ network: Network.optional().meta({
2458
+ description: "Enabled network.",
2459
+ description_zh: "启用的网络协议。"
2460
+ }),
2461
+ tls: OutboundTLSOptions.optional().meta({
2462
+ description: "TLS configuration.",
2463
+ description_zh: "TLS 配置。"
2464
+ }),
2465
+ multiplex: OutboundMultiplexOptions.optional().meta({
2466
+ description: "Multiplex configuration.",
2467
+ description_zh: "多路复用配置。"
2468
+ }),
2469
+ transport: V2RayTransportOptions.optional().meta({
2470
+ description: "V2Ray Transport configuration.",
2471
+ description_zh: "V2Ray 传输配置。"
2472
+ }),
2473
+ ...ServerOptions.shape,
2474
+ ...DialerOptions.shape
2475
+ }).meta({
2476
+ id: "TrojanOutboundOptions",
2477
+ title: "Trojan Outbound",
2478
+ title_zh: "Trojan 出站"
2479
+ });
2480
+
2481
+ //#endregion
2482
+ //#region src/schema/protocols/tuic.ts
2483
+ const TUICUser = zod.z.object({
2484
+ name: zod.z.string().optional(),
2485
+ uuid: zod.z.uuid().optional().meta({
2486
+ description: "TUIC user uuid",
2487
+ description_zh: "TUIC 用户 UUID"
2488
+ }),
2489
+ password: zod.z.string().optional().meta({
2490
+ description: "TUIC user password",
2491
+ description_zh: "TUIC 用户密码"
2492
+ })
2493
+ });
2494
+ const TUICInboundOptions = zod.z.object({
2495
+ type: zod.z.literal("tuic"),
2496
+ tag: zod.z.string().optional(),
2497
+ users: zod.z.array(TUICUser).optional(),
2498
+ congestion_control: zod.z.string().optional().meta({
2499
+ description: "QUIC congestion control algorithm",
2500
+ description_zh: "QUIC 拥塞控制算法"
2501
+ }),
2502
+ auth_timeout: zod.z.string().optional().meta({
2503
+ description: "How long the server should wait for the client to send the authentication command",
2504
+ description_zh: "服务器等待客户端发送认证命令的时间"
2505
+ }),
2506
+ zero_rtt_handshake: zod.z.boolean().optional().meta({
2507
+ description: "Enable 0-RTT QUIC connection handshake on the client side",
2508
+ description_zh: "在客户端启用 0-RTT QUIC 连接握手"
2509
+ }),
2510
+ heartbeat: zod.z.string().optional().meta({
2511
+ description: "Interval for sending heartbeat packets for keeping the connection alive",
2512
+ description_zh: "发送心跳包以保持连接存活的时间间隔"
2513
+ }),
2514
+ tls: InboundTLSOptions.optional(),
2515
+ ...ListenOptions.shape
2516
+ }).meta({
2517
+ id: "TUICInboundOptions",
2518
+ title: "TUIC Inbound",
2519
+ title_zh: "TUIC 入站"
2520
+ });
2521
+ const TUICOutboundOptions = zod.z.object({
2522
+ type: zod.z.literal("tuic"),
2523
+ tag: zod.z.string().optional(),
2524
+ uuid: zod.z.uuid().optional().meta({
2525
+ description: "TUIC user uuid",
2526
+ description_zh: "TUIC 用户 UUID"
2527
+ }),
2528
+ password: zod.z.string().optional().meta({
2529
+ description: "TUIC user password",
2530
+ description_zh: "TUIC 用户密码"
2531
+ }),
2532
+ congestion_control: zod.z.string().optional().meta({
2533
+ description: "QUIC congestion control algorithm",
2534
+ description_zh: "QUIC 拥塞控制算法"
2535
+ }),
2536
+ udp_relay_mode: zod.z.string().optional().meta({
2537
+ description: "UDP packet relay mode",
2538
+ description_zh: "UDP 包中继模式"
2539
+ }),
2540
+ udp_over_stream: zod.z.boolean().optional().meta({
2541
+ description: "This is the TUIC port of the UDP over TCP protocol, designed to provide a QUIC stream based UDP relay mode that TUIC does not provide.",
2542
+ description_zh: "这是 TUIC 的 UDP over TCP 协议移植, 旨在提供 TUIC 不提供的 基于 QUIC 流的 UDP 中继模式。"
2543
+ }),
2544
+ zero_rtt_handshake: zod.z.boolean().optional().meta({
2545
+ description: "Enable 0-RTT QUIC connection handshake on the client side",
2546
+ description_zh: "在客户端启用 0-RTT QUIC 连接握手"
2547
+ }),
2548
+ heartbeat: zod.z.string().optional().meta({
2549
+ description: "Interval for sending heartbeat packets for keeping the connection alive",
2550
+ description_zh: "发送心跳包以保持连接存活的时间间隔"
2551
+ }),
2552
+ network: Network.optional(),
2553
+ tls: OutboundTLSOptions.optional(),
2554
+ ...ServerOptions.shape,
2555
+ ...DialerOptions.shape
2556
+ }).meta({
2557
+ id: "TUICOutboundOptions",
2558
+ title: "TUIC Outbound",
2559
+ title_zh: "TUIC 出站"
2560
+ });
2561
+
2562
+ //#endregion
2563
+ //#region src/schema/protocols/tun.ts
2564
+ const HTTPProxyOptions = zod.z.object({
2565
+ enabled: zod.z.boolean().optional().meta({
2566
+ description: "Enable system HTTP proxy.",
2567
+ description_zh: "启用系统 HTTP 代理。"
2568
+ }),
2569
+ server: zod.z.string().meta({
2570
+ description: "HTTP proxy server address.",
2571
+ description_zh: "系统 HTTP 代理服务器地址。"
2572
+ }),
2573
+ server_port: zod.z.number().int().meta({
2574
+ description: "HTTP proxy server port.",
2575
+ description_zh: "系统 HTTP 代理服务器端口。"
2576
+ }),
2577
+ bypass_domain: listableString.optional().meta({
2578
+ description: "Hostnames that bypass the HTTP proxy.",
2579
+ description_zh: "绕过代理的主机名列表。"
2580
+ }),
2581
+ match_domain: listableString.optional().meta({
2582
+ description: "Hostnames that use the HTTP proxy.",
2583
+ description_zh: "代理的主机名列表。"
2584
+ })
2585
+ });
2586
+ const TunPlatformOptions = zod.z.object({ http_proxy: HTTPProxyOptions.optional().meta({
2587
+ description: "System HTTP proxy settings.",
2588
+ description_zh: "系统 HTTP 代理设置。"
2589
+ }) });
2590
+ const TunInboundOptions = zod.z.object({
2591
+ type: zod.z.literal("tun"),
2592
+ tag: zod.z.string().optional(),
2593
+ interface_name: zod.z.string().optional().meta({
2594
+ description: "Virtual device name, automatically selected if empty.",
2595
+ description_zh: "虚拟设备名称,默认自动选择。"
2596
+ }),
2597
+ address: listableString.optional().meta({
2598
+ description: "IPv4 and IPv6 prefix for the tun interface.",
2599
+ description_zh: "tun 接口的 IPv4 和 IPv6 前缀。"
2600
+ }),
2601
+ mtu: zod.z.number().int().optional().meta({
2602
+ description: "The maximum transmission unit.",
2603
+ description_zh: "最大传输单元。"
2604
+ }),
2605
+ auto_route: zod.z.boolean().optional().meta({
2606
+ description: "Set the default route to the Tun.",
2607
+ description_zh: "设置到 Tun 的默认路由。"
2608
+ }),
2609
+ iproute2_table_index: zod.z.number().int().optional().meta({
2610
+ description: "Linux iproute2 table index generated by `auto_route`.",
2611
+ description_zh: "`auto_route` 生成的 iproute2 路由表索引。"
2612
+ }),
2613
+ iproute2_rule_index: zod.z.number().int().optional().meta({
2614
+ description: "Linux iproute2 rule start index generated by `auto_route`.",
2615
+ description_zh: "`auto_route` 生成的 iproute2 规则起始索引。"
2616
+ }),
2617
+ auto_redirect: zod.z.boolean().optional().meta({
2618
+ description: "Improve TUN routing and performance using nftables.",
2619
+ description_zh: "通过使用 nftables 改善 TUN 路由和性能。"
2620
+ }),
2621
+ auto_redirect_input_mark: FwMark.optional().meta({
2622
+ description: "Connection input mark used by `auto_redirect`.",
2623
+ description_zh: "`auto_redirect` 使用的连接输入标记。"
2624
+ }),
2625
+ auto_redirect_output_mark: FwMark.optional().meta({
2626
+ description: "Connection output mark used by `auto_redirect`.",
2627
+ description_zh: "`auto_redirect` 使用的连接输出标记。"
2628
+ }),
2629
+ loopback_address: listableString.optional().meta({
2630
+ description: "Loopback addresses make TCP connections to the specified address connect to the source address.",
2631
+ description_zh: "环回地址是用于使指向指定地址的 TCP 连接连接到来源地址的。"
2632
+ }),
2633
+ strict_route: zod.z.boolean().optional().meta({
2634
+ description: "Enforce strict routing rules when `auto_route` is enabled.",
2635
+ description_zh: "当启用 `auto_route` 时,强制执行严格的路由规则。"
2636
+ }),
2637
+ route_address: listableString.optional().meta({
2638
+ description: "Use custom routes instead of default when `auto_route` is enabled.",
2639
+ description_zh: "设置到 Tun 的自定义路由。"
2640
+ }),
2641
+ route_address_set: listableString.optional().meta({
2642
+ description: "Add the destination IP CIDR rules in the specified rule-sets to the firewall.",
2643
+ description_zh: "将指定规则集中的目标 IP CIDR 规则添加到防火墙。"
2644
+ }),
2645
+ route_exclude_address: listableString.optional().meta({
2646
+ description: "Exclude custom routes when `auto_route` is enabled.",
2647
+ description_zh: "设置到 Tun 的排除自定义路由。"
2648
+ }),
2649
+ route_exclude_address_set: listableString.optional().meta({
2650
+ description: "Add the destination IP CIDR rules in the specified rule-sets to the firewall.",
2651
+ description_zh: "将指定规则集中的目标 IP CIDR 规则添加到防火墙。"
2652
+ }),
2653
+ include_interface: listableString.optional().meta({
2654
+ description: "Limit interfaces in route.",
2655
+ description_zh: "限制被路由的接口。"
2656
+ }),
2657
+ exclude_interface: listableString.optional().meta({
2658
+ description: "Exclude interfaces in route.",
2659
+ description_zh: "排除路由的接口。"
2660
+ }),
2661
+ include_uid: listableInts.optional().meta({
2662
+ description: "Limit users in route.",
2663
+ description_zh: "限制被路由的用户。"
2664
+ }),
2665
+ include_uid_range: listableString.optional().meta({
2666
+ description: "Limit users in route, but in range.",
2667
+ description_zh: "限制被路由的用户范围。"
2668
+ }),
2669
+ exclude_uid: listableInts.optional().meta({
2670
+ description: "Exclude users in route.",
2671
+ description_zh: "排除路由的用户。"
2672
+ }),
2673
+ exclude_uid_range: listableString.optional().meta({
2674
+ description: "Exclude users in route, but in range.",
2675
+ description_zh: "排除路由的用户范围。"
2676
+ }),
2677
+ include_android_user: listableInts.optional().meta({
2678
+ description: "Limit android users in route.",
2679
+ description_zh: "限制被路由的 Android 用户。"
2680
+ }),
2681
+ include_package: listableString.optional().meta({
2682
+ description: "Limit android packages in route.",
2683
+ description_zh: "限制被路由的 Android 应用包名。"
2684
+ }),
2685
+ exclude_package: listableString.optional().meta({
2686
+ description: "Exclude android packages in route.",
2687
+ description_zh: "排除路由的 Android 应用包名。"
2688
+ }),
2689
+ stack: zod.z.enum([
2690
+ "system",
2691
+ "gvisor",
2692
+ "mixed"
2693
+ ]).optional().meta({
2694
+ description: "TCP/IP stack.",
2695
+ description_zh: "TCP/IP 栈。"
2696
+ }),
2697
+ platform: TunPlatformOptions.optional().meta({
2698
+ description: "Platform-specific settings, provided by client applications.",
2699
+ description_zh: "平台特定的设置,由客户端应用提供。"
2700
+ }),
2701
+ gso: zod.z.boolean().optional().meta({
2702
+ description: "Enable generic segmentation offload.",
2703
+ description_zh: "启用通用分段卸载。",
2704
+ deprecated: true
2705
+ }),
2706
+ inet4_address: listableString.optional().meta({
2707
+ description: "IPv4 prefix for the tun interface.",
2708
+ description_zh: "tun 接口的 IPv4 前缀。",
2709
+ deprecated: true
2710
+ }),
2711
+ inet6_address: listableString.optional().meta({
2712
+ description: "IPv6 prefix for the tun interface.",
2713
+ description_zh: "tun 接口的 IPv6 前缀。",
2714
+ deprecated: true
2715
+ }),
2716
+ inet4_route_address: listableString.optional().meta({
2717
+ description: "Use custom routes instead of default when `auto_route` is enabled.",
2718
+ description_zh: "启用 `auto_route` 时使用自定义路由而不是默认路由。",
2719
+ deprecated: true
2720
+ }),
2721
+ inet6_route_address: listableString.optional().meta({
2722
+ description: "Use custom routes instead of default when `auto_route` is enabled.",
2723
+ description_zh: "启用 `auto_route` 时使用自定义路由而不是默认路由。",
2724
+ deprecated: true
2725
+ }),
2726
+ inet4_route_exclude_address: listableString.optional().meta({
2727
+ description: "Exclude custom routes when `auto_route` is enabled.",
2728
+ description_zh: "启用 `auto_route` 时排除自定义路由。",
2729
+ deprecated: true
2730
+ }),
2731
+ inet6_route_exclude_address: listableString.optional().meta({
2732
+ description: "Exclude custom routes when `auto_route` is enabled.",
2733
+ description_zh: "启用 `auto_route` 时排除自定义路由。",
2734
+ deprecated: true
2735
+ }),
2736
+ endpoint_independent_nat: zod.z.boolean().optional().meta({
2737
+ description: "Enable endpoint-independent NAT.",
2738
+ description_zh: "启用独立于端点的 NAT。"
2739
+ }),
2740
+ ...ListenOptions.shape
2741
+ }).meta({
2742
+ id: "TunInboundOptions",
2743
+ title: "Tun Inbound",
2744
+ title_zh: "Tun 入站"
2745
+ });
2746
+
2747
+ //#endregion
2748
+ //#region src/schema/protocols/vless.ts
2749
+ const VLESSUser = zod.z.object({
2750
+ name: zod.z.string(),
2751
+ uuid: zod.z.uuid(),
2752
+ flow: zod.z.string().optional().meta({
2753
+ description: "VLESS Sub-protocol.",
2754
+ description_zh: "VLESS 子协议。"
2755
+ })
2756
+ });
2757
+ const VLESSInboundOptions = zod.z.object({
2758
+ type: zod.z.literal("vless"),
2759
+ tag: zod.z.string().optional(),
2760
+ users: zod.z.array(VLESSUser).optional().meta({
2761
+ description: "VLESS users.",
2762
+ description_zh: "VLESS 用户。"
2763
+ }),
2764
+ tls: InboundTLSOptions.optional().meta({
2765
+ description: "TLS configuration.",
2766
+ description_zh: "TLS 配置。"
2767
+ }),
2768
+ multiplex: InboundMultiplexOptions.optional().meta({
2769
+ description: "Multiplex configuration.",
2770
+ description_zh: "多路复用配置。"
2771
+ }),
2772
+ transport: V2RayTransportOptions.optional().meta({
2773
+ description: "V2Ray Transport configuration.",
2774
+ description_zh: "V2Ray 传输配置。"
2775
+ }),
2776
+ ...ListenOptions.shape
2777
+ }).meta({
2778
+ id: "VLESSInboundOptions",
2779
+ title: "VLESS Inbound",
2780
+ title_zh: "VLESS 入站"
2781
+ });
2782
+ const VLESSOutboundOptions = zod.z.object({
2783
+ type: zod.z.literal("vless"),
2784
+ tag: zod.z.string().optional(),
2785
+ uuid: zod.z.uuid().meta({
2786
+ description: "VLESS user id.",
2787
+ description_zh: "VLESS 用户 ID。"
2788
+ }),
2789
+ flow: zod.z.string().optional().meta({
2790
+ description: "VLESS Sub-protocol.",
2791
+ description_zh: "VLESS 子协议。"
2792
+ }),
2793
+ network: Network.optional().meta({
2794
+ description: "Enabled network.",
2795
+ description_zh: "启用的网络协议。"
2796
+ }),
2797
+ tls: OutboundTLSOptions.optional().meta({
2798
+ description: "TLS configuration.",
2799
+ description_zh: "TLS 配置。"
2800
+ }),
2801
+ multiplex: OutboundMultiplexOptions.optional().meta({
2802
+ description: "Multiplex configuration.",
2803
+ description_zh: "多路复用配置。"
2804
+ }),
2805
+ transport: V2RayTransportOptions.optional().meta({
2806
+ description: "V2Ray Transport configuration.",
2807
+ description_zh: "V2Ray 传输配置。"
2808
+ }),
2809
+ packet_encoding: zod.z.string().optional().meta({
2810
+ description: "UDP packet encoding, xudp is used by default.",
2811
+ description_zh: "UDP 包编码,默认使用 xudp。"
2812
+ }),
2813
+ ...ServerOptions.shape,
2814
+ ...DialerOptions.shape
2815
+ }).meta({
2816
+ id: "VLESSOutboundOptions",
2817
+ title: "VLESS Outbound",
2818
+ title_zh: "VLESS 出站"
2819
+ });
2820
+
2821
+ //#endregion
2822
+ //#region src/schema/protocols/vmess.ts
2823
+ const VMessUser = zod.z.object({
2824
+ name: zod.z.string(),
2825
+ uuid: zod.z.uuid(),
2826
+ alterId: zod.z.number().int().optional().meta({
2827
+ description: "Alter ID.",
2828
+ description_zh: "Alter ID。"
2829
+ })
2830
+ });
2831
+ const VMessInboundOptions = zod.z.object({
2832
+ type: zod.z.literal("vmess"),
2833
+ tag: zod.z.string().optional(),
2834
+ users: zod.z.array(VMessUser).optional().meta({
2835
+ description: "VMess users.",
2836
+ description_zh: "VMess 用户。"
2837
+ }),
2838
+ tls: InboundTLSOptions.optional().meta({
2839
+ description: "TLS configuration.",
2840
+ description_zh: "TLS 配置。"
2841
+ }),
2842
+ multiplex: InboundMultiplexOptions.optional().meta({
2843
+ description: "Multiplex configuration.",
2844
+ description_zh: "多路复用配置。"
2845
+ }),
2846
+ transport: V2RayTransportOptions.optional().meta({
2847
+ description: "V2Ray Transport configuration.",
2848
+ description_zh: "V2Ray 传输配置。"
2849
+ }),
2850
+ ...ListenOptions.shape
2851
+ }).meta({
2852
+ id: "VMessInboundOptions",
2853
+ title: "VMess Inbound",
2854
+ title_zh: "VMess 入站"
2855
+ });
2856
+ const VMessOutboundOptions = zod.z.object({
2857
+ type: zod.z.literal("vmess"),
2858
+ tag: zod.z.string().optional(),
2859
+ uuid: zod.z.uuid().meta({
2860
+ description: "The VMess user id.",
2861
+ description_zh: "VMess 用户 ID。"
2862
+ }),
2863
+ security: zod.z.string().meta({
2864
+ description: "Encryption methods.",
2865
+ description_zh: "加密方法。"
2866
+ }),
2867
+ alter_id: zod.z.number().int().optional().meta({
2868
+ description: "Alter ID.",
2869
+ description_zh: "Alter ID。"
2870
+ }),
2871
+ global_padding: zod.z.boolean().optional().meta({
2872
+ description: "Protocol parameter. Will waste traffic randomly if enabled.",
2873
+ description_zh: "协议参数。如果启用会随机浪费流量。"
2874
+ }),
2875
+ authenticated_length: zod.z.boolean().optional().meta({
2876
+ description: "Protocol parameter. Enable length block encryption.",
2877
+ description_zh: "协议参数。启用长度块加密。"
2878
+ }),
2879
+ network: Network.optional().meta({
2880
+ description: "Enabled network.",
2881
+ description_zh: "启用的网络协议。"
2882
+ }),
2883
+ tls: OutboundTLSOptions.optional().meta({
2884
+ description: "TLS configuration.",
2885
+ description_zh: "TLS 配置。"
2886
+ }),
2887
+ packet_encoding: zod.z.string().optional().meta({
2888
+ description: "UDP packet encoding.",
2889
+ description_zh: "UDP 包编码。"
2890
+ }),
2891
+ multiplex: OutboundMultiplexOptions.optional().meta({
2892
+ description: "Multiplex configuration.",
2893
+ description_zh: "多路复用配置。"
2894
+ }),
2895
+ transport: V2RayTransportOptions.optional().meta({
2896
+ description: "V2Ray Transport configuration.",
2897
+ description_zh: "V2Ray 传输配置。"
2898
+ }),
2899
+ ...DialerOptions.shape,
2900
+ ...ServerOptions.shape
2901
+ }).meta({
2902
+ id: "VMessOutboundOptions",
2903
+ title: "VMess Outbound",
2904
+ title_zh: "VMess 出站"
2905
+ });
2906
+
2907
+ //#endregion
2908
+ //#region src/schema/inbound.ts
2909
+ const Inbound = zod.z.discriminatedUnion("type", [
2910
+ DirectInboundOptions,
2911
+ MixedInboundOptions,
2912
+ SocksInboundOptions,
2913
+ HTTPInboundOptions,
2914
+ ShadowsocksInboundOptions,
2915
+ VMessInboundOptions,
2916
+ TrojanInboundOptions,
2917
+ NaiveInboundOptions,
2918
+ HysteriaInboundOptions,
2919
+ ShadowTLSInboundOptions,
2920
+ Hysteria2InboundOptions,
2921
+ AnyTLSInboundOptions,
2922
+ VLESSInboundOptions,
2923
+ TUICInboundOptions,
2924
+ TunInboundOptions,
2925
+ RedirectInboundOptions,
2926
+ TProxyInboundOptions
2927
+ ]).meta({
2928
+ id: "Inbound",
2929
+ title: "Inbound",
2930
+ title_zh: "入站"
2931
+ });
2932
+
2933
+ //#endregion
2934
+ //#region src/schema/log.ts
2935
+ /**
2936
+ * Log settings for sing-box.
2937
+ */
2938
+ const LogOptions = zod.default.object({
2939
+ disabled: zod.default.boolean().optional().meta({
2940
+ description: "Disable logging, no output after start.",
2941
+ description_zh: "禁用日志,启动后不输出日志。"
2942
+ }),
2943
+ level: zod.default.enum([
2944
+ "trace",
2945
+ "debug",
2946
+ "info",
2947
+ "warn",
2948
+ "error",
2949
+ "fatal",
2950
+ "panic"
2951
+ ]).optional().meta({
2952
+ description: "Log level. One of: `trace` `debug` `info` `warn` `error` `fatal` `panic`.",
2953
+ description_zh: "日志等级,可选值:`trace` `debug` `info` `warn` `error` `fatal` `panic`。"
2954
+ }),
2955
+ output: zod.default.string().optional().meta({
2956
+ description: "Output file path. Will not write log to console after enable.",
2957
+ description_zh: "输出文件路径,启动后将不输出到控制台。"
2958
+ }),
2959
+ timestamp: zod.default.boolean().optional().meta({
2960
+ description: "Add time to each line.",
2961
+ description_zh: "添加时间到每行。"
2962
+ })
2963
+ }).meta({
2964
+ id: "LogOptions",
2965
+ title: "Log",
2966
+ title_zh: "日志",
2967
+ description: "Log settings for sing-box.",
2968
+ description_zh: "sing-box 日志设置。"
2969
+ });
2970
+
2971
+ //#endregion
2972
+ //#region src/schema/ntp.ts
2973
+ const NTPOptions = zod.z.object({
2974
+ enabled: zod.z.boolean().optional().meta({
2975
+ description: "Enable NTP service.",
2976
+ description_zh: "启用 NTP 服务。"
2977
+ }),
2978
+ interval: zod.z.string().optional().meta({
2979
+ description: "Time synchronization interval.",
2980
+ description_zh: "时间同步间隔。"
2981
+ }),
2982
+ write_to_system: zod.z.boolean().optional().meta({ description: "Write the updated time to the system." }),
2983
+ ...ServerOptions.shape,
2984
+ ...DialerOptions.shape
2985
+ }).meta({
2986
+ id: "NTPOptions",
2987
+ title: "NTP",
2988
+ title_zh: "NTP",
2989
+ description: "Built-in NTP client service.",
2990
+ description_zh: "内建的 NTP 客户端服务。"
2991
+ });
2992
+
2993
+ //#endregion
2994
+ //#region src/schema/groups/selector.ts
2995
+ const SelectorOutbound = zod.z.object({
2996
+ type: zod.z.literal("selector"),
2997
+ tag: zod.z.string(),
2998
+ outbounds: zod.z.array(zod.z.string()).meta({
2999
+ description: "List of outbound tags to select.",
3000
+ description_zh: "用于选择的出站标签列表。"
3001
+ }),
3002
+ default: zod.z.string().optional().meta({
3003
+ description: "The default outbound tag. The first outbound will be used if empty.",
3004
+ description_zh: "默认的出站标签。默认使用第一个出站。"
3005
+ }),
3006
+ interrupt_exist_connections: zod.z.boolean().optional().meta({
3007
+ description: "Interrupt existing connections when the selected outbound has changed.",
3008
+ description_zh: "当选定的出站发生更改时,中断现有连接。"
3009
+ })
3010
+ }).meta({
3011
+ id: "SelectorOutbound",
3012
+ title: "Selector Outbound",
3013
+ title_zh: "选择器出站"
3014
+ });
3015
+
3016
+ //#endregion
3017
+ //#region src/schema/groups/urltest.ts
3018
+ const URLTestOutbound = zod.z.object({
3019
+ type: zod.z.literal("urltest"),
3020
+ tag: zod.z.string(),
3021
+ outbounds: zod.z.array(zod.z.string()).meta({
3022
+ description: "List of outbound tags to test.",
3023
+ description_zh: "用于测试的出站标签列表。"
3024
+ }),
3025
+ url: zod.z.string().url().optional().meta({
3026
+ description: "The URL to test.",
3027
+ description_zh: "用于测试的链接。"
3028
+ }),
3029
+ interval: zod.z.string().optional().meta({
3030
+ description: "The test interval.",
3031
+ description_zh: "测试间隔。"
3032
+ }),
3033
+ tolerance: zod.z.number().int().optional().meta({
3034
+ description: "The test tolerance in milliseconds.",
3035
+ description_zh: "以毫秒为单位的测试容差。"
3036
+ }),
3037
+ idle_timeout: zod.z.string().optional().meta({
3038
+ description: "The idle timeout.",
3039
+ description_zh: "空闲超时。"
3040
+ }),
3041
+ interrupt_exist_connections: zod.z.boolean().optional().meta({
3042
+ description: "Interrupt existing connections when the selected outbound has changed.",
3043
+ description_zh: "当选定的出站发生更改时,中断现有连接。"
3044
+ })
3045
+ }).meta({
3046
+ id: "URLTestOutbound",
3047
+ title: "URLTest Outbound",
3048
+ title_zh: "URLTest 出站"
3049
+ });
3050
+
3051
+ //#endregion
3052
+ //#region src/schema/protocols/shadowsocksr.ts
3053
+ const ShadowsocksROutboundOptions = zod.z.object({
3054
+ type: zod.z.literal("shadowsocksr"),
3055
+ tag: zod.z.string().optional(),
3056
+ method: zod.z.string(),
3057
+ password: zod.z.string(),
3058
+ obfs: zod.z.string().optional(),
3059
+ obfs_param: zod.z.string().optional(),
3060
+ protocol: zod.z.string().optional(),
3061
+ protocol_param: zod.z.string().optional(),
3062
+ network: Network.optional(),
3063
+ ...ServerOptions.shape,
3064
+ ...DialerOptions.shape
3065
+ }).meta({
3066
+ id: "ShadowsocksROutboundOptions",
3067
+ title: "ShadowsocksR Outbound",
3068
+ title_zh: "ShadowsocksR 出站",
3069
+ deprecated: true
3070
+ });
3071
+
3072
+ //#endregion
3073
+ //#region src/schema/protocols/ssh.ts
3074
+ const SSHOutboundOptions = zod.z.object({
3075
+ type: zod.z.literal("ssh"),
3076
+ tag: zod.z.string().optional(),
3077
+ user: zod.z.string().optional().meta({
3078
+ description: "SSH user, root will be used if empty.",
3079
+ description_zh: "SSH 用户, 默认使用 root。"
3080
+ }),
3081
+ password: zod.z.string().optional().meta({
3082
+ description: "Password.",
3083
+ description_zh: "密码。"
3084
+ }),
3085
+ private_key: listableString.optional().meta({
3086
+ description: "Private key.",
3087
+ description_zh: "密钥。"
3088
+ }),
3089
+ private_key_path: zod.z.string().optional().meta({
3090
+ description: "Private key path.",
3091
+ description_zh: "密钥路径。"
3092
+ }),
3093
+ private_key_passphrase: zod.z.string().optional().meta({
3094
+ description: "Private key passphrase.",
3095
+ description_zh: "密钥密码。"
3096
+ }),
3097
+ host_key: listableString.optional().meta({
3098
+ description: "Host key. Accept any if empty.",
3099
+ description_zh: "主机密钥,留空接受所有。"
3100
+ }),
3101
+ host_key_algorithms: listableString.optional().meta({
3102
+ description: "Host key algorithms.",
3103
+ description_zh: "主机密钥算法。"
3104
+ }),
3105
+ client_version: zod.z.string().optional().meta({
3106
+ description: "Client version. Random version will be used if empty.",
3107
+ description_zh: "客户端版本,默认使用随机值。"
3108
+ }),
3109
+ ...ServerOptions.shape,
3110
+ ...DialerOptions.shape
3111
+ }).meta({
3112
+ id: "SSHOutboundOptions",
3113
+ title: "SSH Outbound",
3114
+ title_zh: "SSH 出站"
3115
+ });
3116
+
3117
+ //#endregion
3118
+ //#region src/schema/protocols/tor.ts
3119
+ const TorOutboundOptions = zod.z.object({
3120
+ type: zod.z.literal("tor"),
3121
+ tag: zod.z.string().optional(),
3122
+ executable_path: zod.z.string().optional().meta({
3123
+ description: "The path to the Tor executable.",
3124
+ description_zh: "Tor 可执行文件路径。"
3125
+ }),
3126
+ extra_args: zod.z.array(zod.z.string()).optional().meta({
3127
+ description: "List of extra arguments passed to the Tor instance when started.",
3128
+ description_zh: "启动 Tor 时传递的附加参数列表。"
3129
+ }),
3130
+ data_directory: zod.z.string().optional().meta({
3131
+ description: "The data directory of Tor.",
3132
+ description_zh: "Tor 的数据目录。"
3133
+ }),
3134
+ torrc: zod.z.record(zod.z.string(), zod.z.any()).optional().meta({
3135
+ description: "Map of torrc options.",
3136
+ description_zh: "torrc 参数表。"
3137
+ }),
3138
+ ...DialerOptions.shape
3139
+ }).meta({
3140
+ id: "TorOutboundOptions",
3141
+ title: "Tor Outbound",
3142
+ title_zh: "Tor 出站"
3143
+ });
3144
+
3145
+ //#endregion
3146
+ //#region src/schema/outbound.ts
3147
+ const Outbound = zod.z.discriminatedUnion("type", [
3148
+ DirectOutboundOptions,
3149
+ SocksOutboundOptions,
3150
+ HTTPOutboundOptions,
3151
+ ShadowsocksOutboundOptions,
3152
+ VMessOutboundOptions,
3153
+ TrojanOutboundOptions,
3154
+ LegacyWireGuardOutboundOptions,
3155
+ HysteriaOutboundOptions,
3156
+ ShadowTLSOutboundOptions,
3157
+ AnyTLSOutboundOptions,
3158
+ Hysteria2OutboundOptions,
3159
+ TUICOutboundOptions,
3160
+ VLESSOutboundOptions,
3161
+ ShadowsocksROutboundOptions,
3162
+ SSHOutboundOptions,
3163
+ TorOutboundOptions,
3164
+ SelectorOutbound,
3165
+ URLTestOutbound
3166
+ ]).meta({
3167
+ id: "Outbound",
3168
+ title: "Outbound",
3169
+ title_zh: "出站"
3170
+ });
3171
+
3172
+ //#endregion
3173
+ //#region src/schema/rules/route-rule.ts
3174
+ const RuleActionRouteOptions = zod.z.object({
3175
+ override_address: zod.z.string().optional().meta({
3176
+ description: "Override the connection destination address.",
3177
+ description_zh: "覆盖连接目标地址。"
3178
+ }),
3179
+ override_port: zod.z.number().int().min(0).max(65535).optional().meta({
3180
+ description: "Override the connection destination port.",
3181
+ description_zh: "覆盖连接目标端口。"
3182
+ }),
3183
+ network_strategy: zod.z.enum([
3184
+ "prefer_ipv4",
3185
+ "prefer_ipv6",
3186
+ "ipv4_only",
3187
+ "ipv6_only"
3188
+ ]).optional().meta({
3189
+ description: "See Dial Fields for details.",
3190
+ description_zh: "详情参阅拨号字段。"
3191
+ }),
3192
+ fallback_delay: zod.z.string().optional().meta({
3193
+ description: "See Dial Fields for details.",
3194
+ description_zh: "详情参阅拨号字段。"
3195
+ }),
3196
+ udp_disable_domain_unmapping: zod.z.boolean().optional().meta({
3197
+ description: "If enabled, for UDP proxy requests addressed to a domain, the original packet address will be sent in the response instead of the mapped domain.",
3198
+ description_zh: "如果启用,对于地址为域的 UDP 代理请求,将在响应中发送原始包地址而不是映射的域。"
3199
+ }),
3200
+ udp_connect: zod.z.boolean().optional().meta({
3201
+ description: "If enabled, attempts to connect UDP connection to the destination instead of listen.",
3202
+ description_zh: "如果启用,将尝试将 UDP 连接 connect 到目标而不是 listen。"
3203
+ }),
3204
+ udp_timeout: zod.z.string().optional().meta({
3205
+ description: "Timeout for UDP connections.",
3206
+ description_zh: "UDP 连接超时时间。"
3207
+ }),
3208
+ tls_fragment: zod.z.boolean().optional().meta({
3209
+ description: "Fragment TLS handshakes to bypass firewalls.",
3210
+ description_zh: "通过分段 TLS 握手数据包来绕过防火墙检测。"
3211
+ }),
3212
+ tls_fragment_fallback_delay: zod.z.string().optional().meta({
3213
+ description: "The fallback value used when TLS segmentation cannot automatically determine the wait time.",
3214
+ description_zh: "当 TLS 分片功能无法自动判定等待时间时使用的回退值。"
3215
+ }),
3216
+ tls_record_fragment: zod.z.string().optional().meta({
3217
+ description: "Fragment TLS handshake into multiple TLS records to bypass firewalls.",
3218
+ description_zh: "通过分段 TLS 握手数据包到多个 TLS 记录来绕过防火墙检测。"
3219
+ })
3220
+ }).meta({
3221
+ id: "RuleActionRouteOptions",
3222
+ title: "Rule Action Route Options",
3223
+ title_zh: "规则动作路由选项"
3224
+ });
3225
+ const RuleActionSniff = zod.z.object({
3226
+ action: zod.z.literal("sniff").meta({
3227
+ description: "Performs protocol sniffing on connections.",
3228
+ description_zh: "对连接执行协议嗅探。"
3229
+ }),
3230
+ sniffer: listableString.optional().meta({
3231
+ description: "Enabled sniffers. All sniffers enabled by default.",
3232
+ description_zh: "启用的探测器。默认启用所有探测器。"
3233
+ }),
3234
+ timeout: zod.z.string().optional().meta({
3235
+ description: "Timeout for sniffing.",
3236
+ description_zh: "探测超时时间。"
3237
+ })
3238
+ }).meta({
3239
+ id: "RuleActionSniff",
3240
+ title: "Rule Action Sniff",
3241
+ title_zh: "规则动作嗅探"
3242
+ });
3243
+ const RuleActionResolve = zod.z.object({
3244
+ action: zod.z.literal("resolve").meta({
3245
+ description: "Resolve request destination from domain to IP addresses.",
3246
+ description_zh: "将请求的目标从域名解析为 IP 地址。"
3247
+ }),
3248
+ server: zod.z.string().optional().meta({
3249
+ description: "Specifies DNS server tag to use instead of selecting through DNS routing.",
3250
+ description_zh: "指定要使用的 DNS 服务器的标签,而不是通过 DNS 路由进行选择。"
3251
+ }),
3252
+ strategy: zod.z.enum([
3253
+ "prefer_ipv4",
3254
+ "prefer_ipv6",
3255
+ "ipv4_only",
3256
+ "ipv6_only"
3257
+ ]).optional().meta({
3258
+ description: "DNS resolution strategy.",
3259
+ description_zh: "DNS 解析策略。"
3260
+ }),
3261
+ disable_cache: zod.z.boolean().optional().meta({
3262
+ description: "Disable cache and save cache in this query.",
3263
+ description_zh: "在此查询中禁用缓存。"
3264
+ }),
3265
+ rewrite_ttl: zod.z.number().int().optional().nullable().meta({
3266
+ description: "Rewrite TTL in DNS responses.",
3267
+ description_zh: "重写 DNS 回应中的 TTL。"
3268
+ }),
3269
+ client_subnet: zod.z.string().optional().nullable().meta({
3270
+ description: "Append a `edns0-subnet` OPT extra record with the specified IP prefix to every query by default.",
3271
+ description_zh: "默认情况下,将带有指定 IP 前缀的 `edns0-subnet` OPT 附加记录附加到每个查询。"
3272
+ })
3273
+ }).meta({
3274
+ id: "RuleActionResolve",
3275
+ title: "Rule Action Resolve",
3276
+ title_zh: "规则动作解析"
3277
+ });
3278
+ const RuleActionRouteByDefault = zod.z.object({
3279
+ outbound: zod.z.string().meta({
3280
+ description: "Tag of target outbound.",
3281
+ description_zh: "目标出站的标签。"
3282
+ }),
3283
+ ...RuleActionRouteOptions.shape
3284
+ });
3285
+ const RuleActionRoute = zod.z.object({
3286
+ action: zod.z.literal("route").meta({
3287
+ description: "Action type.",
3288
+ description_zh: "动作类型。"
3289
+ }),
3290
+ ...RuleActionRouteByDefault.shape
3291
+ }).meta({
3292
+ id: "RuleActionRoute",
3293
+ title: "Rule Action Route",
3294
+ title_zh: "规则动作路由"
3295
+ });
3296
+ const RuleActionReject = zod.z.object({
3297
+ action: zod.z.literal("reject").meta({
3298
+ description: "Action type.",
3299
+ description_zh: "动作类型。"
3300
+ }),
3301
+ method: zod.z.enum(["default", "drop"]).optional().meta({
3302
+ description: "`default`: Reply with TCP RST for TCP connections, and ICMP port unreachable for UDP packets. `drop`: Drop packets.",
3303
+ description_zh: "`default`: 对于 TCP 连接回复 RST,对于 UDP 包回复 ICMP 端口不可达。`drop`: 丢弃数据包。"
3304
+ }),
3305
+ no_drop: zod.z.boolean().optional().meta({
3306
+ description: "If not enabled, `method` will be temporarily overwritten to `drop` after 50 triggers in 30s.",
3307
+ description_zh: "如果未启用,则 30 秒内触发 50 次后,`method` 将被暂时覆盖为 `drop`。"
3308
+ })
3309
+ }).meta({
3310
+ id: "RuleActionReject",
3311
+ title: "Rule Action Reject",
3312
+ title_zh: "规则动作拒绝"
3313
+ });
3314
+ const RuleActionHijackDNS = zod.z.object({ action: zod.z.literal("hijack-dns").meta({
3315
+ description: "Action type.",
3316
+ description_zh: "动作类型。"
3317
+ }) }).meta({
3318
+ id: "RuleActionHijackDNS",
3319
+ title: "Rule Action Hijack DNS",
3320
+ title_zh: "规则动作劫持 DNS"
3321
+ });
3322
+ const RuleActionRouteOptionsWithAction = zod.z.object({
3323
+ action: zod.z.literal("route-options").meta({
3324
+ description: "Action type.",
3325
+ description_zh: "动作类型。"
3326
+ }),
3327
+ ...RuleActionRouteOptions.shape
3328
+ }).meta({
3329
+ id: "RuleActionRouteOptionsWithAction",
3330
+ title: "Rule Action Route Options With Action",
3331
+ title_zh: "规则动作路由选项带动作"
3332
+ });
3333
+ const BaseRouteRule = zod.z.object({
3334
+ inbound: listableString.optional().meta({
3335
+ description: "Tags of Inbound.",
3336
+ description_zh: "入站标签。"
3337
+ }),
3338
+ ip_version: zod.z.union([zod.z.literal(4), zod.z.literal(6)]).optional().meta({
3339
+ description: "4 or 6. Not limited if empty.",
3340
+ description_zh: "4 或 6。默认不限制。"
3341
+ }),
3342
+ network: listable(zod.z.enum(["tcp", "udp"])).optional().meta({
3343
+ description: "`tcp` or `udp`.",
3344
+ description_zh: "`tcp` 或 `udp`。"
3345
+ }),
3346
+ auth_user: listableString.optional().meta({
3347
+ description: "Username, see each inbound for details.",
3348
+ description_zh: "认证用户名,参阅入站设置。"
3349
+ }),
3350
+ protocol: listable(zod.z.enum([
3351
+ "http",
3352
+ "tls",
3353
+ "quic",
3354
+ "stun",
3355
+ "dns",
3356
+ "bittorrent",
3357
+ "dtls",
3358
+ "ssh",
3359
+ "rdp",
3360
+ "ntp"
3361
+ ])).optional().meta({
3362
+ description: "Sniffed protocol.",
3363
+ description_zh: "探测到的协议。"
3364
+ }),
3365
+ client: listable(zod.z.enum([
3366
+ "chromium",
3367
+ "safari",
3368
+ "firefox",
3369
+ "quic-go"
3370
+ ])).optional().meta({
3371
+ description: "Sniffed client type.",
3372
+ description_zh: "探测到的客户端类型。"
3373
+ }),
3374
+ domain: listableString.optional().meta({
3375
+ description: "Match full domain.",
3376
+ description_zh: "匹配完整域名。"
3377
+ }),
3378
+ domain_suffix: listableString.optional().meta({
3379
+ description: "Match domain suffix.",
3380
+ description_zh: "匹配域名后缀。"
3381
+ }),
3382
+ domain_keyword: listableString.optional().meta({
3383
+ description: "Match domain using keyword.",
3384
+ description_zh: "匹配域名关键字。"
3385
+ }),
3386
+ domain_regex: listableString.optional().meta({
3387
+ description: "Match domain using regular expression.",
3388
+ description_zh: "匹配域名正则表达式。"
3389
+ }),
3390
+ geosite: listableString.optional().meta({
3391
+ description: "Match geosite.",
3392
+ description_zh: "匹配 Geosite。",
3393
+ deprecated: true
3394
+ }),
3395
+ source_geoip: listableString.optional().meta({
3396
+ description: "Match source geoip.",
3397
+ description_zh: "匹配源 GeoIP。",
3398
+ deprecated: true
3399
+ }),
3400
+ geoip: listableString.optional().meta({
3401
+ description: "Match geoip.",
3402
+ description_zh: "匹配 GeoIP。",
3403
+ deprecated: true
3404
+ }),
3405
+ source_ip_cidr: listableString.optional().meta({
3406
+ description: "Match source IP CIDR.",
3407
+ description_zh: "匹配源 IP CIDR。"
3408
+ }),
3409
+ source_ip_is_private: zod.z.boolean().optional().meta({
3410
+ description: "Match non-public source IP.",
3411
+ description_zh: "匹配非公开源 IP。"
3412
+ }),
3413
+ ip_cidr: listableString.optional().meta({
3414
+ description: "Match IP CIDR.",
3415
+ description_zh: "匹配 IP CIDR。"
3416
+ }),
3417
+ ip_is_private: zod.z.boolean().optional().meta({
3418
+ description: "Match non-public IP.",
3419
+ description_zh: "匹配非公开 IP。"
3420
+ }),
3421
+ source_port: listable(zod.z.number().int().min(0).max(65535)).optional().meta({
3422
+ description: "Match source port.",
3423
+ description_zh: "匹配源端口。"
3424
+ }),
3425
+ source_port_range: listableString.optional().meta({
3426
+ description: "Match source port range.",
3427
+ description_zh: "匹配源端口范围。"
3428
+ }),
3429
+ port: listable(zod.z.number().int().min(0).max(65535)).optional().meta({
3430
+ description: "Match port.",
3431
+ description_zh: "匹配端口。"
3432
+ }),
3433
+ port_range: listableString.optional().meta({
3434
+ description: "Match port range.",
3435
+ description_zh: "匹配端口范围。"
3436
+ }),
3437
+ process_name: listableString.optional().meta({
3438
+ description: "Match process name.",
3439
+ description_zh: "匹配进程名称。"
3440
+ }),
3441
+ process_path: listableString.optional().meta({
3442
+ description: "Match process path.",
3443
+ description_zh: "匹配进程路径。"
3444
+ }),
3445
+ process_path_regex: listableString.optional().meta({
3446
+ description: "Match process path using regular expression.",
3447
+ description_zh: "使用正则表达式匹配进程路径。"
3448
+ }),
3449
+ package_name: listableString.optional().meta({
3450
+ description: "Match android package name.",
3451
+ description_zh: "匹配 Android 应用包名。"
3452
+ }),
3453
+ user: listableString.optional().meta({
3454
+ description: "Match user name.",
3455
+ description_zh: "匹配用户名。"
3456
+ }),
3457
+ user_id: listableInts.optional().meta({
3458
+ description: "Match user id.",
3459
+ description_zh: "匹配用户 ID。"
3460
+ }),
3461
+ clash_mode: zod.z.string().optional().meta({
3462
+ description: "Match Clash mode.",
3463
+ description_zh: "匹配 Clash 模式。"
3464
+ }),
3465
+ network_type: listable(zod.z.enum([
3466
+ "wifi",
3467
+ "cellular",
3468
+ "ethernet",
3469
+ "other"
3470
+ ])).optional().meta({
3471
+ description: "Match network type.",
3472
+ description_zh: "匹配网络类型。"
3473
+ }),
3474
+ network_is_expensive: zod.z.boolean().optional().meta({
3475
+ description: "Match if network is considered Metered.",
3476
+ description_zh: "匹配如果网络被视为计费。"
3477
+ }),
3478
+ network_is_constrained: zod.z.boolean().optional().meta({
3479
+ description: "Match if network is in Low Data Mode.",
3480
+ description_zh: "匹配如果网络在低数据模式下。"
3481
+ }),
3482
+ wifi_ssid: listableString.optional().meta({
3483
+ description: "Match WiFi SSID.",
3484
+ description_zh: "匹配 WiFi SSID。"
3485
+ }),
3486
+ wifi_bssid: listableString.optional().meta({
3487
+ description: "Match WiFi BSSID.",
3488
+ description_zh: "匹配 WiFi BSSID。"
3489
+ }),
3490
+ rule_set: listableString.optional().meta({
3491
+ description: "Match rule-set.",
3492
+ description_zh: "匹配规则集。"
3493
+ }),
3494
+ rule_set_ip_cidr_match_source: zod.z.boolean().optional().meta({
3495
+ description: "Make `ip_cidr` in rule-sets match the source IP.",
3496
+ description_zh: "使规则集中的 `ip_cidr` 规则匹配源 IP。"
3497
+ }),
3498
+ rule_set_ipcidr_match_source: zod.z.boolean().optional().meta({
3499
+ description: "Deprecated in sing-box 1.10.0. Renamed to `rule_set_ip_cidr_match_source`.",
3500
+ description_zh: "已在 sing-box 1.10.0 废弃。已重命名为 `rule_set_ip_cidr_match_source`。",
3501
+ deprecated: true
3502
+ }),
3503
+ invert: zod.z.boolean().optional().meta({
3504
+ description: "Invert match result.",
3505
+ description_zh: "反选匹配结果。"
3506
+ })
3507
+ });
3508
+ const DefaultRouteRule = zod.z.union([
3509
+ BaseRouteRule.extend(RuleActionRouteByDefault.shape),
3510
+ BaseRouteRule.extend(RuleActionRoute.shape),
3511
+ BaseRouteRule.extend(RuleActionReject.shape),
3512
+ BaseRouteRule.extend(RuleActionHijackDNS.shape),
3513
+ BaseRouteRule.extend(RuleActionRouteOptionsWithAction.shape),
3514
+ BaseRouteRule.extend(RuleActionSniff.shape),
3515
+ BaseRouteRule.extend(RuleActionResolve.shape)
3516
+ ]);
3517
+ const LogicalRouteRule = zod.z.object({
3518
+ type: zod.z.literal("logical").meta({
3519
+ description: "Rule type.",
3520
+ description_zh: "规则类型。"
3521
+ }),
3522
+ mode: zod.z.enum(["and", "or"]).meta({
3523
+ description: "`and` or `or`.",
3524
+ description_zh: "`and` 或 `or`。"
3525
+ }),
3526
+ get rules() {
3527
+ return zod.z.array(RouteRule).optional().meta({
3528
+ description: "Included rules.",
3529
+ description_zh: "包括的规则。"
3530
+ });
3531
+ },
3532
+ invert: zod.z.boolean().optional().meta({
3533
+ description: "Invert match result.",
3534
+ description_zh: "反选匹配结果。"
3535
+ })
3536
+ }).meta({
3537
+ id: "LogicalRouteRule",
3538
+ title: "Logical Route Rule",
3539
+ title_zh: "逻辑路由规则"
3540
+ });
3541
+ const RouteRule = zod.z.union([DefaultRouteRule, LogicalRouteRule]).meta({
3542
+ id: "RouteRule",
3543
+ title: "Route Rule",
3544
+ title_zh: "路由规则"
3545
+ });
3546
+
3547
+ //#endregion
3548
+ //#region src/schema/rules/rule-set.ts
3549
+ const DNSQueryType = zod.z.union([zod.z.string(), zod.z.number().int()]).meta({
3550
+ description: "DNS query type. Values can be integers or type name strings.",
3551
+ description_zh: "DNS 查询类型。值可以为整数或者类型名称字符串。"
3552
+ });
3553
+ const DefaultHeadlessRule = zod.z.object({
3554
+ query_type: listable(DNSQueryType).optional().meta({
3555
+ description: "DNS query type.",
3556
+ description_zh: "DNS 查询类型。"
3557
+ }),
3558
+ network: listable(Network).optional().meta({
3559
+ description: "`tcp` or `udp`.",
3560
+ description_zh: "`tcp` 或 `udp`。"
3561
+ }),
3562
+ domain: listableString.optional().meta({
3563
+ description: "Match full domain.",
3564
+ description_zh: "匹配完整域名。"
3565
+ }),
3566
+ domain_suffix: listableString.optional().meta({
3567
+ description: "Match domain suffix.",
3568
+ description_zh: "匹配域名后缀。"
3569
+ }),
3570
+ domain_keyword: listableString.optional().meta({
3571
+ description: "Match domain using keyword.",
3572
+ description_zh: "匹配域名关键字。"
3573
+ }),
3574
+ domain_regex: listableString.optional().meta({
3575
+ description: "Match domain using regular expression.",
3576
+ description_zh: "匹配域名正则表达式。"
3577
+ }),
3578
+ source_ip_cidr: listableString.optional().meta({
3579
+ description: "Match source IP CIDR.",
3580
+ description_zh: "匹配源 IP CIDR。"
3581
+ }),
3582
+ ip_cidr: listableString.optional().meta({
3583
+ description: "Match IP CIDR.",
3584
+ description_zh: "匹配 IP CIDR。"
3585
+ }),
3586
+ source_port: listableInts.optional().meta({
3587
+ description: "Match source port.",
3588
+ description_zh: "匹配源端口。"
3589
+ }),
3590
+ source_port_range: listableString.optional().meta({
3591
+ description: "Match source port range.",
3592
+ description_zh: "匹配源端口范围。"
3593
+ }),
3594
+ port: listableInts.optional().meta({
3595
+ description: "Match port.",
3596
+ description_zh: "匹配端口。"
3597
+ }),
3598
+ port_range: listableString.optional().meta({
3599
+ description: "Match port range.",
3600
+ description_zh: "匹配端口范围。"
3601
+ }),
3602
+ process_name: listableString.optional().meta({
3603
+ description: "Match process name.",
3604
+ description_zh: "匹配进程名称。"
3605
+ }),
3606
+ process_path: listableString.optional().meta({
3607
+ description: "Match process path.",
3608
+ description_zh: "匹配进程路径。"
3609
+ }),
3610
+ process_path_regex: listableString.optional().meta({
3611
+ description: "Match process path using regular expression.",
3612
+ description_zh: "使用正则表达式匹配进程路径。"
3613
+ }),
3614
+ package_name: listableString.optional().meta({
3615
+ description: "Match android package name.",
3616
+ description_zh: "匹配 Android 应用包名。"
3617
+ }),
3618
+ network_type: listable(NetworkType).optional().meta({
3619
+ description: "Match network type.",
3620
+ description_zh: "匹配网络类型。"
3621
+ }),
3622
+ network_is_expensive: zod.z.boolean().optional().meta({
3623
+ description: "Match if network is considered Metered.",
3624
+ description_zh: "匹配如果网络被视为计费。"
3625
+ }),
3626
+ network_is_constrained: zod.z.boolean().optional().meta({
3627
+ description: "Match if network is in Low Data Mode.",
3628
+ description_zh: "匹配如果网络在低数据模式下。"
3629
+ }),
3630
+ wifi_ssid: listableString.optional().meta({
3631
+ description: "Match WiFi SSID.",
3632
+ description_zh: "匹配 WiFi SSID。"
3633
+ }),
3634
+ wifi_bssid: listableString.optional().meta({
3635
+ description: "Match WiFi BSSID.",
3636
+ description_zh: "匹配 WiFi BSSID。"
3637
+ }),
3638
+ invert: zod.z.boolean().optional().meta({
3639
+ description: "Invert match result.",
3640
+ description_zh: "反选匹配结果。"
3641
+ })
3642
+ });
3643
+ const LogicalHeadlessRule = zod.z.object({
3644
+ type: zod.z.literal("logical").meta({
3645
+ description: "Rule type.",
3646
+ description_zh: "规则类型。"
3647
+ }),
3648
+ mode: zod.z.enum(["and", "or"]).meta({
3649
+ description: "`and` or `or`.",
3650
+ description_zh: "`and` 或 `or`。"
3651
+ }),
3652
+ get rules() {
3653
+ return zod.z.array(HeadlessRule).optional().meta({
3654
+ description: "Included rules.",
3655
+ description_zh: "包括的规则。"
3656
+ });
3657
+ },
3658
+ invert: zod.z.boolean().optional().meta({
3659
+ description: "Invert match result.",
3660
+ description_zh: "反选匹配结果。"
3661
+ })
3662
+ }).meta({
3663
+ id: "LogicalHeadlessRule",
3664
+ title: "Logical Headless Rule",
3665
+ title_zh: "逻辑无头规则"
3666
+ });
3667
+ const HeadlessRule = zod.z.union([DefaultHeadlessRule, LogicalHeadlessRule]).meta({
3668
+ id: "HeadlessRule",
3669
+ title: "Headless Rule",
3670
+ title_zh: "无头规则"
3671
+ });
3672
+ const InlineRuleSetOptions = zod.z.object({
3673
+ type: zod.z.literal("inline").meta({
3674
+ description: "Rule set type.",
3675
+ description_zh: "规则集类型。"
3676
+ }),
3677
+ tag: zod.z.string().meta({
3678
+ description: "Tag of rule-set.",
3679
+ description_zh: "规则集的标签。"
3680
+ }),
3681
+ rules: zod.z.array(HeadlessRule).meta({
3682
+ description: "List of Headless Rules.",
3683
+ description_zh: "无头规则列表。"
3684
+ })
3685
+ }).meta({
3686
+ id: "InlineRuleSetOptions",
3687
+ title: "Inline Rule Set Options",
3688
+ title_zh: "内联规则集选项"
3689
+ });
3690
+ const LocalRuleSetOptions = zod.z.object({
3691
+ type: zod.z.literal("local").meta({
3692
+ description: "Rule set type.",
3693
+ description_zh: "规则集类型。"
3694
+ }),
3695
+ tag: zod.z.string().meta({
3696
+ description: "Tag of rule-set.",
3697
+ description_zh: "规则集的标签。"
3698
+ }),
3699
+ format: zod.z.enum(["source", "binary"]).optional().meta({
3700
+ description: "Format of rule-set file, `source` or `binary`.",
3701
+ description_zh: "规则集文件格式,`source` 或 `binary`。"
3702
+ }),
3703
+ path: zod.z.string().meta({
3704
+ description: "File path of rule-set.",
3705
+ description_zh: "规则集的文件路径。"
3706
+ })
3707
+ }).meta({
3708
+ id: "LocalRuleSetOptions",
3709
+ title: "Local Rule Set Options",
3710
+ title_zh: "本地规则集选项"
3711
+ });
3712
+ const RemoteRuleSetOptions = zod.z.object({
3713
+ type: zod.z.literal("remote").meta({
3714
+ description: "Rule set type.",
3715
+ description_zh: "规则集类型。"
3716
+ }),
3717
+ tag: zod.z.string().meta({
3718
+ description: "Tag of rule-set.",
3719
+ description_zh: "规则集的标签。"
3720
+ }),
3721
+ format: zod.z.enum(["source", "binary"]).optional().meta({
3722
+ description: "Format of rule-set file, `source` or `binary`.",
3723
+ description_zh: "规则集文件格式,`source` 或 `binary`。"
3724
+ }),
3725
+ url: zod.z.string().meta({
3726
+ description: "Download URL of rule-set.",
3727
+ description_zh: "规则集的下载 URL。"
3728
+ }),
3729
+ download_detour: zod.z.string().optional().meta({
3730
+ description: "Tag of the outbound to download rule-set.",
3731
+ description_zh: "用于下载规则集的出站的标签。"
3732
+ }),
3733
+ update_interval: zod.z.string().optional().meta({
3734
+ description: "Update interval of rule-set.",
3735
+ description_zh: "规则集的更新间隔。"
3736
+ })
3737
+ }).meta({
3738
+ id: "RemoteRuleSetOptions",
3739
+ title: "Remote Rule Set Options",
3740
+ title_zh: "远程规则集选项"
3741
+ });
3742
+ const RuleSet = zod.z.discriminatedUnion("type", [
3743
+ InlineRuleSetOptions,
3744
+ LocalRuleSetOptions,
3745
+ RemoteRuleSetOptions
3746
+ ]).meta({
3747
+ id: "RuleSet",
3748
+ title: "Rule Set",
3749
+ title_zh: "规则集"
3750
+ });
3751
+
3752
+ //#endregion
3753
+ //#region src/schema/route.ts
3754
+ const GeoIPOptions = zod.z.object({
3755
+ path: zod.z.string().optional().meta({
3756
+ description: "The path to the sing-geoip database.",
3757
+ description_zh: "指定 GeoIP 资源的路径。"
3758
+ }),
3759
+ download_url: zod.z.string().optional().meta({
3760
+ description: "The download URL of the sing-geoip database.",
3761
+ description_zh: "指定 GeoIP 资源的下载链接。"
3762
+ }),
3763
+ download_detour: zod.z.string().optional().meta({
3764
+ description: "The tag of the outbound to download the database.",
3765
+ description_zh: "用于下载 GeoIP 资源的出站的标签。"
3766
+ })
3767
+ }).meta({
3768
+ id: "GeoIPOptions",
3769
+ title: "GeoIP",
3770
+ deprecated: true
3771
+ });
3772
+ const GeositeOptions = zod.z.object({
3773
+ path: zod.z.string().optional().meta({
3774
+ description: "The path to the sing-geosite database.",
3775
+ description_zh: "指定 GeoSite 资源的路径。"
3776
+ }),
3777
+ download_url: zod.z.string().optional().meta({
3778
+ description: "The download URL of the sing-geoip database.",
3779
+ description_zh: "指定 GeoSite 资源的下载链接。"
3780
+ }),
3781
+ download_detour: zod.z.string().optional().meta({
3782
+ description: "The tag of the outbound to download the database.",
3783
+ description_zh: "用于下载 GeoSite 资源的出站的标签。"
3784
+ })
3785
+ }).meta({
3786
+ id: "GeositeOptions",
3787
+ title: "Geosite",
3788
+ deprecated: true
3789
+ });
3790
+ const RouteOptions = zod.z.object({
3791
+ rules: listable(RouteRule).optional().meta({
3792
+ description: "List of Route Rule",
3793
+ description_zh: "一组路由规则"
3794
+ }),
3795
+ rule_set: listable(RuleSet).optional().meta({
3796
+ description: "List of rule-set",
3797
+ description_zh: "一组规则集"
3798
+ }),
3799
+ final: zod.z.string().optional().meta({
3800
+ description: "Default outbound tag. the first outbound will be used if empty.",
3801
+ description_zh: "默认出站标签。如果为空,将使用第一个可用于对应协议的出站。"
3802
+ }),
3803
+ find_process: zod.z.boolean().optional(),
3804
+ auto_detect_interface: zod.z.boolean().optional().meta({
3805
+ description: "Bind outbound connections to the default NIC by default to prevent routing loops under tun.",
3806
+ description_zh: "默认将出站连接绑定到默认网卡,以防止在 tun 下出现路由环路。"
3807
+ }),
3808
+ override_android_vpn: zod.z.boolean().optional().meta({
3809
+ description: "Accept Android VPN as upstream NIC when `auto_detect_interface` enabled.",
3810
+ description_zh: "启用 `auto_detect_interface` 时接受 Android VPN 作为上游网卡。"
3811
+ }),
3812
+ default_interface: zod.z.string().optional().meta({
3813
+ description: "Bind outbound connections to the specified NIC by default to prevent routing loops under tun.",
3814
+ description_zh: "默认将出站连接绑定到指定网卡,以防止在 tun 下出现路由环路。"
3815
+ }),
3816
+ default_mark: FwMark.optional().meta({
3817
+ description: "Set routing mark by default.",
3818
+ description_zh: "默认为出站连接设置路由标记。"
3819
+ }),
3820
+ default_domain_resolver: zod.z.union([zod.z.string(), DomainResolverOptions]).optional().meta({
3821
+ description: "Set domain resolver to use for resolving domain names.",
3822
+ description_zh: "用于设置解析域名的域名解析器。"
3823
+ }),
3824
+ default_network_strategy: zod.z.union([zod.z.string(), NetworkStrategy]).optional().meta({
3825
+ description: "Strategy for selecting network interfaces.",
3826
+ description_zh: "用于选择网络接口的策略。"
3827
+ }),
3828
+ default_network_type: listable(NetworkType).optional().meta({
3829
+ description: "Network types to use.",
3830
+ description_zh: "要使用的网络类型。"
3831
+ }),
3832
+ default_fallback_network_type: listable(NetworkType).optional().meta({
3833
+ description: "Fallback network types.",
3834
+ description_zh: "备用网络类型。"
3835
+ }),
3836
+ default_fallback_delay: zod.z.string().optional().meta({
3837
+ description: "The length of time to wait before spawning a RFC 6555 Fast Fallback connection.",
3838
+ description_zh: "在生成 RFC 6555 快速回退连接之前等待的时间长度。"
3839
+ }),
3840
+ geoip: GeoIPOptions.optional(),
3841
+ geosite: GeositeOptions.optional()
3842
+ }).meta({
3843
+ id: "RouteOptions",
3844
+ title: "Route",
3845
+ title_zh: "路由"
3846
+ });
3847
+
3848
+ //#endregion
3849
+ //#region src/schema/services/derp.ts
3850
+ const DERPVerifyClientURLOptions = zod.z.object({
3851
+ url: zod.z.string().optional().meta({
3852
+ description: "URL to verify clients.",
3853
+ description_zh: "用于验证客户端的 URL。"
3854
+ }),
3855
+ ...DialerOptions.shape
3856
+ }).meta({
3857
+ id: "DERPVerifyClientURLOptions",
3858
+ title: "DERP Verify Client URL Options",
3859
+ title_zh: "DERP 验证客户端 URL 选项"
3860
+ });
3861
+ const DERPMeshOptions = zod.z.object({
3862
+ host: zod.z.string().optional().meta({
3863
+ description: "Custom DERP hostname.",
3864
+ description_zh: "自定义 DERP 主机名。"
3865
+ }),
3866
+ tls: OutboundTLSOptions.optional().meta({
3867
+ description: "TLS configuration.",
3868
+ description_zh: "TLS 配置。"
3869
+ }),
3870
+ ...ServerOptions.shape,
3871
+ ...DialerOptions.shape
3872
+ }).meta({
3873
+ id: "DERPMeshOptions",
3874
+ title: "DERP Mesh Options",
3875
+ title_zh: "DERP 网格选项"
3876
+ });
3877
+ const DERPSTUNListenOptions = zod.z.object({
3878
+ enabled: zod.z.boolean().meta({
3879
+ description: "Enable STUN server.",
3880
+ description_zh: "启用 STUN 服务器。"
3881
+ }),
3882
+ ...ListenOptions.shape
3883
+ }).meta({
3884
+ id: "DERPSTUNListenOptions",
3885
+ title: "DERP STUN Listen Options",
3886
+ title_zh: "DERP STUN 监听选项"
3887
+ });
3888
+ /**
3889
+ * DERP service is a Tailscale DERP server.
3890
+ */
3891
+ const DERPServiceOptions = zod.z.object({
3892
+ type: zod.z.literal("derp"),
3893
+ tag: zod.z.string().optional(),
3894
+ tls: InboundTLSOptions.optional().meta({
3895
+ description: "TLS configuration.",
3896
+ description_zh: "TLS 配置。"
3897
+ }),
3898
+ config_path: zod.z.string().meta({
3899
+ description: "Derper configuration file path.",
3900
+ description_zh: "Derper 配置文件路径。"
3901
+ }),
3902
+ verify_client_endpoint: listableString.optional().meta({
3903
+ description: "Tailscale endpoints tags to verify clients.",
3904
+ description_zh: "Tailscale 端点标签以验证客户端。"
3905
+ }),
3906
+ verify_client_url: listable(zod.z.union([zod.z.string(), DERPVerifyClientURLOptions])).optional().meta({
3907
+ description: "URL to verify clients.",
3908
+ description_zh: "用于验证客户端的 URL。"
3909
+ }),
3910
+ home: zod.z.string().optional().meta({
3911
+ description: "What to serve at the root path. It may be left empty (the default, for a default homepage), `blank` for a blank page, or a URL to redirect to.",
3912
+ description_zh: "根路径下提供什么。可以留空(默认,用于默认主页),`blank` 用于空白页,或重定向到的 URL。"
3913
+ }),
3914
+ mesh_with: listable(DERPMeshOptions).optional().meta({
3915
+ description: "Mesh with other DERP servers.",
3916
+ description_zh: "与其他 DERP 服务器网格。"
3917
+ }),
3918
+ mesh_psk: zod.z.string().optional().meta({
3919
+ description: "Pre-shared key for DERP mesh.",
3920
+ description_zh: "DERP 网格的预共享密钥。"
3921
+ }),
3922
+ mesh_psk_file: zod.z.string().optional().meta({
3923
+ description: "Pre-shared key file for DERP mesh.",
3924
+ description_zh: "DERP 网格的预共享密钥文件。"
3925
+ }),
3926
+ stun: zod.z.union([zod.z.number(), DERPSTUNListenOptions]).optional().meta({
3927
+ description: "STUN server listen options.",
3928
+ description_zh: "STUN 服务器监听选项。"
3929
+ }),
3930
+ ...ListenOptions.shape
3931
+ }).meta({
3932
+ id: "DERPServiceOptions",
3933
+ title: "DERP",
3934
+ title_zh: "DERP",
3935
+ description: "DERP service is a Tailscale DERP server.",
3936
+ description_zh: "DERP 服务是 Tailscale DERP 服务器。"
3937
+ });
3938
+
3939
+ //#endregion
3940
+ //#region src/schema/services/resolved.ts
3941
+ /**
3942
+ * Resolved service is a fake systemd-resolved DBUS service.
3943
+ */
3944
+ const ResolvedServiceOptions = zod.z.object({
3945
+ type: zod.z.literal("resolved"),
3946
+ tag: zod.z.string().optional(),
3947
+ ...ListenOptions.shape
3948
+ }).meta({
3949
+ id: "ResolvedServiceOptions",
3950
+ title: "Resolved",
3951
+ title_zh: "Resolved",
3952
+ description: "Resolved service is a fake systemd-resolved DBUS service to receive DNS settings from other programs (e.g. NetworkManager) and provide DNS resolution.",
3953
+ description_zh: "Resolved 服务是一个伪造的 systemd-resolved DBUS 服务,用于从其他程序(例如 NetworkManager)接收 DNS 设置并提供 DNS 解析。"
3954
+ });
3955
+
3956
+ //#endregion
3957
+ //#region src/schema/services/ssm-api.ts
3958
+ /**
3959
+ * SSM API service is a RESTful API server for managing Shadowsocks servers.
3960
+ */
3961
+ const SSMAPIServiceOptions = zod.z.object({
3962
+ type: zod.z.literal("ssm-api"),
3963
+ servers: zod.z.record(zod.z.string(), zod.z.string()).meta({
3964
+ description: "A mapping Object from HTTP endpoints to Shadowsocks Inbound tags.",
3965
+ description_zh: "从 HTTP 端点到 Shadowsocks 入站标签的映射对象。"
3966
+ }),
3967
+ cache_path: zod.z.string().optional().meta({
3968
+ description: "If set, when the server is about to stop, traffic and user state will be saved to the specified JSON file to be restored on the next startup.",
3969
+ description_zh: "如果设置,当服务器即将停止时,流量和用户状态将保存到指定的 JSON 文件中,以便在下次启动时恢复。"
3970
+ }),
3971
+ tls: InboundTLSOptions.optional().meta({
3972
+ description: "TLS configuration.",
3973
+ description_zh: "TLS 配置。"
3974
+ }),
3975
+ ...ListenOptions.shape
3976
+ }).meta({
3977
+ id: "SSMAPIServiceOptions",
3978
+ title: "SSM API",
3979
+ title_zh: "SSM API",
3980
+ description: "SSM API service is a RESTful API server for managing Shadowsocks servers.",
3981
+ description_zh: "SSM API 服务是用于管理 Shadowsocks 服务器的 RESTful API 服务器。"
3982
+ });
3983
+
3984
+ //#endregion
3985
+ //#region src/schema/service.ts
3986
+ const Service = zod.z.discriminatedUnion("type", [
3987
+ DERPServiceOptions,
3988
+ ResolvedServiceOptions,
3989
+ SSMAPIServiceOptions
3990
+ ]).meta({
3991
+ id: "Service",
3992
+ title: "Service",
3993
+ title_zh: "服务"
3994
+ });
3995
+
3996
+ //#endregion
3997
+ //#region src/schema/configuration.ts
3998
+ const Configuration = zod.z.object({
3999
+ $schema: zod.z.string().optional(),
4000
+ log: LogOptions.optional(),
4001
+ dns: DNSOptions.optional(),
4002
+ ntp: NTPOptions.optional(),
4003
+ certificate: CertificateOptions.optional(),
4004
+ endpoints: zod.z.array(Endpoint).optional(),
4005
+ inbounds: zod.z.array(Inbound).optional(),
4006
+ outbounds: zod.z.array(Outbound).optional(),
4007
+ route: RouteOptions.optional(),
4008
+ services: zod.z.array(Service).optional(),
4009
+ experimental: ExperimentalOptions.optional()
4010
+ }).meta({
4011
+ id: "Configuration",
4012
+ title: "Sing-box v1.12.2 Configuration",
4013
+ title_zh: "Sing-box v1.12.2 配置文件",
4014
+ description: "Sing-box v1.12.2 Configuration file schema.",
4015
+ description_zh: "Sing-box v1.12.2 配置文件定义。",
4016
+ version: "1.12.2"
4017
+ });
4018
+
4019
+ //#endregion
4020
+ exports.CertificateOptions = CertificateOptions;
4021
+ exports.Configuration = Configuration;
4022
+ exports.DHCPDNSServerOptions = DHCPDNSServerOptions;
4023
+ exports.DNSClientOptions = DNSClientOptions;
4024
+ exports.DNSOptions = DNSOptions;
4025
+ exports.DNSRule = DNSRule;
4026
+ exports.DNSServer = DNSServer;
4027
+ exports.DialerOptions = DialerOptions;
4028
+ exports.DirectInboundOptions = DirectInboundOptions;
4029
+ exports.DirectOutboundOptions = DirectOutboundOptions;
4030
+ exports.DomainResolverOptions = DomainResolverOptions;
4031
+ exports.DomainStrategy = DomainStrategy;
4032
+ exports.Endpoint = Endpoint;
4033
+ exports.ExperimentalOptions = ExperimentalOptions;
4034
+ exports.FakeIPDNSServerOptions = FakeIPDNSServerOptions;
4035
+ exports.FwMark = FwMark;
4036
+ exports.GeoIPOptions = GeoIPOptions;
4037
+ exports.GeositeOptions = GeositeOptions;
4038
+ exports.HTTP3DNSServerOptions = HTTP3DNSServerOptions;
4039
+ exports.HTTPInboundOptions = HTTPInboundOptions;
4040
+ exports.HTTPOutboundOptions = HTTPOutboundOptions;
4041
+ exports.HTTPProxyOptions = HTTPProxyOptions;
4042
+ exports.HTTPSDNSServerOptions = HTTPSDNSServerOptions;
4043
+ exports.HeadlessRule = HeadlessRule;
4044
+ exports.HostsDNSServerOptions = HostsDNSServerOptions;
4045
+ exports.HttpHeader = HttpHeader;
4046
+ exports.Hysteria2InboundOptions = Hysteria2InboundOptions;
4047
+ exports.Hysteria2Masquerade = Hysteria2Masquerade;
4048
+ exports.Hysteria2Obfs = Hysteria2Obfs;
4049
+ exports.Hysteria2OutboundOptions = Hysteria2OutboundOptions;
4050
+ exports.Hysteria2User = Hysteria2User;
4051
+ exports.HysteriaInboundOptions = HysteriaInboundOptions;
4052
+ exports.HysteriaOutboundOptions = HysteriaOutboundOptions;
4053
+ exports.HysteriaUser = HysteriaUser;
4054
+ exports.Inbound = Inbound;
4055
+ exports.InboundMultiplexOptions = InboundMultiplexOptions;
4056
+ exports.InboundOptions = InboundOptions;
4057
+ exports.InboundTLSOptions = InboundTLSOptions;
4058
+ exports.IpVersion = IpVersion;
4059
+ exports.LegacyDNSFakeIPOptions = LegacyDNSFakeIPOptions;
4060
+ exports.LegacyWireGuardOutboundOptions = LegacyWireGuardOutboundOptions;
4061
+ exports.LegacyWireGuardPeer = LegacyWireGuardPeer;
4062
+ exports.ListenOptions = ListenOptions;
4063
+ exports.LocalDNSServerOptions = LocalDNSServerOptions;
4064
+ exports.LogOptions = LogOptions;
4065
+ exports.MixedInboundOptions = MixedInboundOptions;
4066
+ exports.NTPOptions = NTPOptions;
4067
+ exports.NaiveInboundOptions = NaiveInboundOptions;
4068
+ exports.Network = Network;
4069
+ exports.NetworkStrategy = NetworkStrategy;
4070
+ exports.NetworkType = NetworkType;
4071
+ exports.Outbound = Outbound;
4072
+ exports.OutboundMultiplexOptions = OutboundMultiplexOptions;
4073
+ exports.OutboundTLSOptions = OutboundTLSOptions;
4074
+ exports.QUICDNSServerOptions = QUICDNSServerOptions;
4075
+ exports.RedirectInboundOptions = RedirectInboundOptions;
4076
+ exports.ResolvedDNSServerOptions = ResolvedDNSServerOptions;
4077
+ exports.RouteOptions = RouteOptions;
4078
+ exports.RouteRule = RouteRule;
4079
+ exports.RuleSet = RuleSet;
4080
+ exports.SSHOutboundOptions = SSHOutboundOptions;
4081
+ exports.SelectorOutbound = SelectorOutbound;
4082
+ exports.ServerOptions = ServerOptions;
4083
+ exports.Service = Service;
4084
+ exports.ShadowsocksDestination = ShadowsocksDestination;
4085
+ exports.ShadowsocksInboundOptions = ShadowsocksInboundOptions;
4086
+ exports.ShadowsocksOutboundOptions = ShadowsocksOutboundOptions;
4087
+ exports.ShadowsocksROutboundOptions = ShadowsocksROutboundOptions;
4088
+ exports.ShadowsocksUser = ShadowsocksUser;
4089
+ exports.SocksInboundOptions = SocksInboundOptions;
4090
+ exports.SocksOutboundOptions = SocksOutboundOptions;
4091
+ exports.TCPDNSServerOptions = TCPDNSServerOptions;
4092
+ exports.TLSDNSServerOptions = TLSDNSServerOptions;
4093
+ exports.TProxyInboundOptions = TProxyInboundOptions;
4094
+ exports.TUICInboundOptions = TUICInboundOptions;
4095
+ exports.TUICOutboundOptions = TUICOutboundOptions;
4096
+ exports.TUICUser = TUICUser;
4097
+ exports.Tag = Tag;
4098
+ exports.TailscaleDNSServerOptions = TailscaleDNSServerOptions;
4099
+ exports.TailscaleEndpointOptions = TailscaleEndpointOptions;
4100
+ exports.TorOutboundOptions = TorOutboundOptions;
4101
+ exports.TrojanInboundOptions = TrojanInboundOptions;
4102
+ exports.TrojanOutboundOptions = TrojanOutboundOptions;
4103
+ exports.TrojanUser = TrojanUser;
4104
+ exports.TunInboundOptions = TunInboundOptions;
4105
+ exports.TunPlatformOptions = TunPlatformOptions;
4106
+ exports.UDPDNSServerOptions = UDPDNSServerOptions;
4107
+ exports.UDPOverTCPOptions = UDPOverTCPOptions;
4108
+ exports.URLTestOutbound = URLTestOutbound;
4109
+ exports.V2RayTransportOptions = V2RayTransportOptions;
4110
+ exports.VLESSInboundOptions = VLESSInboundOptions;
4111
+ exports.VLESSOutboundOptions = VLESSOutboundOptions;
4112
+ exports.VLESSUser = VLESSUser;
4113
+ exports.VMessInboundOptions = VMessInboundOptions;
4114
+ exports.VMessOutboundOptions = VMessOutboundOptions;
4115
+ exports.VMessUser = VMessUser;
4116
+ exports.WireGuardEndpointOptions = WireGuardEndpointOptions;
4117
+ exports.WireGuardPeer = WireGuardPeer;