DNS: Add tag for DnsServerObject (#4515)

Closes https://github.com/XTLS/Xray-core/issues/4505
This commit is contained in:
风扇滑翔翼 2025-03-21 08:18:59 +08:00 committed by RPRX
parent 6a211a0bb9
commit 6f8e253dec
4 changed files with 81 additions and 57 deletions

View file

@ -20,6 +20,7 @@ type NameServerConfig struct {
ExpectIPs StringList `json:"expectIps"`
QueryStrategy string `json:"queryStrategy"`
AllowUnexpectedIPs bool `json:"allowUnexpectedIps"`
Tag string `json:"tag"`
}
func (c *NameServerConfig) UnmarshalJSON(data []byte) error {
@ -38,6 +39,7 @@ func (c *NameServerConfig) UnmarshalJSON(data []byte) error {
ExpectIPs StringList `json:"expectIps"`
QueryStrategy string `json:"queryStrategy"`
AllowUnexpectedIPs bool `json:"allowUnexpectedIps"`
Tag string `json:"tag"`
}
if err := json.Unmarshal(data, &advanced); err == nil {
c.Address = advanced.Address
@ -48,6 +50,7 @@ func (c *NameServerConfig) UnmarshalJSON(data []byte) error {
c.ExpectIPs = advanced.ExpectIPs
c.QueryStrategy = advanced.QueryStrategy
c.AllowUnexpectedIPs = advanced.AllowUnexpectedIPs
c.Tag = advanced.Tag
return nil
}
@ -121,6 +124,7 @@ func (c *NameServerConfig) Build() (*dns.NameServer, error) {
OriginalRules: originalRules,
QueryStrategy: resolveQueryStrategy(c.QueryStrategy),
AllowUnexpectedIPs: c.AllowUnexpectedIPs,
Tag: c.Tag,
}, nil
}