diff --git a/dns/router.go b/dns/router.go index e7980c1e4..0ad1b0c30 100644 --- a/dns/router.go +++ b/dns/router.go @@ -475,7 +475,7 @@ type exchangeWithRulesResult struct { err error } -const dnsRespondMissingResponseMessage = "respond action requires a saved DNS response from a preceding evaluate action" +const dnsRespondMissingResponseMessage = "respond action requires an evaluated response from a preceding evaluate action" func (r *Router) exchangeWithRules(ctx context.Context, rules []adapter.DNSRule, message *mDNS.Msg, options adapter.DNSQueryOptions, allowFakeIP bool) exchangeWithRulesResult { metadata := adapter.ContextFrom(ctx) @@ -483,11 +483,11 @@ func (r *Router) exchangeWithRules(ctx context.Context, rules []adapter.DNSRule, panic("no context") } effectiveOptions := options - var savedResponse *mDNS.Msg - var savedTransport adapter.DNSTransport + var evaluatedResponse *mDNS.Msg + var evaluatedTransport adapter.DNSTransport for currentRuleIndex, currentRule := range rules { metadata.ResetRuleCache() - metadata.DNSResponse = savedResponse + metadata.DNSResponse = evaluatedResponse metadata.DestinationAddressMatchFromResponse = false if !currentRule.Match(metadata) { continue @@ -502,8 +502,8 @@ func (r *Router) exchangeWithRules(ctx context.Context, rules []adapter.DNSRule, switch status { case dnsRouteStatusMissing: r.logger.ErrorContext(ctx, "transport not found: ", action.Server) - savedResponse = nil - savedTransport = nil + evaluatedResponse = nil + evaluatedTransport = nil continue case dnsRouteStatusSkipped: continue @@ -518,21 +518,21 @@ func (r *Router) exchangeWithRules(ctx context.Context, rules []adapter.DNSRule, return exchangeWithRulesResult{err: err} } r.logger.ErrorContext(ctx, E.Cause(err, "exchange failed for ", FormatQuestion(message.Question[0].String()))) - savedResponse = nil - savedTransport = nil + evaluatedResponse = nil + evaluatedTransport = nil continue } - savedResponse = response - savedTransport = transport + evaluatedResponse = response + evaluatedTransport = transport case *R.RuleActionRespond: - if savedResponse == nil { + if evaluatedResponse == nil { return exchangeWithRulesResult{ err: E.New(dnsRespondMissingResponseMessage), } } return exchangeWithRulesResult{ - response: savedResponse, - transport: savedTransport, + response: evaluatedResponse, + transport: evaluatedTransport, } case *R.RuleActionDNSRoute: queryOptions := effectiveOptions diff --git a/dns/router_test.go b/dns/router_test.go index 2227e0d82..aff6a318d 100644 --- a/dns/router_test.go +++ b/dns/router_test.go @@ -1956,7 +1956,7 @@ func TestExchangeLegacyDNSModeDisabledEvaluateExchangeFailureUsesMatchResponseBo } } -func TestExchangeLegacyDNSModeDisabledRespondReturnsSavedResponse(t *testing.T) { +func TestExchangeLegacyDNSModeDisabledRespondReturnsEvaluatedResponse(t *testing.T) { t.Parallel() var exchanges []string @@ -2008,7 +2008,7 @@ func TestExchangeLegacyDNSModeDisabledRespondReturnsSavedResponse(t *testing.T) require.Equal(t, []netip.Addr{netip.MustParseAddr("1.1.1.1")}, MessageToAddresses(response)) } -func TestLookupLegacyDNSModeDisabledRespondReturnsSavedResponse(t *testing.T) { +func TestLookupLegacyDNSModeDisabledRespondReturnsEvaluatedResponse(t *testing.T) { t.Parallel() defaultTransport := &fakeDNSTransport{tag: "default", transportType: C.DNSTypeUDP} @@ -2065,7 +2065,7 @@ func TestLookupLegacyDNSModeDisabledRespondReturnsSavedResponse(t *testing.T) { }, addresses) } -func TestExchangeLegacyDNSModeDisabledRespondWithoutSavedResponseReturnsError(t *testing.T) { +func TestExchangeLegacyDNSModeDisabledRespondWithoutEvaluatedResponseReturnsError(t *testing.T) { t.Parallel() defaultTransport := &fakeDNSTransport{tag: "default", transportType: C.DNSTypeUDP} diff --git a/docs/configuration/dns/rule.md b/docs/configuration/dns/rule.md index ef5110eed..190192df4 100644 --- a/docs/configuration/dns/rule.md +++ b/docs/configuration/dns/rule.md @@ -497,7 +497,7 @@ Enable response-based matching. When enabled, this rule matches against DNS resp (set by a preceding [`evaluate`](/configuration/dns/rule_action/#evaluate) action) instead of only matching the original query. -The saved response can also be returned directly by a later [`respond`](/configuration/dns/rule_action/#respond) action. +The evaluated response can also be returned directly by a later [`respond`](/configuration/dns/rule_action/#respond) action. Required for Response Match Fields (`response_rcode`, `response_answer`, `response_ns`, `response_extra`). Also required for `ip_cidr` and `ip_is_private` when used with `evaluate` or Response Match Fields. @@ -618,7 +618,7 @@ Match any IP with query response. Match fields for DNS response data. Require `match_response` to be set to `true` and a preceding rule with [`evaluate`](/configuration/dns/rule_action/#evaluate) action to populate the response. -That saved response may also be returned directly by a later [`respond`](/configuration/dns/rule_action/#respond) action. +That evaluated response may also be returned directly by a later [`respond`](/configuration/dns/rule_action/#respond) action. #### response_rcode diff --git a/docs/configuration/dns/rule.zh.md b/docs/configuration/dns/rule.zh.md index 4fc505891..fb215b0c0 100644 --- a/docs/configuration/dns/rule.zh.md +++ b/docs/configuration/dns/rule.zh.md @@ -495,7 +495,7 @@ Available values: `wifi`, `cellular`, `ethernet` and `other`. 启用响应匹配。启用后,此规则将匹配 DNS 响应数据(由前序 [`evaluate`](/zh/configuration/dns/rule_action/#evaluate) 动作设置),而不仅是匹配原始查询。 -该已保存的响应也可以被后续的 [`respond`](/zh/configuration/dns/rule_action/#respond) 动作直接返回。 +该已评估的响应也可以被后续的 [`respond`](/zh/configuration/dns/rule_action/#respond) 动作直接返回。 响应匹配字段(`response_rcode`、`response_answer`、`response_ns`、`response_extra`)需要此选项。 当与 `evaluate` 或响应匹配字段一起使用时,`ip_cidr` 和 `ip_is_private` 也需要此选项。 @@ -617,7 +617,7 @@ Available values: `wifi`, `cellular`, `ethernet` and `other`. DNS 响应数据的匹配字段。需要将 `match_response` 设为 `true`, 且需要前序规则使用 [`evaluate`](/zh/configuration/dns/rule_action/#evaluate) 动作来填充响应。 -该已保存的响应也可以被后续的 [`respond`](/zh/configuration/dns/rule_action/#respond) 动作直接返回。 +该已评估的响应也可以被后续的 [`respond`](/zh/configuration/dns/rule_action/#respond) 动作直接返回。 #### response_rcode diff --git a/docs/configuration/dns/rule_action.md b/docs/configuration/dns/rule_action.md index 6e44fbb9c..678053e61 100644 --- a/docs/configuration/dns/rule_action.md +++ b/docs/configuration/dns/rule_action.md @@ -81,7 +81,7 @@ Will override `dns.client_subnet`. } ``` -`evaluate` sends a DNS query to the specified server and saves the response for subsequent rules +`evaluate` sends a DNS query to the specified server and saves the evaluated response for subsequent rules to match against using [`match_response`](/configuration/dns/rule/#match_response) and response fields. Unlike `route`, it does **not** terminate rule evaluation. @@ -126,7 +126,7 @@ Will override `dns.client_subnet`. This action does not send a new DNS query and has no extra options. -Only allowed after a preceding top-level `evaluate` rule. If the action is reached without a saved response at runtime, the request fails with an error instead of falling through to later rules. +Only allowed after a preceding top-level `evaluate` rule. If the action is reached without an evaluated response at runtime, the request fails with an error instead of falling through to later rules. ### route-options diff --git a/docs/configuration/dns/rule_action.zh.md b/docs/configuration/dns/rule_action.zh.md index b7d9b0dbd..a9db91820 100644 --- a/docs/configuration/dns/rule_action.zh.md +++ b/docs/configuration/dns/rule_action.zh.md @@ -81,7 +81,7 @@ icon: material/new-box } ``` -`evaluate` 向指定服务器发送 DNS 查询并保存响应,供后续规则通过 [`match_response`](/zh/configuration/dns/rule/#match_response) 和响应字段进行匹配。与 `route` 不同,它**不会**终止规则评估。 +`evaluate` 向指定服务器发送 DNS 查询并保存已评估的响应,供后续规则通过 [`match_response`](/zh/configuration/dns/rule/#match_response) 和响应字段进行匹配。与 `route` 不同,它**不会**终止规则评估。 仅允许在顶层 DNS 规则中使用(不可在逻辑子规则内部使用)。 使用 [`match_response`](/zh/configuration/dns/rule/#match_response) 或响应匹配字段的规则, @@ -120,11 +120,11 @@ icon: material/new-box } ``` -`respond` 会终止规则评估,并直接返回前序 [`evaluate`](/zh/configuration/dns/rule_action/#evaluate) 动作保存的 DNS 响应。 +`respond` 会终止规则评估,并直接返回前序 [`evaluate`](/zh/configuration/dns/rule_action/#evaluate) 动作保存的已评估的响应。 此动作不会发起新的 DNS 查询,也没有额外选项。 -只能用于前面已有顶层 `evaluate` 规则的场景。如果运行时命中该动作时没有已保存的响应,则请求会直接返回错误,而不是继续匹配后续规则。 +只能用于前面已有顶层 `evaluate` 规则的场景。如果运行时命中该动作时没有已评估的响应,则请求会直接返回错误,而不是继续匹配后续规则。 ### route-options