Rule Sets
By using rule sets, you can reference a large number of rules with lower resource usage, and they can be updated in the background without the need to reload Stash. To use rule sets, you must complete the declaration under rule-providers
, and then you can reference the sets under rules
.
rule-providers:
proxy-domain:
behavior: domain # Use domain-type rule sets for more efficient matching
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 # Use ipcidr-type rule sets for more efficient matching
format: text # Use text format for rule sets
url: https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/cncidr.txt
interval: 86400
rules:
- RULE-SET,proxy-domain,Proxy
- RULE-SET,cn-cidr,DIRECT,no-resolve # ipcidr-type rule sets support the no-resolve parameter
Stash supports multiple formats for rule sets, each format supports different content and has different resource usage:
Behavior | Format | Supported Content | Example | Matching Performance |
---|---|---|---|---|
domain | yaml | Domain / Domain wildcard | link (opens in a new tab) | Excellent |
domain | text | Domain / Domain wildcard | link (opens in a new tab) | Excellent |
ipcidr | yaml | IPv4 / IPv6 sets, CIDR format | link (opens in a new tab) | Excellent |
ipcidr | text | IPv4 / IPv6 sets, CIDR format | link (opens in a new tab) | Excellent |
classical | yaml | Any | link (opens in a new tab) | Poor |
classical | text | Any | link (opens in a new tab) | Poor |
The domain(-text)
and ipcidr(-text)
types of rule sets are specifically optimized for large amounts of data, and it is recommended to prioritize them when there are many rule entries.
It is not recommended to use classical
rule sets that contain a large number of rules, as it will significantly increase Stash's memory usage and decrease rule matching speed.