Rules
Rule Set

Rule Sets

By using rule sets, a large number of rules can be referenced with low resource usage, and can be silently updated in the background without the need to reload Stash. To use rule sets, the declaration must be completed under rule-provide, and then the set can be referenced under rules.

rule-providers:
  proxy-domain:
    behavior: domain # Using domain class rule sets can make matching more efficient
    url: https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/proxy.txt
    interval: 86400
 
  cn-cidr:
    behavior: ipcidr # Using ipcidr class rule sets can make matching more efficient
    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 class rule sets support the no-resolve parameter

Stash supports multiple rule set formats, which support different content and have different resource usage:

Behavior (behavior)Supported ContentExampleMatching Performance
domainDomain / Wildcardlink (opens in a new tab)Excellent
domain-textDomain / Wildcardlink (opens in a new tab)Excellent
ipcidrIPv4 / IPv6 Setlink (opens in a new tab)Excellent
ipcidr-textIPv4 / IPv6 Setlink (opens in a new tab)Excellent
classicalAnylink (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 are recommended for use when there are many rule entries.

It is not recommended to use the classical rule set containing a large number of rules, as it will significantly increase Stash's memory usage.