Skip to content

pluiez/clash-rules

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

clash-rules

用于托管可公开的 Mihomo / Clash 自定义规则文件。

这个仓库只保存经常变动的规则集和脱敏模板,不保存真实使用中的 clash.yaml,也不保存节点信息。

1. 目录结构

.
├── rules/
│   ├── direct.yaml
│   ├── reject.yaml
│   └── proxy.yaml
└── templates/
    └── clash.template.yaml

2. 规则文件

  • rules/direct.yaml: 强制直连的自定义域名规则
  • rules/reject.yaml: 强制拦截的自定义域名规则
  • rules/proxy.yaml: 强制走代理的自定义域名规则

当前规则文件使用 behavior: domain 对应的 wildcard YAML 格式:

payload:
  - '+.example.com'
  - '+.sub.example.com'

3. 在配置中引用

可在本地 clash.yaml / mihomo.yaml 中这样引用。默认使用 GitHub 原始地址;如果中国网络环境无法稳定访问 raw.githubusercontent.com,可把对应 url 改成其下方注释掉的 gh-proxy 版本。

rule-providers:
  custom-reject:
    type: http
    behavior: domain
    format: yaml
    url: "https://raw.githubusercontent.com/pluiez/clash-rules/main/rules/reject.yaml"
    # 中国网络环境如无法稳定访问 raw.githubusercontent.com,可改用 gh-proxy:
    # url: "https://gh-proxy.org/https://raw.githubusercontent.com/pluiez/clash-rules/main/rules/reject.yaml"
    path: ./ruleset/custom-reject.yaml
    interval: 86400

  custom-direct:
    type: http
    behavior: domain
    format: yaml
    url: "https://raw.githubusercontent.com/pluiez/clash-rules/main/rules/direct.yaml"
    # 中国网络环境如无法稳定访问 raw.githubusercontent.com,可改用 gh-proxy:
    # url: "https://gh-proxy.org/https://raw.githubusercontent.com/pluiez/clash-rules/main/rules/direct.yaml"
    path: ./ruleset/custom-direct.yaml
    interval: 86400

  custom-proxy:
    type: http
    behavior: domain
    format: yaml
    url: "https://raw.githubusercontent.com/pluiez/clash-rules/main/rules/proxy.yaml"
    # 中国网络环境如无法稳定访问 raw.githubusercontent.com,可改用 gh-proxy:
    # url: "https://gh-proxy.org/https://raw.githubusercontent.com/pluiez/clash-rules/main/rules/proxy.yaml"
    path: ./ruleset/custom-proxy.yaml
    interval: 86400

对应的 rules 示例:

rules:
  - RULE-SET,custom-reject,🛑 广告拦截
  - RULE-SET,custom-proxy,🚀 节点选择
  - RULE-SET,custom-direct,DIRECT

规则按从上到下的顺序匹配,优先级由上往下递减。

如果你没有单独的广告策略组,也可以直接写成:

- RULE-SET,custom-reject,REJECT

4. 模板

templates/clash.template.yaml 提供了一份脱敏模板,用于演示如何把这三个规则集接入本地主配置。

5. 说明

  • 真实使用中的主配置文件不应提交到仓库
  • 节点、订阅、密钥等敏感信息不应提交到仓库
  • 这个仓库更适合存放需要频繁调整的增量规则,而不是完整配置

6. License

MIT

About

Public custom rule providers for Mihomo / Clash

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors