DnsFilterEngine Class
A DNS filter matching engine that evaluates DNS queries against a set of filter rules. Supports efficient exact domain matching, subdomain matching, wildcard, and regex patterns.
public sealed class DnsFilterEngineRemarks
DnsFilterEngine.Evaluate is safe to call concurrently, and DnsFilterEngine.Reload swaps the rule set atomically. DnsFilterRuleSet itself is not thread-safe for concurrent mutation; the engine takes a snapshot when it builds, so mutating a rule set afterwards never affects an engine already built from it.
Constructors
| Name | Description |
|---|---|
| DnsFilterEngine(DnsFilterRuleSet) | Initializes a new instance of the DnsFilterEngine class with the specified rule set. |
DnsFilterEngine(DnsFilterRuleSet)
DnsFilterEngine.csInitializes a new instance of the DnsFilterEngine class with the specified rule set.
public DnsFilterEngine(DnsFilterRuleSet ruleSet)Parameters
ruleSetDnsFilterRuleSet- The rule set to use for matching.
Methods
| Name | Description |
|---|---|
| Evaluate(string, DnsFilterQueryType, DnsClientInfo) | Evaluates a DNS query against the filter rules. |
| Reload(DnsFilterRuleSet) | Atomically replaces the current rule set with a new one. Thread-safe with respect to concurrent DnsFilterEngine.Evaluate calls. |
Evaluate(string, DnsFilterQueryType, DnsClientInfo)
DnsFilterEngine.csEvaluates a DNS query against the filter rules.
public DnsFilterResult Evaluate(string domain, DnsFilterQueryType queryType = DnsFilterQueryType.A, DnsClientInfo client = default)Parameters
domainstring- The queried domain name. Internationalized names are converted to their punycode form before matching.
queryTypeDnsFilterQueryType- The DNS query type. Pass the raw QTYPE cast to
DnsFilterQueryTypeeven when it is not a named member. clientDnsClientInfo- Optional client information for
$clientand$ctagmatching. When a dimension is not supplied, rules scoped on it do not match.
Returns
DnsFilterResult A DnsFilterResult indicating whether the query is blocked, allowed, rewritten, or unmatched. This method does not throw for malformed or hostile input.
Reload(DnsFilterRuleSet)
DnsFilterEngine.csAtomically replaces the current rule set with a new one. Thread-safe with respect to concurrent DnsFilterEngine.Evaluate calls.
public void Reload(DnsFilterRuleSet ruleSet)Parameters
ruleSetDnsFilterRuleSet- The new rule set.