feat(outbound): sync DNS outbound config with Xray core changes

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.
This commit is contained in:
MHSanaei
2026-06-01 10:24:35 +02:00
parent 32f96298f8
commit 2bb9ed1cda
6 changed files with 42 additions and 25 deletions
@@ -2,15 +2,16 @@ import { z } from 'zod';
import { PortSchema } from '@/schemas/primitives';
export const DNSRuleActionSchema = z.enum(['direct', 'reject', 'rejectIPv4', 'rejectIPv6']);
export const DNSRuleActionSchema = z.enum(['direct', 'drop', 'return', 'hijack']);
// On the wire `qtype` is either a number (DNS type code) or a string like
// 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(),
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>;