mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-05 12:44:22 +00:00
Rename the DNS rule wire key qtype to qType (reading the legacy qtype on parse for back-compat), add the new rCode response-code field for the return action (omitted when zero), and rename the reject action to return. Align the DNS rule action set across the form dropdown, schema, and adapter to the core's valid values (direct/drop/return/hijack), dropping the never-valid rejectIPv4/rejectIPv6 entries.
28 lines
1.2 KiB
TypeScript
28 lines
1.2 KiB
TypeScript
import { z } from 'zod';
|
|
|
|
import { PortSchema } from '@/schemas/primitives';
|
|
|
|
export const DNSRuleActionSchema = z.enum(['direct', 'drop', 'return', 'hijack']);
|
|
|
|
// On the wire `qType` is either a number (DNS type code) or a string like
|
|
// "A"/"AAAA"/"TXT"; the panel normalizes numeric strings to numbers in
|
|
// toJson. `domain` is a string[] (split from a comma-joined input).
|
|
export const DNSRuleSchema = z.object({
|
|
action: DNSRuleActionSchema.default('direct'),
|
|
qType: z.union([z.string(), z.number().int()]).optional(),
|
|
domain: z.array(z.string()).optional(),
|
|
rCode: z.number().int().min(0).max(65535).optional(),
|
|
});
|
|
export type DNSRule = z.infer<typeof DNSRuleSchema>;
|
|
|
|
// DNS outbound rewrites DNS queries onto a different transport. All five
|
|
// fields are emitted conditionally — empty/zero values are omitted from the
|
|
// wire payload entirely (handled at the caller, not here).
|
|
export const DNSOutboundSettingsSchema = z.object({
|
|
rewriteNetwork: z.string().optional(),
|
|
rewriteAddress: z.string().optional(),
|
|
rewritePort: PortSchema.optional(),
|
|
userLevel: z.number().int().min(0).optional(),
|
|
rules: z.array(DNSRuleSchema).optional(),
|
|
});
|
|
export type DNSOutboundSettings = z.infer<typeof DNSOutboundSettingsSchema>;
|