Rules
Rule Set

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 parameter

Stash supports various rule set formats, each supporting different content types and exhibiting different resource usage:

BehaviorFormatSupported ContentExampleMatching PerformanceMemory Usage
domainyamlDomains/Domain WildcardsLink (opens in a new tab)ExcellentLow
domaintextDomains/Domain WildcardsLink (opens in a new tab)ExcellentLow
ipcidryamlIPv4/IPv6 collections, CIDR formatLink (opens in a new tab)ExcellentLow
ipcidrtextIPv4/IPv6 collections, CIDR formatLink (opens in a new tab)ExcellentLow
classicalyamlAny rule typeLink (opens in a new tab)AverageAverage
classicaltextAny rule typeLink (opens in a new tab)AverageAverage
💡

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.