Developer-Focused Rules
Relevant source files
The following files were used as context for generating this wiki page:The Self-Rule project, based on ACL4SSR, utilizes a collection of developer-focused rules to manage network traffic for various software development tools, services, and platforms. These rules are defined in modular YAML files and are designed to route traffic for specific domains through a designated proxy policy, ensuring consistent access and performance for developers. The rules cover a wide range of services, including version control systems like GitHub, containerization platforms like Docker, AI development tools, and general programming resources.
These individual rule sets are managed as distinct files, which can then be aggregated into larger, more comprehensive proxy provider configurations. This modular approach allows for easy maintenance and customization of traffic routing policies tailored to a developer's workflow. The generation of these rule files is automated by a Python script, which converts simple list files into the required Clash YAML format.
Sources: README.md, Clash/Providers/Ruleset/Developer.yaml, update_providers.py
Rule Architecture and Generation
The developer-focused rules are structured as Clash-compatible YAML files, which are automatically generated from simpler .list source files. This process ensures consistency and simplifies rule management.
Rule File Structure
Each rule set is a YAML file containing a payload key. This key holds a list of individual rule definitions, which are primarily domain-based.
The most common rule types used are:
| Rule Type | Description | Example |
|---|---|---|
DOMAIN-SUFFIX | Matches a domain and all its subdomains. | DOMAIN-SUFFIX,github.com matches github.com and api.github.com. |
DOMAIN-KEYWORD | Matches if the keyword is found anywhere in the domain name. | DOMAIN-KEYWORD,openai matches chat.openai.com. |
DOMAIN | Matches an exact domain name. | DOMAIN,api.githubcopilot.com matches only that specific domain. |
Sources: Clash/Providers/Ruleset/Developer.yaml:4-23, Clash/Providers/Ruleset/AI.yaml:5-43
An example from the Developer.yaml file illustrates this structure:
payload:
# 内容:Developer 开发者常用国外网站、镜像和论坛
# 数量:20条
- DOMAIN-SUFFIX,apache.org
- DOMAIN-SUFFIX,docker.com
- DOMAIN-SUFFIX,docker.io
- DOMAIN-SUFFIX,elastic.co
- DOMAIN-SUFFIX,stackoverflow.com
Sources: Clash/Providers/Ruleset/Developer.yaml:1-9,23
Automated Generation Process
The YAML rule provider files are not manually created. The update_providers.py script automates their generation from .list files located in the Clash/ directory tree.
The script performs the following actions:
- Traverses the
Clash/directory, ignoring theClash/configandClash/Providerssubdirectories. - For each
.listfile found (e.g.,Clash/Ruleset/Developer.list), it creates a corresponding.yamlfile in theClash/Providers/directory (e.g.,Clash/Providers/Ruleset/Developer.yaml). - It reads the content of the
.listfile line by line. - Each line is formatted and written into the new YAML file under the
payload:key. - Lines starting with
#,USER-AGENT,URL-REGEX, orPROCESS-NAMEin the source.listfile are converted into comments in the final YAML file.
Sources: update_providers.py:7-41
The following diagram illustrates the file generation flow:
This diagram shows how the update_providers.py script processes .list files to generate the final YAML rule providers.
Sources: update_providers.py
Key Developer Rule Sets
The repository contains several rule sets tailored for specific developer needs.
General Development
The Developer.yaml file provides rules for commonly used developer websites, package repositories, and forums.
| Service/Tool | Domain Rule |
|---|---|
| Apache | DOMAIN-SUFFIX,apache.org |
| Docker | DOMAIN-SUFFIX,docker.com |
| GitLab | DOMAIN-SUFFIX,gitlab.com |
| Maven | DOMAIN-SUFFIX,maven.org |
| Spring Framework | DOMAIN-SUFFIX,spring.io |
| Stack Overflow | DOMAIN-SUFFIX,stackoverflow.com |
Sources: Clash/Providers/Ruleset/Developer.yaml:4-23
AI and Machine Learning
The AI.yaml rule set targets platforms and services used for AI/ML development. This includes large language models and development APIs.
Key services covered:
- Anthropic:
DOMAIN-KEYWORD,anthropic,DOMAIN-SUFFIX,claude.ai - OpenAI:
DOMAIN-KEYWORD,openai,DOMAIN-SUFFIX,chatgpt.com - Google AI:
DOMAIN,ai.google.dev,DOMAIN-SUFFIX,gemini.google.com - Microsoft Copilot:
DOMAIN,api.githubcopilot.com,DOMAIN-SUFFIX,copilot.microsoft.com - Hugging Face:
DOMAIN-SUFFIX,huggingface.co(fromProxyGFWlist.yaml)
Sources: Clash/Providers/Ruleset/AI.yaml:4-43, Clash/Providers/ProxyGFWlist.yaml:1260
Version Control and Containerization
Dedicated rules exist for GitHub and Docker to ensure seamless interaction with their repositories and registries.
GitHub Rules:
payload:
# 内容:Github
# 数量:5条
- DOMAIN-SUFFIX,github.com
- DOMAIN-SUFFIX,github.io
- DOMAIN-SUFFIX,githubapp.com
- DOMAIN-SUFFIX,githubassets.com
- DOMAIN-SUFFIX,githubusercontent.com
Sources: Clash/Providers/Ruleset/Github.yaml:1-8
Docker Rules:
payload:
# 内容:Docker
# 数量:7条
- DOMAIN,d1q6f0aelx0por.cloudfront.net
- DOMAIN,d2wy8f7a9ursnm.cloudfront.net
- DOMAIN,d36jcksde1wxzq.cloudfront.net
- DOMAIN-SUFFIX,compose-spec.io
- DOMAIN-SUFFIX,docker.com
- DOMAIN-SUFFIX,docker.io
- DOMAIN-SUFFIX,dockerhub.com
Sources: Clash/Providers/Ruleset/Docker.yaml:1-10
Cryptocurrency and Blockchain
For developers working in the Web3 space, the Crypto.yaml file provides rules for various exchanges, blockchain explorers, and development platforms.
- Exchanges:
binance.com,coinbase.com,kraken.com,okx.com - Blockchain/Tools:
ethereum.org,etherscan.io,solana.com,ipfs.io - NFT Platforms:
opensea.io,nftscan.com
Sources: Clash/Providers/Ruleset/Crypto.yaml:5,12,15,100,140,148,162,163
Rule Aggregation in Proxy Providers
The modular rule sets are designed to be included in larger, composite proxy provider files. The ProxyLite.yaml file is an example of such an aggregation, where it includes the entire Developer ruleset.
This diagram shows the aggregation concept:
This shows how specific rule sets are combined into a larger provider file for easier management in a Clash configuration.
The ProxyLite.yaml file explicitly lists the developer-related domains, demonstrating this inclusion.
payload:
# ... other rules
# Developer 开发者常用国外网站、镜像和论坛
- DOMAIN-SUFFIX,apache.org
- DOMAIN-SUFFIX,docker.com
- DOMAIN-SUFFIX,docker.io
- DOMAIN-SUFFIX,elastic.co
- DOMAIN-SUFFIX,elastic.com
- DOMAIN-SUFFIX,gcr.io
- DOMAIN-SUFFIX,gitlab.com
# ... and so on
Sources: Clash/Providers/ProxyLite.yaml:220-241
Summary
The Developer-Focused Rules in the Self-Rule repository provide a robust and modular system for managing network traffic for software development activities. By defining specific rules for tools like Docker, GitHub, and various AI platforms, the project ensures that developers have reliable access to critical resources. The automation of YAML file generation from simpler .list files streamlines maintenance, while the aggregation of these modules into comprehensive provider files like ProxyLite.yaml offers flexibility in applying routing policies. This structured approach is central to the project's goal of providing a customized and efficient proxy experience for developers.