Rules
Rule Set

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:

BehaviorFormatSupported ContentExampleMatching Performance
domainyamlDomain / Domain wildcardlink (opens in a new tab)Excellent
domaintextDomain / Domain wildcardlink (opens in a new tab)Excellent
ipcidryamlIPv4 / IPv6 sets, CIDR formatlink (opens in a new tab)Excellent
ipcidrtextIPv4 / IPv6 sets, CIDR formatlink (opens in a new tab)Excellent
classicalyamlAnylink (opens in a new tab)Poor
classicaltextAnylink (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.