The domain_set plugin provides a flexible domain-matching dataset that other plugins can consume. It loads domain rules from files or inline expressions and exposes them via request metadata for fast lookups.
Arc<RwLock<DomainRules>> into metadata keyed by domain_set_<name>).The plugin supports four match types. Evaluation priority is: Full > Domain > Regexp > Keyword.
full — exact case-insensitive match (e.g., full:example.com). Does not match subdomains.domain — domain and all subdomains (e.g., domain:example.com matches example.com and www.example.com). This is the default match type.regexp — regular expression match (Rust regex syntax). Patterns are compiled and evaluated in import order.keyword — substring match (case-insensitive). Rules evaluated in import order.When multiple domain rules could match, the priority and domain specificity rules ensure deterministic behavior (more specific domain wins before less specific TLD rules).
Rules may be provided in files or inline via the exps argument (sequence or single string). Each non-comment line may be one of:
full:example.comdomain:example.comregexp:.+\.google\.com$keyword:googleexample.com (uses default_match_type, typically domain)Lines starting with # are ignored. Leading/trailing whitespace is trimmed.
tag / plugin name: used as the domain-set name if provided.files (string or sequence): paths to domain list files to load.exps (string or sequence): inline expressions to load.auto_reload (bool): enable file watcher to reload when files change (default: false).default_match_type / match_type (string): one of full, domain, regexp, keyword (default: domain).Example configuration:
plugins:
- tag: cn-domains
type: domain_set
config:
files:
- examples/etc/my-domain-list.txt
auto_reload: true
default_match_type: domain
Or inline expressions:
plugins:
- tag: sample-set
type: domain_set
config:
exps:
- full:exact.com
- domain:example.com
- regexp:.+\.github\.io$
- keyword:ads
When the plugin executes, it stores the compiled DomainRules in request metadata under the key domain_set_<name> where <name> is the plugin tag or effective name. Other plugins implementing Matcher can read this metadata and call into it.
exps are applied.stats() method to inspect counts programmatically.full: for exact matches and domain: for subdomains).domain/full rules where possible (they are O(1) lookups) and avoid excessive regex rules which are O(n) to evaluate.default_match_type: domain for common host-lists so that plain example.com matches subdomains.