rule
Шаблоны правил (rule-set) для Clash/Mihomo, Loon и Shadowrocket: полное зеркало blackmatrix7/ios_rule_script (ветка master) и свои шаблоны byFox. Каталог с описаниями и обратный индекс «домен/IP → шаблоны».
Шаблонов —, каталог от —, последний коммит bm7 —.
В файлах только условия, без политики — обычные rule-set'ы. Direct, Block или Proxy назначает клиент.
Файлы
| Путь | Что |
|---|---|
manifest.json | дата каталога, коммит bm7, размеры и sha256 файлов ниже |
templates.json (.gz) | каталог всех шаблонов — описания, теги, статистика, пути к файлам |
index.json.gz | обратный индекс для поиска (~4 МБ, в памяти ~100 МБ) |
index/ | тот же индекс по частям — чтобы не держать его в памяти целиком (ниже) |
bm7/<Clash|Loon|Shadowrocket>/<путь>/<файл> | зеркало bm7 один в один: bm7/Clash/Telegram/Telegram.yaml |
byfox/<имя>/{clash/rules.yaml, loon/rules.list, shadowrocket/rules.list} | свои шаблоны |
blackmatrix7.txt, blackmatrix7+www.txt, folders.txt | старые форматы для совместимости (собираются из каталога) |
Переезд с GitHub — замена префикса:
raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/ →
api.byfox.dev/rule/bm7/. Остальная часть пути не меняется.
templates.json
{"date": "2026-11-03", "bm7_commit": "0b6897d…", "bm7_date": "2026-10-27",
"bm7_upstream": "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/",
"base": "rule/", "count": 703, "hidden": 1,
"items": [{
"id": "Apple", "src": "bm7", "name": "Apple",
"title": {"ru": "Apple: все сервисы", "en": "Apple: all services"},
"desc": {"ru": "…", "en": "…"},
"tags": ["icloud", "app store"], "category": "apple",
"check": "https://www.apple.com/",
"domain_set": true,
"stats": {"domains": 9, "suffixes": 1550, "keywords": 7, "cidr": 10, "cidr6": 3, "asn": 0, "other": 13},
"sample": ["apple.com", "appleid.com", "me.com", …],
"files": {"clash": "bm7/Clash/Apple/Apple_Domain.yaml", "loon": "bm7/Loon/Apple/Apple_Domain.list",
"shadowrocket": "bm7/Shadowrocket/Apple/Apple_Domain.list"},
"rest": {"clash": "bm7/Clash/Apple/Apple.yaml", …},
"classical": "bm7/Clash/Apple/Apple_Classical.yaml",
"updated": "2026-10-27"}]}
| Поле | Смысл |
|---|---|
id | уникален; у bm7 — путь папки (Telegram, Cloud/AkamaiCloud), у своих — имя папки (при совпадении с bm7 — byfox/<имя>) |
src | bm7 или byfox |
title, desc | RU/EN; без ручной подсказки title = имя, desc = сводка по статистике |
category | ai, apple, google, microsoft, social, messenger, video, music, news, games, dev, cloud, cdn, ads, privacy, finance, crypto, shopping, tools, devices, education, torrent, cert, system, russia, china, china-bundle (сборники bm7 для пользователей из КНР), other |
check | сайт, по которому проверять, работает ли сервис; нет — null (пустой строки не бывает) |
files | основной файл на платформу, путь от rule/. Платформы может не быть |
domain_set | true — в files лежит domain-set (строки +.example.com/.example.com), а не classical. Так у 19 крупных шаблонов bm7 (Apple, Advertising, China*, Global…) |
rest | только у domain-set: classical-файл с тем, что в domain-set не влезло (keyword, IP, ASN). Подключать вместе с files |
classical | полный classical-список для Clash одним файлом (у domain-set — _Classical.yaml) |
generated | платформы, которых нет в источнике и которые сгенерированы здесь из другой платформы |
updated | дата последнего изменения шаблона (для bm7 — по git log) |
hidden | только у скрытых, true: в выбор шаблонов не показывать, но файлы отдаются как у всех — для клиентов, у которых он уже подключён. В индекс и старые txt не попадает. count считает и скрытые, сколько их — hidden в корне |
Как подключить
Clash / Mihomo
rule-providers:
Telegram:
type: http
behavior: classical
format: yaml
url: https://api.byfox.dev/rule/bm7/Clash/Telegram/Telegram.yaml
interval: 86400
Apple: # domain_set: true
type: http
behavior: domain
format: yaml
url: https://api.byfox.dev/rule/bm7/Clash/Apple/Apple_Domain.yaml
interval: 86400
rules:
- RULE-SET,Telegram,PROXY
- RULE-SET,Apple,DIRECT
Shadowrocket
RULE-SET,https://api.byfox.dev/rule/bm7/Shadowrocket/Telegram/Telegram.list,PROXY
DOMAIN-SET,https://api.byfox.dev/rule/bm7/Shadowrocket/Apple/Apple_Domain.list,DIRECT
Loon
[Remote Rule]
https://api.byfox.dev/rule/bm7/Loon/Telegram/Telegram.list, policy=PROXY, tag=Telegram, enabled=true
index.json.gz — поиск «кто это блокирует»
{"date": "2026-11-03", "ver": 1,
"ids": ["115", "12306", …], // номер → id шаблона; ниже везде номера
"suffix": {"telegram.org": [290, 582]}, // DOMAIN-SUFFIX и +.x
"exact": {"openai-api.arkoselabs.com": [191, 468]}, // DOMAIN
"keyword": {"telegram": [290, 503, 504]},
"asn": {"62041": [582]},
"cidr": [["91.108.4.0/22", [583]], …], // по возрастанию сети
"cidr6": [["2001:67c:4e8::/48", [290, 582, 583]], …],
"names": {"telegram": [582, 583, 584, 585]}} // имя, теги, слова title, слова категории RU/EN — нижний регистр
Домен a.b.example.com: проверить exact для него целиком, затем suffix для него
и каждого родителя (b.example.com, example.com, com), затем все keyword, входящие
в строку. IP — все сети cidr/cidr6, в которые он попадает. Результат — объединение номеров → ids.
names — для поиска по названию: кроме имён и тегов там слова категорий по-русски и по-английски
(нейросети, ии, соцсети, реклама, мессенджеры, видео…).
Скрытых шаблонов (hidden) в индексе нет.
index/ — индекс по частям
Те же данные, что в index.json.gz, разложены так, чтобы на запрос читать с диска только нужное.
Номера шаблонов те же, что в ids.json.
| Файл | Что |
|---|---|
index/ids.json | {"date", "ver": 1, "shards": 256, "ids": [...]} — номер → id |
index/domain/<hh>.json.gz | {"suffix": {...}, "exact": {...}}; 256 файлов, hh — первые 2 hex-символа sha1 ключа (домен в нижнем регистре, UTF-8) |
index/keyword.json.gz | как keyword |
index/cidr.json.gz | {"cidr": [...], "cidr6": [...]}, по возрастанию сети |
index/asn.json.gz, index/names.json.gz | как asn, names |
def shard(key): return hashlib.sha1(key.encode()).hexdigest()[:2]
# a.b.example.com → domain/shard("a.b.example.com"): exact + suffix,
# domain/shard("b.example.com"), shard("example.com"), shard("com"): suffix
Все файлы — в rule/manifest.json (files["index/…"], size + sha256). Качать изменившиеся
и подменять набор целиком: шарды из разных сборок вместе не годятся (номера могут сдвинуться) — набор годен, когда
sha256 каждого его файла совпал с одним и тем же rule/manifest.json.
Совместимость
blackmatrix7.txt—<!--DD.MM.YYYY-->, затем имена шаблонов bm7 верхнего уровня, у которых есть Clash-файл; CRLF.blackmatrix7+www.txt—<!--дата+ комментарии +-->, затем строкиName|CheckUrl|ClashUrl; ClashUrl — полный classical-список здесь.folders.txt— имена своих шаблонов; CRLF.
Дата в первой строке меняется только когда меняется список.
Источник
Шаблоны bm7 — blackmatrix7/ios_rule_script, лицензия — как в репозитории. Обновляется раз в сутки; если GitHub недоступен, остаётся прежнее зеркало.
Rule-set templates for Clash/Mihomo, Loon and Shadowrocket: a full mirror of blackmatrix7/ios_rule_script (master branch) plus byFox's own templates. A described catalog and a reverse "domain/IP → templates" index.
— templates, catalog of —, latest bm7 commit —.
Files hold conditions only, no policy — plain rule-sets. The client decides Direct, Block or Proxy.
Files
| Path | What |
|---|---|
manifest.json | catalog date, bm7 commit, sizes and sha256 of the files below |
templates.json (.gz) | catalog of all templates: descriptions, tags, stats, file paths |
index.json.gz | reverse index for search (~4 MB, ~100 MB in memory) |
index/ | the same index split in parts, so it need not be held in memory whole (below) |
bm7/<Clash|Loon|Shadowrocket>/<path>/<file> | bm7 mirrored as is: bm7/Clash/Telegram/Telegram.yaml |
byfox/<name>/{clash/rules.yaml, loon/rules.list, shadowrocket/rules.list} | our own templates |
blackmatrix7.txt, blackmatrix7+www.txt, folders.txt | legacy formats (built from the catalog) |
Moving off GitHub is a prefix swap:
raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/ →
api.byfox.dev/rule/bm7/. The rest of the path stays the same.
templates.json
{"date": "2026-11-03", "bm7_commit": "0b6897d…", "bm7_date": "2026-10-27",
"bm7_upstream": "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/",
"base": "rule/", "count": 703, "hidden": 1,
"items": [{
"id": "Apple", "src": "bm7", "name": "Apple",
"title": {"ru": "Apple: все сервисы", "en": "Apple: all services"},
"desc": {"ru": "…", "en": "…"},
"tags": ["icloud", "app store"], "category": "apple",
"check": "https://www.apple.com/",
"domain_set": true,
"stats": {"domains": 9, "suffixes": 1550, "keywords": 7, "cidr": 10, "cidr6": 3, "asn": 0, "other": 13},
"sample": ["apple.com", "appleid.com", "me.com", …],
"files": {"clash": "bm7/Clash/Apple/Apple_Domain.yaml", "loon": "bm7/Loon/Apple/Apple_Domain.list",
"shadowrocket": "bm7/Shadowrocket/Apple/Apple_Domain.list"},
"rest": {"clash": "bm7/Clash/Apple/Apple.yaml", …},
"classical": "bm7/Clash/Apple/Apple_Classical.yaml",
"updated": "2026-10-27"}]}
| Field | Meaning |
|---|---|
id | unique; for bm7 the folder path (Telegram, Cloud/AkamaiCloud), for ours the folder name (byfox/<name> if it clashes with bm7) |
src | bm7 or byfox |
title, desc | RU/EN; without a hand-written hint, title = name and desc = a stats summary |
category | ai, apple, google, microsoft, social, messenger, video, music, news, games, dev, cloud, cdn, ads, privacy, finance, crypto, shopping, tools, devices, education, torrent, cert, system, russia, china, china-bundle (bm7 bundles for users in mainland China), other |
check | a site to test whether the service works; none — null (never an empty string) |
files | main file per platform, relative to rule/. A platform may be missing |
domain_set | true — files are domain-sets (+.example.com/.example.com lines), not classical. True for 19 big bm7 templates (Apple, Advertising, China*, Global…) |
rest | domain-sets only: a classical file with what a domain-set cannot hold (keyword, IP, ASN). Use together with files |
classical | the full classical list for Clash in one file (for domain-sets, _Classical.yaml) |
generated | platforms missing upstream and generated here from another platform |
updated | date the template last changed (bm7: from git log) |
hidden | hidden templates only, true: do not offer it in a picker, but its files are served as usual — for clients that already use it. Not in the index or the legacy txt files. count includes hidden ones; how many — hidden at the top level |
How to use
Clash / Mihomo
rule-providers:
Telegram:
type: http
behavior: classical
format: yaml
url: https://api.byfox.dev/rule/bm7/Clash/Telegram/Telegram.yaml
interval: 86400
Apple: # domain_set: true
type: http
behavior: domain
format: yaml
url: https://api.byfox.dev/rule/bm7/Clash/Apple/Apple_Domain.yaml
interval: 86400
rules:
- RULE-SET,Telegram,PROXY
- RULE-SET,Apple,DIRECT
Shadowrocket
RULE-SET,https://api.byfox.dev/rule/bm7/Shadowrocket/Telegram/Telegram.list,PROXY
DOMAIN-SET,https://api.byfox.dev/rule/bm7/Shadowrocket/Apple/Apple_Domain.list,DIRECT
Loon
[Remote Rule]
https://api.byfox.dev/rule/bm7/Loon/Telegram/Telegram.list, policy=PROXY, tag=Telegram, enabled=true
index.json.gz — "who blocks this"
{"date": "2026-11-03", "ver": 1,
"ids": ["115", "12306", …], // number → template id; numbers everywhere below
"suffix": {"telegram.org": [290, 582]}, // DOMAIN-SUFFIX and +.x
"exact": {"openai-api.arkoselabs.com": [191, 468]}, // DOMAIN
"keyword": {"telegram": [290, 503, 504]},
"asn": {"62041": [582]},
"cidr": [["91.108.4.0/22", [583]], …], // sorted by network
"cidr6": [["2001:67c:4e8::/48", [290, 582, 583]], …],
"names": {"telegram": [582, 583, 584, 585]}} // name, tags, title words, category words RU/EN, lower case
For a domain a.b.example.com: look it up in exact, then in suffix for it and each
parent (b.example.com, example.com, com), then every keyword contained in the string.
For an IP: every cidr/cidr6 network that contains it. Join the numbers → ids.
names is for search by name: besides names and tags it holds category words in Russian and English
(нейросети, ии, соцсети, реклама, мессенджеры, видео…).
Hidden templates (hidden) are not in the index.
index/ — the index in parts
The same data as index.json.gz, laid out so a lookup reads only what it needs from disk.
Template numbers are the same as in ids.json.
| File | What |
|---|---|
index/ids.json | {"date", "ver": 1, "shards": 256, "ids": [...]} — number → id |
index/domain/<hh>.json.gz | {"suffix": {...}, "exact": {...}}; 256 files, hh is the first 2 hex chars of the key's sha1 (lower-case domain, UTF-8) |
index/keyword.json.gz | as keyword |
index/cidr.json.gz | {"cidr": [...], "cidr6": [...]}, sorted by network |
index/asn.json.gz, index/names.json.gz | as asn, names |
def shard(key): return hashlib.sha1(key.encode()).hexdigest()[:2]
# a.b.example.com → domain/shard("a.b.example.com"): exact + suffix,
# domain/shard("b.example.com"), shard("example.com"), shard("com"): suffix
Every file is in rule/manifest.json (files["index/…"], size + sha256). Download the changed ones
and swap the set as a whole: shards from different builds do not mix (numbers may shift) — the set is good when
every file's sha256 matches one and the same rule/manifest.json.
Compatibility
blackmatrix7.txt—<!--DD.MM.YYYY-->, then top-level bm7 template names that have a Clash file; CRLF.blackmatrix7+www.txt—<!--date+ comments +-->, thenName|CheckUrl|ClashUrllines; ClashUrl is the full classical list here.folders.txt— our own template names; CRLF.
The date in the first line changes only when the list changes.
Source
bm7 templates come from blackmatrix7/ios_rule_script, licensed as in that repository. Refreshed daily; if GitHub is unreachable, the previous mirror stays.