Rule Sets
The rule set feature allows referencing a large number of rules with low resource consumption and supports silent updates in the background without reloading Stash. To use rule sets, you need to declare them under rule-providers, and then reference the sets under rules.
rule-providers:
proxy-domain:
behavior: domain # Using domain-type rule sets can improve matching efficiency
format: yaml # Use YAML format for rule sets
url: https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/proxy.txt
interval: 86400
cn-cidr:
behavior: ipcidr # Using ipcidr-type rule sets can improve matching efficiency
format: text # Use text format for rule sets
url: https://cdn.jsdelivr.net/gh/17mon/china_ip_list@master/china_ip_list.txt
interval: 86400
rules:
- RULE-SET,proxy-domain,Proxy
- RULE-SET,cn-cidr,DIRECT,no-resolve # ipcidr-type rule sets support the no-resolve parameterIf a remote rule set requires authentication, or if the server expects specific
request headers such as Accept or User-Agent, configure headers on the
rule provider. Stash sends these headers when updating the remote rule set.
rule-providers:
proxy-domain:
behavior: domain
format: yaml
url: https://example.com/rules.yaml
interval: 86400
headers:
Authorization: Bearer your-token
Accept: application/yamlValues under headers can be either a single string or an array of strings for
multi-value request headers:
rule-providers:
proxy-domain:
behavior: domain
format: yaml
url: https://example.com/rules.yaml
interval: 86400
headers:
Accept:
- application/yaml
- text/plainIf the URL already contains a username and password, such as
https://user:password@example.com/rules.yaml, Stash uses the URL credentials to
generate Basic Auth. In that case, it overrides Authorization configured in
headers.
Stash supports various rule set formats, each supporting different content types and exhibiting different resource usage:
| Behavior | Format | Supported Content | Example | Matching Performance | Memory Usage |
|---|---|---|---|---|---|
domain | yaml | Domains/Domain Wildcards | Link (opens in a new tab) | Excellent | Low |
domain | text | Domains/Domain Wildcards | Link (opens in a new tab) | Excellent | Low |
ipcidr | yaml | IPv4/IPv6 collections, CIDR format | Link (opens in a new tab) | Excellent | Low |
ipcidr | text | IPv4/IPv6 collections, CIDR format | Link (opens in a new tab) | Excellent | Low |
classical | yaml | Any rule type | Link (opens in a new tab) | Average | Average |
classical | text | Any rule type | Link (opens in a new tab) | Average | Average |
Rule sets of type domain(-text) and ipcidr(-text) are specially compressed
and optimized for a large amount of data. It is recommended to prioritize
these when there are a lot of rule entries.
Stash also supports using MRS format rule sets, currently supporting rule sets
with behavior as domain and ipcidr.