Premium · Clash documentation

Feature: Rule Providers

Load rule-providers locally or remotely, verify behavior, url, interval, path, and RULE-SET, and distinguish domain, ipcidr, and classical formats.

  • RULE-SET
  • rule-providers
  • behavior
  • interval
  • path
Premium

Rule Providers work much like Proxy Providers. They let users load rules from external sources, keeping the configuration concise. This feature is currently available only in the Clash Premium core.

To define Rule Providers, add the rule-providers field to the main configuration:

yaml
rule-providers:
  apple:
    behavior: "domain" # domain, ipcidr or classical (仅限 Clash Premium 内核)
    type: http
    url: "url"
    # format: 'yaml' # or 'text'
    interval: 3600
    path: ./apple.yaml
  microsoft:
    behavior: "domain"
    type: file
    path: /microsoft.yaml

rules:
  - RULE-SET,apple,REJECT
  - RULE-SET,microsoft,policy

Three behavior types are available:

domain

yaml:

yaml
payload:
  - '.blogger.com'
  - '*.*.microsoft.com'
  - 'books.itunes.apple.com'

text:

txt
# comment
.blogger.com
*.*.microsoft.com
books.itunes.apple.com

ipcidr

yaml

yaml
payload:
  - '192.168.1.0/24'
  - '10.0.0.0.1/32'

text:

txt
# comment
192.168.1.0/24
10.0.0.0.1/32

classical

yaml:

yaml
payload:
  - DOMAIN-SUFFIX,google.com
  - DOMAIN-KEYWORD,google
  - DOMAIN,ad.com
  - SRC-IP-CIDR,192.168.1.201/32
  - IP-CIDR,127.0.0.0/8
  - GEOIP,CN
  - DST-PORT,80
  - SRC-PORT,7777
  # MATCH 在这里并不是必须的

text:

txt
# comment
DOMAIN-SUFFIX,google.com
DOMAIN-KEYWORD,google
DOMAIN,ad.com
SRC-IP-CIDR,192.168.1.201/32
IP-CIDR,127.0.0.0/8
GEOIP,CN
DST-PORT,80
SRC-PORT,7777