fix: add missing EnvName, document Strategy invariant, improve rcode display

- Add EnvName to four new deprecation constants so users can suppress
  warnings via ENABLE_DEPRECATED_* environment variables
- Add comment explaining why applyDNSRouteOptions skips Strategy
- Use dns.RcodeToString in DNSResponseRCodeItem.String() for readability
- Remove redundant Fqdn(FqdnToDomain(domain)) round-trip
This commit is contained in:
世界
2026-03-31 15:47:29 +08:00
parent 1897e512ac
commit e6377f7ec9
3 changed files with 10 additions and 2 deletions

View File

@@ -410,6 +410,9 @@ func (r *Router) matchDNS(ctx context.Context, rules []adapter.DNSRule, allowFak
}
func (r *Router) applyDNSRouteOptions(options *adapter.DNSQueryOptions, routeOptions R.RuleActionDNSRouteOptions) {
// Strategy is intentionally skipped here. A non-default DNS rule action strategy
// forces legacy mode via resolveLegacyDNSMode, so this path is only reachable
// when strategy remains at its default value.
if routeOptions.DisableCache {
options.DisableCache = true
}
@@ -658,7 +661,7 @@ func (r *Router) lookupWithRulesType(ctx context.Context, rules []adapter.DNSRul
RecursionDesired: true,
},
Question: []mDNS.Question{{
Name: mDNS.Fqdn(FqdnToDomain(domain)),
Name: mDNS.Fqdn(domain),
Qtype: qType,
Qclass: mDNS.ClassINET,
}},

View File

@@ -98,6 +98,7 @@ var OptionIPAcceptAny = Note{
Description: "`ip_accept_any` in DNS rules",
DeprecatedVersion: "1.14.0",
ScheduledVersion: "1.16.0",
EnvName: "DNS_RULE_IP_ACCEPT_ANY",
MigrationLink: "https://sing-box.sagernet.org/configuration/dns/rule/",
}
@@ -106,6 +107,7 @@ var OptionRuleSetIPCIDRAcceptEmpty = Note{
Description: "`rule_set_ip_cidr_accept_empty` in DNS rules",
DeprecatedVersion: "1.14.0",
ScheduledVersion: "1.16.0",
EnvName: "DNS_RULE_RULE_SET_IP_CIDR_ACCEPT_EMPTY",
MigrationLink: "https://sing-box.sagernet.org/configuration/dns/rule/",
}
@@ -114,6 +116,7 @@ var OptionLegacyDNSAddressFilter = Note{
Description: "legacy address filter DNS rule items",
DeprecatedVersion: "1.14.0",
ScheduledVersion: "1.16.0",
EnvName: "LEGACY_DNS_ADDRESS_FILTER",
MigrationLink: "https://sing-box.sagernet.org/configuration/dns/rule/",
}
@@ -122,6 +125,7 @@ var OptionLegacyDNSRuleStrategy = Note{
Description: "`strategy` in DNS rule actions",
DeprecatedVersion: "1.14.0",
ScheduledVersion: "1.16.0",
EnvName: "LEGACY_DNS_RULE_STRATEGY",
MigrationLink: "https://sing-box.sagernet.org/configuration/dns/rule_action/",
}

View File

@@ -1,6 +1,7 @@
package rule
import (
"github.com/miekg/dns"
"github.com/sagernet/sing-box/adapter"
F "github.com/sagernet/sing/common/format"
)
@@ -20,5 +21,5 @@ func (r *DNSResponseRCodeItem) Match(metadata *adapter.InboundContext) bool {
}
func (r *DNSResponseRCodeItem) String() string {
return F.ToString("response_rcode=", r.rcode)
return F.ToString("response_rcode=", dns.RcodeToString[r.rcode])
}