DnsFilterRule Class
Represents a single parsed DNS filter rule.
public sealed class DnsFilterRuleProperties
| Name | Description |
|---|---|
| Action | Gets the action to perform when this rule matches. Always DnsFilterAction.Block or DnsFilterAction.Allow. |
| AllowedDnsTypes | Gets the set of DNS query types this rule applies to (from $dnstype modifier). null means the rule applies to all query types. |
| DenyAllowDomains | Gets the set of domains excluded from this rule (from $denyallow modifier). |
| DomainSuffix | Gets the domain suffix this rule matches (for ||domain^ style rules that match the domain and all its subdomains), or null. |
| ExactDomain | Gets the exact domain this rule matches, or null if it does not match by exact domain. |
| ExcludedDnsTypes | Gets the set of DNS query types this rule does not apply to (from $dnstype=~ modifier). null means no types are excluded. |
| IsBadFilter | Gets a value indicating whether this is a $badfilter rule that disables another rule matching its pattern and modifiers. |
| IsImportant | Gets a value indicating whether this rule has the $important modifier, which elevates its priority above normal rules and exceptions. |
| OriginalText | Gets the original text of the rule as it appeared in the filter list. |
| PatternText | Gets the regular expression source this rule matches with, or null. Set for /regex/ rules and for patterns containing *. |
| Rewrite | Gets the rewrite directive for this rule (from $dnsrewrite modifier). |
Action
DnsFilterRule.csGets the action to perform when this rule matches. Always DnsFilterAction.Block or DnsFilterAction.Allow.
public required DnsFilterAction Action { get; init; }Property value
AllowedDnsTypes
DnsFilterRule.csGets the set of DNS query types this rule applies to (from $dnstype modifier). null means the rule applies to all query types.
public IReadOnlyCollection<DnsFilterQueryType>? AllowedDnsTypes { get; init; }Property value
DenyAllowDomains
DnsFilterRule.csGets the set of domains excluded from this rule (from $denyallow modifier).
public IReadOnlyCollection<string>? DenyAllowDomains { get; init; }Property value
DomainSuffix
DnsFilterRule.csExactDomain
DnsFilterRule.csExcludedDnsTypes
DnsFilterRule.csGets the set of DNS query types this rule does not apply to (from $dnstype=~ modifier). null means no types are excluded.
public IReadOnlyCollection<DnsFilterQueryType>? ExcludedDnsTypes { get; init; }Property value
IsBadFilter
DnsFilterRule.csIsImportant
DnsFilterRule.csOriginalText
DnsFilterRule.csGets the original text of the rule as it appeared in the filter list.
public required string OriginalText { get; init; }Property value
Remarks
This is provided for diagnostics only. It is not the rule's identity: use DnsFilterRule.ExactDomain, DnsFilterRule.DomainSuffix or DnsFilterRule.PatternText to report what the rule actually matches.
PatternText
DnsFilterRule.csRewrite
DnsFilterRule.csGets the rewrite directive for this rule (from $dnsrewrite modifier).
public DnsFilterRewriteRule? Rewrite { get; init; }Property value
Methods
| Name | Description |
|---|---|
| CreateAllow(string, bool) | Creates an exception rule allowing a single domain, and optionally all of its subdomains. |
| CreateBlock(string, bool) | Creates a rule blocking a single domain, and optionally all of its subdomains. |
CreateAllow(string, bool)
DnsFilterRule.csCreates an exception rule allowing a single domain, and optionally all of its subdomains.
public static DnsFilterRule CreateAllow(string domain, bool includeSubdomains = false)CreateBlock(string, bool)
DnsFilterRule.csCreates a rule blocking a single domain, and optionally all of its subdomains.
public static DnsFilterRule CreateBlock(string domain, bool includeSubdomains = false)