Provider Plugins
Providers turn rule sets from one-off literals into reusable data assets. In larger configurations they reduce duplication, centralize shared datasets, and keep policies maintainable.
Providers with domain or IP match capability can be referenced directly by matchers through "$tag" and can also be composed by domain_set or ip_set. Those composite providers compile only their own local rules and then consult referenced providers at runtime instead of copying downstream rule data into a merged matcher.
Every live provider also registers POST /plugins/<provider_tag>/reload, and the reload_provider executor can refresh that provider's snapshot in place with the same startup configuration without rebuilding unrelated plugins.
At runtime, ForgeDNS only initializes providers that are actually consumed. If a provider is not referenced directly or indirectly by any server, executor, or matcher, it is skipped during startup, does not appear in the runtime registry, and emits a warning log so the unused configuration is visible.
domain_set
Purpose
Provides a high-performance domain rule set that can be referenced by plugins such as qname and cname.
Example Configuration
- tag: core_domains
type: domain_set
args:
exps:
# Exact-name match
- "full:login.example.com"
# Suffix-domain match
- "domain:example.com"
# Keyword match
- "keyword:cdn"
# Regex match
- "regexp:^api[0-9]+\\.example\\.net$"
# Bare domain syntax is also allowed
- "static.example.org"
files:
# Merge additional rules from files
- "/etc/forgedns/domains.txt"
sets:
# Reuse another domain-capable provider
- "shared_domains"
- "shared_geosite"
Configuration Details
exps
- Type:
array; Required: no; Default: empty array - Purpose: Defines inline domain expressions.
- Examples:
- "full:example.com"- "domain:example.com"- "keyword:cdn"
- Supported forms:
full:domain:keyword:regexp:- Bare domains without a prefix
- Runtime impact:
- Compiled into directly matchable rules during initialization.
files
- Type:
array; Required: no; Default: empty array - Purpose: Lists external rule files.
- Example:
- "/etc/forgedns/domains.txt" - File requirements:
- One rule per line.
- Empty lines and comment lines are ignored.
- Runtime impact:
- File contents are re-read during initialization or
reload_providerand compiled into the current provider's local matcher.
- File contents are re-read during initialization or
sets
- Type:
array; Required: no; Default: empty array - Purpose: References other providers with domain match capability.
- Example:
- "shared_domain_set" - Constraints:
domain_set,geosite,adguard_rule, and other domain-capable providers are allowed.
- Runtime impact:
- The current provider keeps stable handles to referenced providers instead of copying their rules.
- After a downstream provider reloads, the current
domain_setsees the new result without reloading itself.
Behavior
- Initialization and reload only compile local
expsandfiles. - Runtime matching checks the local matcher first and then evaluates referenced providers in
setsdeclaration order. - Referenced providers are no longer flattened into copied rule text or copied compiled state.
Supported Rule Formats
full:example.comdomain:example.comkeyword:cdnregexp:^api\\.example\\.com$example.com
Typical Uses
- Share a core domain list across multiple policies.
- Combine local rules with shared providers behind one reusable entrypoint.
Notes
setsmay reference any provider with domain match capability.- Changing provider topology, tags, or config structure still requires a full
reload;reload_provideronly refreshes the current provider's existing config and external data files.
geosite
Purpose
Loads reusable domain rules from v2ray-rules-dat geosite.dat.
Example Configuration
- tag: geosite_cn
type: geosite
args:
file: "/etc/forgedns/geosite.dat"
selectors:
- "cn"
- "geolocation-!cn"
Configuration Details
file- Type:
string; Required: yes - Path to
geosite.dat.
- Type:
selectors- Type:
array; Required: no; Default: empty array - Case-insensitive exact code filter. Also supports
code@attributeselectors. - Multiple selectors are merged as a union.
- Omit it or pass
[]to load the full union of every entry in the dat file. - Example:
category-games@cnkeeps only rules undercategory-gamesthat carry thecnattribute.
- Type:
Behavior
Plainbecomeskeyword:.Regexbecomesregexp:.RootDomainbecomesdomain:.Fullbecomesfull:.- Can be referenced directly by
qname,cname, andquestion, or aggregated bydomain_set. - Supports independent refresh through
reload_providerorPOST /plugins/<tag>/reload. - If you want to pre-export selected rules into text files before runtime, use
forgedns export-dat --kind geosite.
adguard_rule
Purpose
Provides a reusable subset of AdGuard Home DNS rule evaluation as a provider.
This provider exposes two semantics:
contains_question: full request-question evaluation, includingdnstypecontains_name: a name-only projection that ignores alldnstyperules
Example Configuration
- tag: ad_rules
type: adguard_rule
args:
rules:
# Basic blocking rule
- "||ads.example.com^"
# Exception rule
- "@@||safe.ads.example.com^"
# Complex inline rule with dnstype / important / denyallow
- "||cdn.example.com^$dnstype=A|AAAA,important,denyallow=cdn-safe.example.com"
files:
# External AdGuard-format rule files
- "/etc/forgedns/adguard.txt"
Behavior
- Supports: basic domain rules,
@@,important,badfilter,denyallow, and request-sidednstype - Unsupported but skipped with warnings:
/etc/hostsstyle rules,dnsrewrite,$client,$ctag, and unknown modifiers - Full precedence order:
importantexceptionsimportantblocks- normal exceptions
- normal blocks
Typical Uses
- Use AdGuard rules through the
qnamematcher with name-only projection semantics. - Reuse AdGuard rule files through the
questionmatcher. - Centralize complex AdGuard-style blocking semantics at the provider layer.
Notes
- Name-only matchers such as
qnameandcnameusecontains_name, sodnstype-only rules are ignored there. adguard_rulecan be referenced fromdomain_set.sets; because evaluation stays dynamic, exception precedence and request-scoped modifiers such asdnstyperemain intact.
ip_set
Purpose
Provides IP and CIDR rule sets that can be referenced by matchers such as client_ip, resp_ip, and ptr_ip.
Example Configuration
- tag: lan_ip_set
type: ip_set
args:
ips:
# Single IPv4
- "192.168.1.1"
# IPv4 CIDR
- "192.168.0.0/16"
- "10.0.0.0/8"
# Single IPv6
- "2001:db8::1"
# IPv6 CIDR
- "fd00::/8"
files:
# Merge more IP / CIDR entries from files
- "/etc/forgedns/ips.txt"
sets:
# Reuse another IP-capable provider
- "shared_ip_set"
- "shared_geoip"
Configuration Details
ips
- Type:
array; Required: no; Default: empty array - Purpose: Defines inline IP or CIDR rules.
- Examples:
- "1.1.1.1"- "192.168.0.0/16"- "2400:3200::/32"
- Supported forms:
- Individual IPv4 addresses
- Individual IPv6 addresses
- IPv4 CIDRs
- IPv6 CIDRs
- Runtime impact:
- Compiled into address matching structures during initialization.
files
- Type:
array; Required: no; Default: empty array - Purpose: Lists external IP rule files.
- Example:
- "/etc/forgedns/ips.txt" - File requirements:
- One IP or CIDR rule per line.
- Empty lines and comment lines are ignored.
- Runtime impact:
- File contents are re-read during initialization or
reload_providerand compiled into the current provider's local matcher.
- File contents are re-read during initialization or
sets
- Type:
array; Required: no; Default: empty array - Purpose: References other providers with IP match capability.
- Example:
- "shared_ip_set" - Constraints:
ip_set,geoip, and other IP-capable providers are allowed.
- Runtime impact:
- The current provider keeps stable handles to referenced providers instead of copying their rules.
- After a downstream provider reloads, the current
ip_setsees the new result without reloading itself.
Behavior
- Initialization and reload only compile local
ipsandfiles. - IPv4 and IPv6 rule indexes are maintained separately.
- Runtime matching checks the local matcher first and then evaluates referenced providers in
setsdeclaration order.
Rule Formats
1.1.1.1192.168.0.0/162400:3200::/32
Typical Uses
- Define LAN, WAN, overlay, or infrastructure address groups.
- Build allowlists, bypass lists, or target network sets.
- Combine local CIDRs with shared
geoiporip_setproviders behind one reusable entrypoint.
Notes
setsmay reference any provider with IP match capability.- Changing provider topology, tags, or config structure still requires a full
reload;reload_provideronly refreshes the current provider's existing config and external data files.
geoip
Purpose
Loads reusable IP and CIDR rules from v2ray-rules-dat geoip.dat.
Example Configuration
- tag: geoip_cn
type: geoip
args:
file: "/etc/forgedns/geoip.dat"
selectors:
- "cn"
Configuration Details
file- Type:
string; Required: yes - Path to
geoip.dat.
- Type:
selectors- Type:
array; Required: no; Default: empty array - Case-insensitive exact code filter.
- Multiple selectors are merged as a union.
- Omit it or pass
[]to load the full union of every entry in the dat file.
- Type:
Behavior
- Exposes IP-only membership checks.
- Can be referenced directly by
client_ip,resp_ip, andptr_ip, or composed byip_set. - Supports independent refresh through
reload_providerorPOST /plugins/<tag>/reload. - If you want to pre-export selected rules into text files before runtime, use
forgedns export-dat --kind geoip.