Compare commits
No commits in common. "main" and "core-v1.19.32-ts1" have entirely different histories.
main
...
core-v1.19
8
.gitignore
vendored
8
.gitignore
vendored
@ -3,16 +3,8 @@
|
||||
!tests/fixtures/*.env
|
||||
!presets/*.env
|
||||
*.ovpn
|
||||
!tests/fixtures/*.ovpn
|
||||
/configs/
|
||||
/reference/
|
||||
|
||||
.DS_Store
|
||||
__pycache__/
|
||||
tools/core/work/
|
||||
tools/core/dist/
|
||||
tools/nikki-work/
|
||||
|
||||
# Local agent notes
|
||||
/AGENTS.md
|
||||
/PROJECT_NOTES.md
|
||||
|
||||
732
README.md
732
README.md
@ -1,9 +1,8 @@
|
||||
# mihomo-kit
|
||||
|
||||
Конфиги mihomo из одного набора шаблонов: роутер под nikki (профили `main` — дома в России, `whitelist` — белые списки, `foreign` — за рубежом)
|
||||
и приложения на телефоне и компьютере (FlClash, Clash Mi и другие на ядре mihomo). Подписки через
|
||||
BOOT-ноду, `ru-inside` напрямую, остальные `.ru` через RU, опционально OpenVPN (рабочая или
|
||||
учебная сеть, с одноразовыми кодами TOTP или без) и Tailscale.
|
||||
Конфиги mihomo из одного набора шаблонов: роутер под nikki (профили «дом» и «улица»)
|
||||
и телефон (FlClash). Подписки через BOOT-ноду, `ru-inside` напрямую, остальные `.ru`
|
||||
через RU, опционально OpenVPN с TOTP и Tailscale.
|
||||
|
||||
## Установка на роутер
|
||||
|
||||
@ -21,47 +20,15 @@ ssh root@192.168.32.1 sh /etc/nikki/kit/install.sh
|
||||
```
|
||||
|
||||
Установщик ставит nikki (если нет), правильное ядро, фиксы и kit со страницей LuCI —
|
||||
ничего не спрашивает. Пакеты nikki берутся из релиза `nikki-<версия>` этого репозитория
|
||||
(зеркало релиза [OpenWrt-nikki](https://github.com/nikkinikki-org/OpenWrt-nikki/releases)),
|
||||
и только если там нет — с GitHub; зависимости — из обычных фидов OpenWrt. Нужна OpenWrt 24.10
|
||||
(opkg); 25.12 с apk пока не поддерживается.
|
||||
|
||||
Если роутер не достаёт ни до одного источника — на компьютере скачать архив под свой роутер
|
||||
(`nikki_<DISTRIB_ARCH>-openwrt-24.10.tar.gz`, арх — `grep DISTRIB_ARCH /etc/openwrt_release`;
|
||||
установщик сам печатает имя и ссылку), положить в `/tmp` роутера и запустить с `NIKKI_TGZ`:
|
||||
|
||||
```sh
|
||||
scp -O nikki_aarch64_cortex-a53-openwrt-24.10.tar.gz root@192.168.32.1:/tmp/
|
||||
ssh root@192.168.32.1 'NIKKI_TGZ=/tmp/nikki_aarch64_cortex-a53-openwrt-24.10.tar.gz sh /etc/nikki/kit/install.sh'
|
||||
```
|
||||
|
||||
Архив релиза nikki — это готовый подписанный фид: установщик распаковывает его в `/tmp`,
|
||||
временно подключает к opkg (подпись проверяется ключом nikki из kit,
|
||||
`router/nikki-key-build.pub`), ставит `mihomo-meta nikki luci-app-nikki luci-i18n-nikki-ru`
|
||||
и убирает фид. Не скачалось или не поставилось — установка останавливается с ошибкой. Дальше всё в браузере: LuCI → **Службы → mihomo-kit**
|
||||
ничего не спрашивает. Дальше всё в браузере: LuCI → **Службы → mihomo-kit → Настройка**
|
||||
(адрес установщик печатает в конце; если пункта нет — выйти из LuCI и войти снова).
|
||||
Страница разбита на вкладки по темам: «Обзор» (состояние, профиль), «Подписки» (подписки,
|
||||
vless-ссылки BOOT), «Правила» (торренты, пуши, свои домены и IP), «Свои серверы», «Пулы и
|
||||
сервисы», «OpenVPN», «Tailscale», «CSQTT», «Телефон», «Система» (облегчённый режим, ядро,
|
||||
обновления, экспорт). На вкладке сверху её состояние и кнопки, ниже настройки. Одна кнопка
|
||||
«Сохранить и применить» под вкладками сохраняет все вкладки разом: собирает профили `main`, `whitelist` и `foreign`,
|
||||
Там подписки, vless-ссылки BOOT, торренты, OpenVPN (файл `.ovpn`, логин, пароль,
|
||||
TOTP-секрет), Tailscale; «Сохранить и применить» собирает профили `home` и `street`,
|
||||
включает профиль и, если включён Tailscale, показывает ссылку для входа — открыть её,
|
||||
войти, в админке Tailscale **Disable key expiry** для ноды.
|
||||
|
||||
На новом роутере (ещё без настроек) установщик сразу настраивает nikki: перехват без TUN
|
||||
(TCP — redirect, UDP — tproxy, `tun_enabled=0`, как в облегчённом режиме) и IPv6 выключен
|
||||
везде (`mixin.ipv6`, `mixin.dns_ipv6`, `proxy.ipv6_dns_hijack`, `proxy.ipv6_proxy`). В форме
|
||||
торренты и обход для пушей по умолчанию выключены, а конфиг для телефона включён. Включение
|
||||
профиля (`use`, «Сохранить и применить») включает и nikki, в том числе автозапуск.
|
||||
|
||||
Маленькая флешка: opkg сравнивает свободное место с распакованным размером пакетов (у mihomo
|
||||
около 55 МБ), а сжимающий overlay (ubifs, jffs2) хранит их примерно в размере .ipk (около 20 МБ).
|
||||
Поэтому установщик сам считает место по .ipk и ставит с `--force-space`, а если места правда нет,
|
||||
останавливается до установки. Пакеты качаются в `/tmp`, весь вывод установки сохраняется в
|
||||
`/tmp/mihomo-kit-install.log`.
|
||||
|
||||
Позже настройки меняются там же; ключи, добавленные в
|
||||
`common.env` / `openvpn.env` руками, сохраняются.
|
||||
Позже настройки меняются там же — «Изменить настройки»; ключи, добавленные в
|
||||
`common.env` / `bmstu.env` руками, сохраняются.
|
||||
|
||||
Роутер без LuCI или вопросы в терминале по-старому:
|
||||
`wget -qO- …/install.sh | sh -s -- --cli` (или `mihomo-kit.sh setup --cli`).
|
||||
@ -74,193 +41,31 @@ vless-ссылки BOOT), «Правила» (торренты, пуши, сво
|
||||
## Каждый день
|
||||
|
||||
То же самое из веб-интерфейса: LuCI → **Службы → mihomo-kit**. Там переключение
|
||||
профиля, OpenVPN вкл/выкл/переподключить (с текущим кодом, если он нужен), ссылка для входа в Tailscale,
|
||||
профиля, OpenVPN вкл/выкл/переподключить с текущим OTP, ссылка для входа в Tailscale,
|
||||
пересборка, обновление kit и `fix`; вывод команды показывается внизу страницы.
|
||||
|
||||
Перенос настроек на другой роутер — «Экспорт настроек» там же: один файл `.kit` с
|
||||
профилями, подписками, BOOT, своими серверами и OpenVPN (с паролями и `.ovpn` — хранить
|
||||
как секрет). На другом роутере «Импорт настроек» заменяет его настройки и перезапускает
|
||||
профиль; галка «оставить имя ноды Tailscale и x-hwid» сохраняет `TS_HOSTNAME` и `HWID_ID`
|
||||
этого роутера, а `LOCAL_HOSTS` всегда остаётся свой. Выбор ядра, ключ ноды Tailscale и ссылка для телефона не переносятся.
|
||||
Из терминала: `mihomo-kit.sh export > file.kit`, `mihomo-kit.sh import file.kit --keep-local`.
|
||||
|
||||
Автообновление — «Включить автообновление» там же (или `mihomo-kit.sh auto-update on|off`):
|
||||
cron каждый день в 4:00 по времени роутера (часовой пояс — Система → Система) проверяет
|
||||
коммит на сервере; если он новее — скачивает kit, пересобирает профили, при смене версии
|
||||
ядра делает `fix` и перезапускает текущий профиль. Если kit уже свежий, а ядро не то, что он
|
||||
просит (релиз ядра выложен позже кита, скачивание не удалось), автообновление ставит ядро
|
||||
заново — только когда файл ядра доступен, чтобы не перезапускать nikki каждую ночь впустую.
|
||||
Явный `MIHOMO_VERSION=…` в `kit.env` закрепляет ядро, и тогда оно не обновляется. Журнал —
|
||||
`/etc/nikki/kit/auto-update.log`, последняя строка видна на странице.
|
||||
ядра делает `fix` и перезапускает текущий профиль. Журнал — `/etc/nikki/kit/auto-update.log`,
|
||||
последняя строка видна на странице.
|
||||
|
||||
```sh
|
||||
mihomo-kit.sh use whitelist # попал на белые списки
|
||||
mihomo-kit.sh use main # обычный интернет в России
|
||||
mihomo-kit.sh use foreign # за рубежом: российское через RU, остальное напрямую
|
||||
mihomo-kit.sh use street # уехал на белые списки
|
||||
mihomo-kit.sh use home # вернулся
|
||||
|
||||
ovpn.sh off # OpenVPN выключить: освободить сессию для другого устройства
|
||||
ovpn.sh on # включить постоянно
|
||||
ovpn.sh sched on # работать по расписанию; sched off — выключить (как off)
|
||||
ovpn.sh sched 09:00 17:00 # запомнить часы расписания (время роутера), включает их sched on
|
||||
ovpn.sh sched 09:00 17:00 weekdays # то же, только по будням (дни: 12345, weekend, all)
|
||||
ovpn.sh sched days 12345 # поменять только дни (1 — пн … 7 — вс)
|
||||
ovpn.sh for 60 # поднять на 60 минут поверх режима, потом вернуть режим
|
||||
ovpn.sh extend 60 # продлить таймер на 60 минут (не дальше 12 ч от сейчас)
|
||||
ovpn.sh stop # остановить таймер
|
||||
ovpn.sh status # что решает сейчас, когда следующее переключение, отвечает ли туннель
|
||||
bmstu-otp.sh off # OpenVPN выключить: освободить сессию для другого устройства
|
||||
bmstu-otp.sh on # включить обратно
|
||||
bmstu-otp.sh status
|
||||
```
|
||||
|
||||
Эти же кнопки и часы расписания есть на странице LuCI (Службы → mihomo-kit). Там же видно,
|
||||
что решает сейчас («включён по расписанию», «выключен вручную», «включён таймером до 15:30»)
|
||||
и что будет дальше («выключится сегодня в 17:06», «потом снова действует ручное „Выключить“»).
|
||||
На сервере BMSTU одна сессия на пользователя. `off` закрывает туннель в mihomo и не даёт
|
||||
cron поднять его снова; трафик в сети BMSTU идёт без туннеля (дома напрямую, на улице через
|
||||
`OVPN-EXIT`) — публичные ресурсы открываются, внутренние (`172.x`) нет. mihomo не отправляет
|
||||
серверу EXIT, поэтому сервер держит старую сессию до своего `ping-restart` — до ~5 минут,
|
||||
потом можно подключаться с другого устройства.
|
||||
|
||||
Режим всегда один из трёх, у каждого своя кнопка:
|
||||
- «Включить» — туннель включён постоянно;
|
||||
- «Выключить» — выключен и сам не включится;
|
||||
- «Включить расписание» — включён только в часы и дни расписания. «Выключить расписание»
|
||||
переводит в «Выключено». Выключенное расписание туннель не включает; «Сохранить» у часов
|
||||
только запоминает их.
|
||||
|
||||
«Включить» и «Выключить» снимают расписание и таймер. Таймер («Включить на 1 ч», потом
|
||||
«+1 ч», не дальше 12 ч от текущего момента — `TIMER_MAX`) поднимает туннель поверх любого
|
||||
режима, а когда истекает или по «Остановить таймер», возвращает режим. Так можно держать
|
||||
OpenVPN выключенным и включать его только на время, не трогая расписание.
|
||||
|
||||
Дни недели — галки Пн…Вс рядом с расписанием (`OVPN_SCHED_DAYS` в `openvpn.env`, по умолчанию
|
||||
все); окно через полночь относится ко дню, в который началось: «22:00–02:00 по будням» работает и
|
||||
в ночь с пятницы на субботу, но не с воскресенья на понедельник.
|
||||
|
||||
Время — локальное на роутере (Система → Система → часовой пояс). Границы окна каждый день сдвигаются на случайные, но
|
||||
постоянные в течение дня ±10 минут (`OVPN_SCHED_JITTER`), чтобы включение и выключение не
|
||||
приходились каждый раз на одну и ту же секунду. Поэтому окно короче 20 минут (или длиннее
|
||||
23 ч 40 мин) не принимается. Сети VPN (`OVPN_ROUTES`) следуют за туннелем: пока он
|
||||
выключен по любой причине, они убраны.
|
||||
|
||||
Многие VPN-серверы пускают только одну сессию на пользователя. `off` закрывает туннель в
|
||||
mihomo и не даёт cron поднять его снова, и убирает его сети (`OVPN_ROUTES`) из
|
||||
маршрутизации: они лежат в rule-provider `openvpn-routes`, который `off` очищает, а `on`
|
||||
возвращает, без перезапуска nikki. Эти адреса тогда идут по обычным правилам, как любые
|
||||
другие сайты: публичные открываются, внутренние — нет. Ядро kit при закрытии туннеля
|
||||
отправляет серверу EXIT, как OpenVPN Connect, и сессия освобождается за секунды — можно сразу
|
||||
подключаться с другого устройства. С другим ядром EXIT не уходит, и сервер держит сессию до
|
||||
своего `ping-restart` (~5 минут).
|
||||
|
||||
На `whitelist` и `foreign` OpenVPN идёт через группу `OVPN-EXIT` — один раз выбрать в
|
||||
дашборде RU-ноду (рассчитано на VPN-сервер в России).
|
||||
|
||||
### OpenVPN
|
||||
|
||||
LuCI → вкладка «OpenVPN» → галка «Включить OpenVPN»:
|
||||
- **Файл .ovpn** — профиль, который выдал администратор VPN (тот же, что для OpenVPN Connect
|
||||
или openvpn). Сервер берётся из его строк `remote`.
|
||||
- **Логин** и **пароль** — обычный пароль, без одноразового кода.
|
||||
- **Сети через VPN** — адреса, которые открываются только через VPN (CIDR через пробел). При
|
||||
загрузке `.ovpn` сюда подставляются его строки `route`; остальной трафик идёт как обычно.
|
||||
- **TOTP-секрет** — только если VPN просит одноразовый код из приложения (Google
|
||||
Authenticator и т. п.): секрет из QR-кода, строка из букв и цифр (`secret=…` в ссылке
|
||||
`otpauth://`). Роутер сам считает код и подставляет его при каждом подключении. Без секрета
|
||||
пароль уходит как есть.
|
||||
- **Как отправлять код** — «сам» подходит обычно: если в `.ovpn` есть `static-challenge`,
|
||||
код уходит отдельным полем (как у OpenVPN Connect), иначе — сразу за паролем. Если сервер не
|
||||
принимает код, попробовать другие варианты (`PASS_FORMAT` в `openvpn.env`).
|
||||
- **Адрес для проверки** — страница за VPN для кнопки «Проверить».
|
||||
|
||||
Файлы на роутере: `/etc/nikki/openvpn.ovpn`, `/etc/nikki/openvpn.env` (логин, пароль, секрет,
|
||||
600). Группа в дашборде — `OPENVPN`.
|
||||
|
||||
Обновление со старых версий kit (там OpenVPN был только для BMSTU и файлы назывались
|
||||
`bmstu.*`) переносит всё само: `bmstu.env` / `bmstu.ovpn` → `openvpn.env` / `openvpn.ovpn`,
|
||||
строки cron и init-скрипта nikki — на `ovpn.sh`, а сети, адреса сервера и адрес проверки,
|
||||
которые раньше были зашиты в kit, записываются в `common.env`. Старая команда `bmstu-otp.sh`
|
||||
работает как ссылка на `ovpn.sh`. Старые файлы экспорта импортируются так же.
|
||||
|
||||
### Граф
|
||||
|
||||
LuCI → **Службы → mihomo-kit → Граф** — собранный профиль картинкой, слева направо:
|
||||
правила (сверху вниз — в порядке, в котором mihomo их проверяет) → группы → подписки и
|
||||
свои серверы → через что они подключаются → выходы. Выходы — последняя колонка: `DIRECT`
|
||||
и прокси `type: direct` (`CSQTT`, интерфейс `csqtt0`). Фиолетовый пунктир — `dialer-proxy`,
|
||||
серый — к серверу напрямую (у прокси и подписки нет `dialer-proxy`: Tailscale и OpenVPN на
|
||||
`main`). Зелёный — через что качается подписка (`proxy:` провайдера, обычно `BOOT-AUTO`) и
|
||||
`<имя>-my`, читающий файл основной подписки. То, куда правила не ведут (`BOOT-AUTO`, `BOOT`,
|
||||
seed-ноды), — под чертой «служебное». Правило в `DIRECT`/`REJECT` заканчивается на самом
|
||||
правиле. Фильтры групп (`∋` filter, `∌` exclude-filter) видны на рёбрах при наведении;
|
||||
⛶ — на весь экран.
|
||||
|
||||
Для запущенного профиля поверх схемы — живое состояние из API mihomo (раз в 3 секунды,
|
||||
пока вкладка открыта): что выбрано в каждой группе сейчас (синее) с задержкой, сколько нод
|
||||
подписки живы, и куда идут соединения (оранжевое, с числом на узлах) — по `chains`
|
||||
соединения и дальше по цепочке `dialer-proxy`. Наведи или нажми на узел — подсветится всё,
|
||||
что в него приходит и что из него выходит, снизу — подробности и «путь сейчас». «Только
|
||||
выбранное» прячет невыбранные пункты групп. Другие профили (`whitelist`, `foreign`) — из
|
||||
списка, без живого состояния.
|
||||
|
||||
Править на графе (запущенный профиль):
|
||||
- нажать на группу — справа её пункты с последней задержкой: выбрать (`select`) или закрепить
|
||||
(`fallback` / `url-test`, «Снять закрепление» возвращает автовыбор), «Проверить задержки» —
|
||||
все пункты разом. Сразу через API mihomo, без пересборки; выбор запоминается и переживает
|
||||
перезапуск (`cache.db`), до следующей смены в дашборде;
|
||||
- сервисы и пулы: «+ сервис» (есть «как Claude»), «+ пул» или нажать на группу сервиса / пула;
|
||||
«через что» у сервиса можно и перетащить от его группы на MY / FOREIGN / RU / MAIN / DIRECT /
|
||||
пул. «Сохранить и применить» меняет в `common.env` только `SERVICES`/`SVC_*` и
|
||||
`POOLS`/`POOL_*` (`mihomo-kit.sh services`), проверяет, что все профили собираются, и
|
||||
перезапускает текущий. Это те же ключи, что на «Управлении»: где удобнее, там и правь.
|
||||
|
||||
Без роутера: [tools/graph.html](tools/graph.html) из репозитория открыть в браузере и выбрать
|
||||
или перетащить любой конфиг mihomo. Для живого состояния — адрес API и secret (они в ссылке
|
||||
«открыть дашборд»).
|
||||
|
||||
### OpenVPN под видом OpenVPN Connect
|
||||
|
||||
Для VPN-сервера роутер выглядит как OpenVPN Connect 3.7.1 (5558) на macOS. Обычный
|
||||
mihomo представляется сам (`IV_VER=mihomo-openvpn`, `IV_PROTO=22`, своя строка опций), и в
|
||||
логах сервера это видно. Маскировку дают ядро kit (правка
|
||||
`tools/core/openvpn-connect-mimic.patch`) и `ovpn.sh`, который пишет в провайдер
|
||||
поля `options-string` и `peer-info-raw`.
|
||||
|
||||
Совпадает с Connect:
|
||||
- строка опций (`V4,dev-type tun,link-mtu 1541,…,cipher BF-CBC,auth SHA1,…`) и peer-info
|
||||
(`IV_VER=3.11.1`, `IV_PLAT=mac`, `IV_PROTO=8094`, `IV_GUI_VER=OCmacOS_3.7.1-5558`, …) —
|
||||
те же строки в том же порядке, что в логе Connect;
|
||||
- протокол: в ответ на `IV_PROTO=8094` сервер включает `tls-ekm` (ключи из TLS-экспортёра),
|
||||
`dyn-tls-crypt` (свой tls-crypt-ключ для rekey) и `aead-epoch` (формат данных OpenVPN 2.7),
|
||||
и ядро kit их поддерживает. Ещё 8094 объявляет `AUTH_FAIL_TEMP` (временный отказ — ядро
|
||||
повторяет позже, а не считает пароль отклонённым), `DNS_OPTION_V2` (DNS из `dns server …`
|
||||
ядро берёт так же, как из `dhcp-option DNS`), `AUTH_PENDING_KW` и `PUSH_UPDATE` (сообщения,
|
||||
которые ядро пропускает);
|
||||
- код TOTP в формате `SCRV1`, как отправляет Connect при `static-challenge`;
|
||||
- `ping 60`, `ping-restart 300` — то, что обычно присылает сервер;
|
||||
- туннель держится всё время, как у Connect (`auto-connect` у прокси). Он поднимается сразу
|
||||
при загрузке провайдера, без ожидания трафика: init-скрипт nikki перед стартом mihomo
|
||||
пишет провайдер со свежим кодом (`ovpn.sh write`). После обрыва ядро переподключается
|
||||
само, с auth-token сессии вместо пароля и кода. Если сервер токен не принял (AUTH_FAILED),
|
||||
ядро больше не пробует — как Connect, который тогда просит новый код, — и туннель
|
||||
поднимает cron (`ovpn.sh check`) со свежим кодом;
|
||||
- быстрых переподключений нет: некоторые серверы на моментальный реконнект после обрыва
|
||||
или кика отвечают блокировкой учётки. После любого обрыва (в том числе молчаливого), неудачной
|
||||
попытки или отказа в авторизации ядро ждёт `OVPN_RECONNECT_PAUSE` секунд (по умолчанию
|
||||
120). Пауза удваивается, пока попытки не удаются или туннель падает раньше чем через 5
|
||||
минут после подъёма, но не больше 10 минут. Если сессию закрыл сам сервер (RESTART/HALT —
|
||||
например, админ кикнул клиента), пауза своя — `OVPN_KICK_PAUSE` (по умолчанию как
|
||||
`OVPN_RECONNECT_PAUSE`). Она удваивается за каждый кик подряд, до 30 минут; сессия,
|
||||
продержавшаяся 30 минут, сбрасывает счёт. К каждой паузе добавляется случайный разброс
|
||||
±`OVPN_RECONNECT_JITTER` секунд (по умолчанию 30), чтобы попытки не шли по часам. Пауза
|
||||
переживает перезагрузку провайдера и конфига, и трафик в сети VPN в это время туннель не
|
||||
поднимает. Новый код cron в паузе не берёт, кнопки LuCI тоже не переподключают; в
|
||||
«Состоянии» видны причина (оборвался, не подключился, сервер отключил) и время следующей
|
||||
попытки;
|
||||
- при закрытии (`off`, перезапуск nikki, новый провайдер) сервер получает EXIT
|
||||
(`cc-exit`) и сразу освобождает сессию.
|
||||
|
||||
Отличается только TLS-рукопожатие управляющего канала: его делает Go (`crypto/tls`), а не
|
||||
OpenSSL, поэтому набор шифров и расширений в ClientHello другой (JA3/JA4). Это видно при
|
||||
разборе трафика, в логах сервера — нет.
|
||||
|
||||
Без ядра kit (`stock`, `official`) эти поля игнорируются, и сервер снова видит mihomo.
|
||||
Выключить маскировку: `OVPN_MIMIC=mihomo` в `openvpn.env`. После обновления Connect — взять
|
||||
новые строки `Tunnel Options` и `Sending Peer Info` из его лога
|
||||
(`~/Library/Application Support/OpenVPN Connect/log/ovpn.log`) и поправить
|
||||
`mimic_connect_mac` в `router/ovpn.sh`.
|
||||
На «улице» OpenVPN идёт через группу `OVPN-EXIT` — один раз выбрать в дашборде RU-ноду.
|
||||
|
||||
## Обслуживание
|
||||
|
||||
@ -276,9 +81,9 @@ mihomo-kit.sh build # после правки /etc/nikki/profiles.d/*.
|
||||
|---|---|
|
||||
| `/etc/nikki/kit/` | кит: шаблоны, пресеты, скрипты |
|
||||
| `/etc/nikki/profiles.d/common.env` | подписки, BOOT, модули (секреты, 600) |
|
||||
| `/etc/nikki/profiles.d/main.env`, `whitelist.env` | профили поверх common.env |
|
||||
| `/etc/nikki/profiles.d/home.env`, `street.env` | профили поверх common.env |
|
||||
| `/etc/nikki/profiles/*.yaml` | собранные конфиги, их запускает nikki |
|
||||
| `/etc/nikki/openvpn.env`, `openvpn.ovpn` | OpenVPN: логин, пароль, TOTP-секрет; профиль `.ovpn` |
|
||||
| `/etc/nikki/bmstu.env`, `bmstu.ovpn` | OpenVPN: логин, пароль, TOTP-секрет |
|
||||
| `/etc/nikki/run/tailscale/` | ключ ноды Tailscale — не удалять |
|
||||
|
||||
У каждой подписки есть имя — так называется провайдер в дашборде, и к нему привязаны
|
||||
@ -298,235 +103,32 @@ x-device-os, x-ver-os, x-device-model, x-hwid). Выключить, не уда
|
||||
BOOT — whitelisted seed-ноды для скачивания подписок: в форме vless-ссылки по одной на
|
||||
строку (`BOOT_LINKS` в `common.env`; старые `BOOT_SERVER`/`_PBK`/… читаются как одна
|
||||
нода). Из них собираются `seed`, `seed2`, …, группа `BOOT` (fallback) берёт первую живую.
|
||||
`BOOT-AUTO` — то, через что подписки качаются по умолчанию (и без BOOT тоже): `BOOT`, если
|
||||
ни одна seed не отвечает или BOOT не задан — ноды уже скачанных подписок (mihomo хранит их в
|
||||
`BOOT-AUTO` — то, через что подписки качаются по умолчанию: `BOOT`, если ни одна seed не
|
||||
отвечает — ноды уже скачанных подписок (mihomo хранит их в
|
||||
`/etc/nikki/run/providers/<имя>.yaml` и загружает при старте), в последнюю очередь напрямую.
|
||||
|
||||
Пуши (Apple `*.push.apple.com` и подсети 17.x, Google FCM `mtalk.google.com`, порты
|
||||
5228–5230) идут через группу `PUSH`: на `main` по умолчанию `DIRECT`, на `whitelist` — `MY`
|
||||
5228–5230) идут через группу `PUSH`: на `home` по умолчанию `DIRECT`, на `street` — `MY`
|
||||
(без своих серверов — `FOREIGN`); переключается в дашборде. Долгое соединение пушей
|
||||
рвётся, когда меняется нода под ним, — отсюда пропадающие уведомления. Отключается
|
||||
галочкой «Обход для пушей» (`PUSH=0` в `common.env`) — тогда пуши идут по общим правилам.
|
||||
рвётся, когда меняется нода под ним, — отсюда пропадающие уведомления.
|
||||
|
||||
Сервисы — сайты и приложения, которые всегда идут своим путём, что бы ни было выбрано в
|
||||
`MAIN`: LuCI → вкладка «Пулы и сервисы» (кнопка «+ Claude» добавляет готовый). У каждого
|
||||
сервиса своя группа в дашборде (имя заглавными: `claude` → `CLAUDE`) и свои правила —
|
||||
выше «Своих правил», ниже туннелей, локальной сети и пушей. Чем матчить: списки geosite из
|
||||
[MetaCubeX/meta-rules-dat](https://github.com/MetaCubeX/meta-rules-dat) (`anthropic` —
|
||||
claude.ai, claude.com, anthropic.com, clau.de, claudeusercontent.com…; `openai`, `youtube`, …
|
||||
— rule-provider `geosite-<имя>`, раз в сутки с jsdelivr), свои домены и IP. Куда:
|
||||
- `MY` (по умолчанию) — группа `fallback` из своих серверов и `[MY]`-нод подписок: первый
|
||||
живой, а не самый быстрый, как в `MY`. Выходной IP не скачет между серверами, пока сервер
|
||||
жив, — сайт, который проверяет регион (Claude), видит одну страну. Другой сервер — выбрать
|
||||
в дашборде, выбор запоминается. Если все свои серверы лежат, сервис не открывается, а не
|
||||
уходит в `FOREIGN`. На `whitelist` и телефоне к своим серверам — через `MY-EXIT`, как всегда:
|
||||
клиент → `CLAUDE` → свой сервер → `MY-EXIT` → нода подписки;
|
||||
- `FOREIGN`, `RU`, `DIRECT`, `MAIN` или пул (ниже) — группа `select`, где это первый пункт, а
|
||||
остальные можно выбрать в дашборде.
|
||||
|
||||
Списки доменов из файлов — поле «Списки доменов» (`SVC_<ИМЯ>_HOSTLIST`, пути через пробел): по
|
||||
домену в строке, как хостлисты zapret. Если на роутере стоит zapret2 / zapret, под полем есть
|
||||
кнопки с его списками из `/opt/zapret2/ipset/` и `/opt/zapret/ipset/` (без `*exclude*`): нажал —
|
||||
файл добавлен, ещё раз — убран. Копировать ничего не нужно: файл читается при каждой сборке
|
||||
профиля (поменялся список в zapret — «Применить»), домены уходят в inline rule-provider
|
||||
`hostlist-<имя>` (`behavior: domain`, поиск по дереву — тысячи доменов не тормозят правила) и
|
||||
попадают и в конфиг телефона. Как в zapret: `youtube.com` — с поддоменами, `^youtube.com` —
|
||||
только он сам; `#`-комментарии, IP и мусор пропускаются, `.gz` читается. Файла нет — сборка
|
||||
предупреждает и идёт дальше без него.
|
||||
|
||||
Чтобы сервис сохранял **один конкретный выходной сервер** при смене main/whitelist/foreign,
|
||||
на графе откройте сервис → «Выход сервиса» → «Фиксированный сервер». Выберите источник
|
||||
(«Свои серверы» или конкретную подписку) и имя из подсказок, затем «Сохранить и применить».
|
||||
Имя можно ввести вручную, если подписка ещё не загружена. Это постоянная настройка сервиса,
|
||||
а не закрепление через API: она переносится экспортом и действует также в конфиге телефона.
|
||||
В обычной форме «Сервисы» те же поля называются «Фиксированный сервер» и «Источник сервера».
|
||||
|
||||
В env это `SVC_<ИМЯ>_SERVER="точное имя"` и `SVC_<ИМЯ>_PROVIDER="id-my"` (пустой PROVIDER —
|
||||
свой сервер из настроек). VIA при фиксированном сервере не выбирает выход. Kit создаёт
|
||||
внутренний односерверный пул `SVC-FIXED-<ИМЯ>`; сервис имеет только этот путь. Внутренние
|
||||
пулы не нужно создавать вручную. Для подписки имя сопоставляется точно, включая эмодзи,
|
||||
скобки и регистр, только в указанном провайдере. Если ноду переименовали, удалили или
|
||||
подписка выключена, сервис закрывается через REJECT; на другую ноду или DIRECT он не
|
||||
переключается. Недоступность самой ноды тоже не меняет выходной сервер.
|
||||
|
||||
«Вход» (CHAIN) по-прежнему задаёт путь подключения к выбранному серверу. С «как обычно»
|
||||
свои серверы и [MY]-ноды на whitelist и телефоне доступны через MY-EXIT, а на main —
|
||||
напрямую либо через UPLINK. Для обычных нод подписки сохраняется путь их провайдера.
|
||||
Перетаскивание сервиса на группу в графе возвращает режим группы после сохранения.
|
||||
|
||||
Пулы — свои наборы серверов: LuCI → вкладка «Пулы и сервисы» или «+ пул» на графе. У пула своя
|
||||
группа (имя заглавными: `de` → `DE`), и сервис можно пустить через неё — тогда выход сервиса
|
||||
задан настройками, а не выбором в дашборде, и одинаков на роутере и телефоне (закрепление в
|
||||
дашборде живёт только в `cache.db` своего устройства). В пул входят:
|
||||
- свои серверы — галками (по имени);
|
||||
- ноды подписок — отметить подписку (`sam_hub` — её ноды без `[MY]`, `sam_hub-my` — только
|
||||
`[MY]`) и задать фильтр по имени ноды: `filter` / `exclude-filter` mihomo, регулярное
|
||||
выражение (`\[WL\]` — метка в своей подписке, `(?i)🇩🇪|\bde\b` — страна в чужой; несколько
|
||||
через `` ` ``; пусто — все ноды). К своим серверам фильтр не применяется.
|
||||
|
||||
Как выбирать: первый живой (`fallback`, по умолчанию), самый быстрый (`url-test`) или вручную
|
||||
(`select`). Встроенные группы (`MY`, `FOREIGN`, `MY-EXIT`, …) от пулов не меняются: пока пулов нет,
|
||||
профили собираются как раньше. Если из пула всё пропало (сервер переименован, подписка
|
||||
выключена), он собирается с `REJECT` — его сервисы закрыты, а не идут мимо, — и сборка пишет
|
||||
предупреждение. Пул, через который идёт сервис, не удалить, пока сервис не переключён.
|
||||
|
||||
Цепочки — когда до выхода надо добираться через что-то ещё:
|
||||
- **вход сервиса** («Вход» у сервиса, `SVC_<ИМЯ>_CHAIN`): выход — MY или пул, вход — DIRECT,
|
||||
FOREIGN, RU, MY, MY-EXIT или другой пул. Например, OpenAI выходит с IP своего сервера из пула
|
||||
`DE`, а к самому серверу подключается через пул `WL`: клиент → `OPENAI` → `DE ⟶ WL` →
|
||||
`de-1 ⟶ WL` → `WL` → наружу. Без входа — как обычно: на whitelist и телефоне свои серверы
|
||||
и так идут через `MY-EXIT`;
|
||||
- **пул в UPLINK** (галка «В UPLINK» у пула, `POOL_<ИМЯ>_UPLINK=1`): в группе `UPLINK` появляется
|
||||
пункт `<ПУЛ> ⟶ DIRECT`; выбрать его (граф, дашборд) — и ноды подписок, BOOT и свои серверы
|
||||
сначала идут через пул, а дальше как обычно (выход из блокировок). Серверы самого пула туда
|
||||
подключаются напрямую, иначе была бы петля. По умолчанию в `UPLINK` выбран `DIRECT`; выбор,
|
||||
как у любой группы, хранится в `cache.db` роутера.
|
||||
|
||||
mihomo строит цепочку только через `dialer-proxy` самой прокси, поэтому kit делает копии:
|
||||
свои серверы — `<сервер> ⟶ <вход>`, ноды подписок — file-провайдер `<подписка>@<вход>` на тот
|
||||
же скачанный файл (второго скачивания нет; на телефоне — да, как у `<имя>-my`), группа
|
||||
`<ПУЛ> ⟶ <вход>`. На графе это видно отдельной веткой.
|
||||
|
||||
В `common.env`:
|
||||
|
||||
```sh
|
||||
SERVICES="claude"
|
||||
SVC_CLAUDE_GEOSITE="anthropic" # через пробел, если списков несколько
|
||||
SVC_CLAUDE_DOMAINS="" # ещё домены (с поддоменами)
|
||||
SVC_CLAUDE_IPS="" # ещё IP / подсети
|
||||
SVC_CLAUDE_HOSTLIST="" # файлы со списками доменов (хостлисты zapret), через пробел
|
||||
SVC_CLAUDE_VIA=MY # MY | FOREIGN | RU | DIRECT | MAIN | пул (DE)
|
||||
SVC_CLAUDE_CHAIN="" # вход для MY / пула: DIRECT | FOREIGN | RU | MY | MY-EXIT | пул
|
||||
|
||||
POOLS="de"
|
||||
POOL_DE_TYPE=fallback # fallback | url-test | select
|
||||
POOL_DE_SERVERS="de-1; nl-2" # свои серверы по имени, через ;
|
||||
POOL_DE_SUBS="sam_hub sam_hub-my" # подписки (<id> без [MY], <id>-my — только [MY])
|
||||
POOL_DE_FILTER='(?i)🇩🇪|\bde\b' # по имени ноды подписки
|
||||
POOL_DE_EXCLUDE='(?i)torrent'
|
||||
POOL_DE_UPLINK=1 # предлагать в UPLINK
|
||||
```
|
||||
|
||||
Сервисы попадают и в конфиг телефона. Правила по доменам не работают для трафика, который
|
||||
спрашивает DNS в обход роутера («Безопасный DNS» в браузере) — см. ниже про ECH и DoH.
|
||||
|
||||
Свои серверы — LuCI → вкладка «Свои серверы». Каждый сервер — карточка: имя (так он
|
||||
виден в дашборде), тип и адрес, «Настройки (YAML)» — весь сервер в формате mihomo, правится
|
||||
на месте. «Добавить из ссылки / YAML» принимает сразу несколько: ссылки `vless://`, `vmess://`,
|
||||
`trojan://`, `ss://`, `hysteria2://`, `tuic://`, `anytls://` (и `socks5://`, `http(s)://`,
|
||||
`ssr://`, `hysteria://`, `mierus://`), подписку в base64 или YAML из конфига mihomo / Clash
|
||||
(список `proxies:`, просто список или один сервер). Ссылки страница разбирает так же, как
|
||||
mihomo разбирает подписку (`luci/servers.js` — перенос его `common/convert`, `tools/test.sh`
|
||||
сверяет с ним): reality, xhttp, ws, grpc и прочее — как в приложении. «Скопировать» отдаёт
|
||||
сервер как YAML для другого роутера.
|
||||
|
||||
«Вход» в карточке — через что подключаться к самому серверу. «Как обычно» — как остальные
|
||||
свои серверы: на `main` напрямую, на `whitelist` и телефоне через `MY-EXIT`, с CSQTT через
|
||||
`UPLINK`. «Через FOREIGN», «через RU», «напрямую» или «через пул» действует только для этого
|
||||
сервера и во всех профилях и в конфиге телефона: например, сервер, до которого напрямую не
|
||||
достучаться, идёт через ноды FOREIGN, а остальные свои серверы — как раньше. Хранится как
|
||||
`dialer-proxy` в строке сервера (`/etc/nikki/my-servers`); `dialer-proxy`, вписанный в
|
||||
«Настройки (YAML)», становится тем же «Входом». Пул, в который сервер входит сам, как вход
|
||||
нельзя — это петля.
|
||||
|
||||
Тот же «Вход» есть у серверов, которые лежат в своей подписке с `[MY]` в имени: блок «Из
|
||||
подписок ([MY])» на той же вкладке. Их список страница берёт из работающего mihomo (nikki не
|
||||
запущен — видны только ноды, у которых вход уже задан). Нода с входом уходит из провайдера
|
||||
`<подписка>-my` в `<подписка>-my-via-<вход>`: тот же файл подписки (на телефоне — ещё одна
|
||||
загрузка), только эти ноды, `dialer-proxy` = вход. Он стоит везде, где `<подписка>-my`: в MY,
|
||||
пулах, сервисах. В `common.env` это `MY_NODE_1='FOREIGN|<подписка>-my|<точное имя>'`,
|
||||
`MY_NODE_2=…`. Ноду ищут по точному имени: переименовали в подписке — вход перестаёт
|
||||
действовать, нода снова идёт как остальные `[MY]`.
|
||||
|
||||
AmneziaWG: туда же вставляется ключ AmneziaVPN `vpn://…` («Поделиться» в приложении; файл
|
||||
`.vpn` тоже можно выбрать) или `.conf` AmneziaWG / обычного WireGuard (текст `[Interface]` …
|
||||
`[Peer]` … или файл — тогда сервер называется по имени файла). Получается сервер
|
||||
`type: wireguard` с `amnezia-wg-option` (AmneziaWG 1.0 / 1.5 / 2.0 / 3 — параметры как в
|
||||
конфиге; без Jc/H1/… — обычный WireGuard) в упрощённом виде mihomo, с одним `[Peer]`;
|
||||
`AllowedIPs` и `DNS` не переносятся — что куда идёт, решают правила kit. Из ключа берутся
|
||||
только контейнеры AmneziaWG / WireGuard (Xray — его `vless://`-ссылкой), ключи Amnezia
|
||||
Free / Premium не подходят: в них нет сервера. WireGuard — это UDP: на `whitelist` и с
|
||||
телефона он идёт через `MY-EXIT`, поэтому нода там должна пропускать UDP (hysteria2, tuic,
|
||||
ss, vless/trojan с UDP); на телефоне нужно ядро FlClash с поддержкой AmneziaWG.
|
||||
|
||||
Серверы хранятся в `/etc/nikki/my-servers` (права 600, по одному JSON-объекту прокси на
|
||||
строку) и переносятся экспортом настроек. Сборка вписывает их в `proxies:` профилей роутера
|
||||
и в конфиг телефона и собирает в группу `MY` (url-test: самый быстрый живой; в дашборде
|
||||
Свои серверы hysteria2 — LuCI → Настройка → «Свои серверы» (или `HY2="имя1 имя2"` и
|
||||
`HY2_<ИМЯ>_SERVER/_PORT/_PASSWORD/_OBFS_PASSWORD/_SNI/_INSECURE/_UP/_DOWN` в
|
||||
`common.env`). Они собираются в группу `MY` (url-test: самый быстрый живой; в дашборде
|
||||
можно закрепить конкретный). `MY` — пункт в `MAIN` рядом с `FOREIGN` (переключать
|
||||
вручную). К самим серверам на `whitelist` и с телефона подключение через группу `MY-EXIT`
|
||||
(те же ноды, что в `FOREIGN`, но с `tolerance: 300`: меняет ноду, только если текущая
|
||||
заметно хуже или умерла — каждая смена рвёт всё, что идёт через `MY`), на `main` —
|
||||
напрямую, с CSQTT — через `UPLINK`. `dialer-proxy` из YAML сервера отбрасывается: его ставит kit.
|
||||
вручную). К самим серверам на `street` подключение через группу `MY-EXIT` (те же ноды,
|
||||
что в `FOREIGN`, но с `tolerance: 300`: меняет ноду, только если текущая заметно хуже или
|
||||
умерла — каждая смена рвёт всё, что идёт через `MY`), на `home` — напрямую.
|
||||
|
||||
Старые настройки по-прежнему собираются: hysteria2 по полям (`HY2="имя1 имя2"` и
|
||||
`HY2_<ИМЯ>_SERVER/_PORT/_PASSWORD/_OBFS_PASSWORD/_SNI/_INSECURE/_UP/_DOWN` в `common.env`) и
|
||||
ссылки `MY_LINKS` (только роутер, провайдер `my-links`). Страница показывает их карточками и
|
||||
при сохранении переносит в `my-servers`.
|
||||
|
||||
Свои серверы можно держать и в своей подписке: ноды, в имени которых есть `[MY]`
|
||||
(`[MY] 🇩🇪 de-1`, регистр не важен), из любой подписки сами попадают в `MY`, а не в `RU` /
|
||||
`FOREIGN` / `TORRENT`. Поменял адрес сервера в подписке — роутеры подхватят при
|
||||
обновлении провайдера (раз в час или кнопкой в дашборде). Устроено так: основной
|
||||
провайдер `<имя>` такие ноды отбрасывает, а рядом file-провайдер `<имя>-my` читает тот же
|
||||
скачанный файл `providers/<имя>.yaml` (mihomo следит за ним, второго скачивания нет) и берёт
|
||||
только их (на телефоне FlClash переносит файлы провайдеров к себе, поэтому там `<имя>-my`
|
||||
качает ту же ссылку ещё раз) — свой провайдер нужен, чтобы на `whitelist` и телефоне ходить к ним через
|
||||
`MY-EXIT`. Группа `MY` теперь есть
|
||||
всегда; без своих серверов и `[MY]`-нод она пустая, и `PUSH` на `whitelist` тогда по
|
||||
умолчанию `FOREIGN`.
|
||||
|
||||
CSQTT ([star-panel-csqtt](https://github.com/starkugz/csqtt-openwrt)) — резервный выход из белых
|
||||
списков: галка «Включить CSQTT» на вкладке «CSQTT» в LuCI (`CSQTT=1` в `common.env`). Пакет ставится и
|
||||
настраивается отдельно, в своей панели (Службы → star-panel-csqtt); он поднимает интерфейс
|
||||
`csqtt0` и маршруты не меняет. Kit добавляет прокси `CSQTT` (`type: direct`,
|
||||
`interface-name: csqtt0`) и группу `UPLINK` — через что подключаться к нодам подписок, BOOT
|
||||
и своим серверам (`dialer-proxy: UPLINK`):
|
||||
- `DIRECT` (по умолчанию) — как раньше;
|
||||
- `CSQTT` — сначала через туннель CSQTT наружу из белых списков, а дальше `MAIN` / `FOREIGN` /
|
||||
`MY` / `RU` работают поверх него как обычно. На `whitelist` свои серверы идут цепочкой
|
||||
`MY-EXIT` → нода → `CSQTT`.
|
||||
|
||||
Включать и выключать — кнопками в блоке «CSQTT» на странице mihomo-kit (или
|
||||
`mihomo-kit.sh csqtt on|off`): «Включить» запускает csqtt, ждёт подключения (до 90 с,
|
||||
`CSQTT_WAIT`) и только потом ставит `UPLINK = CSQTT`; «Выключить» сначала возвращает
|
||||
`UPLINK = DIRECT`, потом останавливает csqtt и ставит `csqtt.main.enabled=0` — без этого он
|
||||
поднимается сам при перезагрузке и переподключении WAN. Там же состояние: подключён ли,
|
||||
активный профиль, трафик, капчи и последняя ошибка (`User authorization failed` — истёк
|
||||
VK-токен). Кнопка Stop в панели csqtt останавливает только процесс. `UPLINK` можно
|
||||
переключать и в дашборде, без перезапуска. `CSQTT` ещё есть последним пунктом в `MAIN` —
|
||||
просто выход в интернет с IP сервера CSQTT. Правила `DIRECT` (ru-inside, `.ru` на `main`) в
|
||||
туннель не идут.
|
||||
|
||||
Собственные соединения клиента CSQTT (сервер, VK TURN) идут напрямую по правилу
|
||||
`PROCESS-NAME,csqtt,DIRECT` в самом начале правил, иначе с перехватом трафика роутера
|
||||
получится петля. Правилу нужен поиск процессов, а nikki по умолчанию его выключает
|
||||
(`find-process-mode: off` из `nikki.mixin.match_process`), поэтому с `CSQTT=1`
|
||||
`mihomo-kit.sh use` ставит `match_process=strict`. Если процесс называется иначе
|
||||
(`ps w | grep -i csqtt`) — `CSQTT_PROCESS="имя"` в `common.env`; другой интерфейс — `CSQTT_IFACE`.
|
||||
|
||||
Имена тейлнета (`*.ts.net` и `TS_DOMAINS`) разрешает MagicDNS встроенного Tailscale
|
||||
(`nameserver-policy` → `tailscale://tailscale`): клиенты получают настоящие адреса 100.x,
|
||||
и трафик идёт по правилу `100.64.0.0/10` в `TAILSCALE`. В тейлнете должен быть включён
|
||||
MagicDNS (админка Tailscale → DNS).
|
||||
|
||||
Проверка туннелей: у групп `OPENVPN` и `TAILSCALE` свой адрес проверки — LuCI, вкладки
|
||||
«OpenVPN» и «Tailscale» («Адрес для проверки») или `OVPN_CHECK_URL` (страница за VPN;
|
||||
пусто — `generate_204` Google) / `TS_CHECK_URL` (HTTP-сервис на ноде тейлнета, по умолчанию
|
||||
Проверка туннелей: у групп `BMSTU` и `TAILSCALE` свой адрес проверки — LuCI → Настройка
|
||||
(«Адрес для проверки» в блоках OpenVPN и Tailscale) или `OVPN_CHECK_URL` (по умолчанию
|
||||
`https://eu.bmstu.ru`) / `TS_CHECK_URL` (HTTP-сервис на ноде тейлнета, по умолчанию
|
||||
`http://100.69.216.50:8080`) в `common.env`.
|
||||
Кнопка проверки задержки этих групп в дашборде открывает его через туннель (если дашборд
|
||||
берёт адрес из группы); сами по таймеру они не проверяются. На странице mihomo-kit их
|
||||
открывает кнопка «Проверить» (у OpenVPN — «Проверка сайта», `ovpn.sh probe`).
|
||||
берёт адрес из группы); сами по таймеру они не проверяются. Tailscale ещё проверяется
|
||||
кнопкой «Проверить» на странице mihomo-kit.
|
||||
|
||||
OpenVPN сам ничего через туннель не проверяет. Connect таких запросов не делает, а
|
||||
URL-тест виден в логах сайта, который он открывает: `HEAD /` от Go-клиента, по таймеру.
|
||||
Поэтому с ядром kit состояние туннеля (подключён с такого-то времени, подключается, сервер
|
||||
не принял сессию) берётся из API mihomo — ядро отдаёт его в поле `openvpn` прокси, — и
|
||||
cron, LuCI («Состояние») и `ovpn.sh status` не шлют ни одного запроса. Новый код
|
||||
cron даёт, только если сервер не принял токен сессии или туннель не поднимается 5 минут
|
||||
(`DOWN_GRACE`). Ядра `stock`/`official` состояние не отдают: с ними cron открывает адрес
|
||||
проверки не чаще раза в 10 минут (`PROBE_EVERY`), в случайную секунду.
|
||||
|
||||
Новый профиль = новый файл в `profiles.d/` (например `LOCATION=main` + `OPENVPN=0`),
|
||||
Новый профиль = новый файл в `profiles.d/` (например `LOCATION=home` + `OPENVPN=0`),
|
||||
затем `mihomo-kit.sh build && mihomo-kit.sh use <имя>`. Все опции — в
|
||||
[router/profile.env.example](router/profile.env.example).
|
||||
|
||||
@ -534,175 +136,55 @@ cron даёт, только если сервер не принял токен
|
||||
|
||||
| Фикс | Зачем |
|
||||
|---|---|
|
||||
| ядро kit `v1.19.34-ts8` вместо ядра из пакета | в v1.19.29 OpenVPN не проходит рукопожатие; Tailscale через `dialer-proxy` и маскировка OpenVPN — только в ядре kit |
|
||||
| ядро mihomo `v1.19.32` вместо ядра из пакета | в v1.19.29 OpenVPN не проходит рукопожатие |
|
||||
| `TS_FORCE_NOISE_443=true` в `/etc/init.d/nikki` | провайдер ломает control-соединение Tailscale на порту 80, вход зависает |
|
||||
| убрать `100.64.0.0/10`, `172.16.0.0/12` из `nikki.proxy.reserved_ip` | иначе nikki пускает Tailscale и внутренние сети VPN (172.16/12) мимо mihomo |
|
||||
| `ts.net` в `rebind_domain` dnsmasq | иначе защита от DNS rebinding отбрасывает адреса 100.x тейлнета |
|
||||
| убрать `100.64.0.0/10`, `172.16.0.0/12` из `nikki.proxy.reserved_ip` | иначе nikki пускает Tailscale и внутренние сети BMSTU мимо mihomo |
|
||||
| metric: `wan`/`wan6` — 10, остальные выходы (модемы, wifi-клиент) — 50, 60, … (если не заданы руками) | при живом проводе интернет идёт по проводу, модемы — запасные |
|
||||
| cron `ovpn.sh check` раз в минуту | держит туннель по расписанию/таймеру; со свежим кодом поднимает, если сервер не принял токен сессии или туннель долго лежит (состояние из ядра, без запросов через туннель) |
|
||||
| `ovpn.sh write` в `/etc/init.d/nikki` | провайдер OpenVPN (со свежим кодом, если нужен) перед стартом mihomo: ядро kit подключается сразу |
|
||||
| `GOMEMLIMIT` в `/etc/init.d/nikki` (только с `LITE=1`) | лимит памяти ядра для слабых роутеров, см. «Облегчённый режим» |
|
||||
| cron `bmstu-otp.sh check` раз в минуту | поднимает OpenVPN со свежим OTP, если туннель упал |
|
||||
| переустановка `libcurl4 curl`, если curl сломан | `Error relocating ... symbol not found` |
|
||||
|
||||
Ещё `mihomo-kit.sh use` (и «Сохранить и применить») ставит `nikki.proxy.ipv6_proxy=0`, если на
|
||||
роутере выключен IPv6 (`disable_ipv6=1` для `all` или `lo`, или IPv6 нет в ядре): иначе nikki
|
||||
при старте пишет `Error: IPv6 is disabled on nexthop device` (`ip -6 route ... dev lo` для
|
||||
tproxy). Включить обратно — `uci set nikki.proxy.ipv6_proxy=1`, когда IPv6 появится.
|
||||
## Телефон (FlClash)
|
||||
|
||||
## Телефон и компьютер
|
||||
|
||||
Тот же обход можно взять в приложение на ядре mihomo (Clash Meta):
|
||||
- Android — FlClash или Clash Meta for Android;
|
||||
- iPhone, iPad — Clash Mi;
|
||||
- Windows, macOS, Linux — FlClash или Clash Verge Rev.
|
||||
|
||||
С роутера: LuCI → вкладка «Телефон» → галка «Конфиг для телефона» (на новом роутере уже стоит) →
|
||||
«Сохранить и применить». На той же вкладке появится блок «Подключить приложение» с QR-кодом и
|
||||
ссылкой `http://<роутер>/mihomo-kit/<токен>.yaml`. В приложении: профили (подписки) →
|
||||
добавить → по ссылке или QR-коду; QR сканировать сканером в самом приложении (камера телефона
|
||||
просто покажет ссылку). «Скопировать ссылку» — вставить вручную; «Открыть в приложении»
|
||||
(`clash://install-config?url=…`) — если страница открыта на самом телефоне.
|
||||
С роутера: LuCI → Настройка → галка «Конфиг для телефона» → «Сохранить и применить». На
|
||||
странице появится блок «Телефон (FlClash)» с QR-кодом и ссылкой
|
||||
`http://<роутер>/mihomo-kit/<токен>.yaml`: FlClash → Профили → + → по ссылке (или QR).
|
||||
Это `common.env`, собранный с `TARGET=mobile`: те же подписки, BOOT/`BOOT-AUTO`, HWID и
|
||||
RU-адреса, без OpenVPN, Tailscale, торрентов и `PUSH`; свои серверы — в `MY`, к ним всегда
|
||||
через `MY-EXIT` (телефон часто на белых списках). Пересобирается вместе с профилями.
|
||||
|
||||
Ссылка открывается только в сети роутера (вне дома приложение просто не обновит профиль) и
|
||||
Ссылка открывается только в сети роутера (вне дома FlClash просто не обновит профиль) и
|
||||
содержит ссылки подписок — токен и есть секрет; «Новая ссылка» (`mihomo-kit.sh mobile new`)
|
||||
отзывает старую.
|
||||
|
||||
Без роутера — веб-конструктор:
|
||||
|
||||
Открыть [web/index.html](web/index.html) (из репозитория или со своего хостинга) →
|
||||
«Телефон» → подписки и vless-ссылка BOOT → «Скачать» → FlClash: Профили → + → Файл.
|
||||
Страница всё считает в браузере и никуда ничего не отправляет.
|
||||
|
||||
## Профили
|
||||
|
||||
| | роутер `main` | роутер `whitelist` | роутер `foreign` | телефон |
|
||||
|---|---|---|---|---|
|
||||
| подписки через `BOOT-AUTO` | ✓ | ✓ | ✓ | ✓ |
|
||||
| `ru-inside` | напрямую | напрямую | через RU | напрямую |
|
||||
| `ru-services` (русские сервисы вне ru-inside и вне .ru/.su/.рф) | напрямую | через RU | через RU | через RU |
|
||||
| остальные `.ru` / `.su` / `.рф`, доп. IP (`RU_IPS`) | напрямую | через RU | через RU | через RU |
|
||||
| доп. IP / домены через FOREIGN, MY (`FOREIGN_*`, `MY_*`) | `FOREIGN` / `MY` | `FOREIGN` / `MY` | `FOREIGN` / `MY` | `FOREIGN` / `MY` |
|
||||
| доп. домены через RU (`RU_DOMAINS`) | напрямую | через RU | через RU | через RU |
|
||||
| локальные адреса (`LOCAL_HOSTS`) | по LAN | по LAN | по LAN | — |
|
||||
| всё остальное (`MAIN`) | `FOREIGN` | `FOREIGN` | напрямую (можно `MY`) | `FOREIGN` |
|
||||
| торренты (порты 20000–20199) | ✓ | ✓ | ✓ | — |
|
||||
| OpenVPN | напрямую | через `OVPN-EXIT` (RU-нода) | через `OVPN-EXIT` (RU-нода) | — |
|
||||
| Tailscale | напрямую | через `MY` (свои серверы и `[MY]`-ноды подписки), без них напрямую* | напрямую | — |
|
||||
| свои серверы | напрямую | через `MY-EXIT` | напрямую | через `MY-EXIT` |
|
||||
| пуши (`PUSH`, отключаемо) | `DIRECT` | `MY` | `DIRECT` | — |
|
||||
| сервисы (`SERVICES`) | своя группа | своя группа | своя группа | своя группа |
|
||||
| | роутер дом | роутер улица | телефон |
|
||||
|---|---|---|---|
|
||||
| подписки через BOOT | ✓ | ✓ | ✓ |
|
||||
| `ru-inside` напрямую, остальные `.ru` через RU | ✓ | ✓ | ✓ |
|
||||
| торренты (порты 20000–20199) | ✓ | ✓ | — |
|
||||
| OpenVPN | напрямую | через `OVPN-EXIT` (RU-нода) | — |
|
||||
| Tailscale | напрямую | напрямую* | — |
|
||||
|
||||
`LOCAL_HOSTS` — свои серверы в локальной сети этого роутера: «Локальные адреса» в LuCI →
|
||||
вкладка «Правила» (или `LOCAL_HOSTS="sam-hub.net=192.168.64.20"` в `common.env`,
|
||||
пар может быть несколько, домен — вместе с поддоменами). Без этого mihomo разрешает свой
|
||||
домен во внешний (белый) IP роутера и стучится сам в себя: вместо сервера отвечает LuCI с
|
||||
сертификатом `OpenWrt`. С ним домен попадает в `hosts` mihomo и в исключения fake-ip:
|
||||
клиенты получают адрес в LAN и ходят к серверу напрямую, правило `DIRECT` стоит первым
|
||||
среди своих списков, а подписку с такого домена роутер качает напрямую (`DIRECT`), какой
|
||||
бы выход для неё ни был выбран. Действует во всех профилях роутера, в конфиг телефона не
|
||||
попадает; при импорте с `--keep-local` остаётся свой, из файла не переносится. Для
|
||||
`wget`/`opkg` самого роутера (обновления kit, ядро) нужна ещё запись в dnsmasq:
|
||||
`uci add_list dhcp.@dnsmasq[0].address='/sam-hub.net/192.168.64.20'`.
|
||||
|
||||
Клиенты мимо mihomo — LuCI → вкладка «Правила» → «Клиенты мимо mihomo» (`BYPASS_CLIENTS` в
|
||||
`common.env`): IP-адреса, подсети и MAC-адреса через пробел. Их трафик и DNS nikki вообще не
|
||||
отдаёт в mihomo, они идут напрямую. Нужно, например, когда за этим роутером второй роутер со
|
||||
своим kit: иначе его трафик дважды заворачивается в прокси (сначала на втором, потом на этом).
|
||||
MAC надёжнее IP: адрес по DHCP может смениться (или закрепить его в Сеть → DHCP и DNS). Это
|
||||
секция `lan_access_control` самого nikki (`proxy 0`, `dns 0`), которую `use` и «Сохранить и
|
||||
применить» ставят первой — первое совпадение побеждает. Только для этого роутера: при импорте
|
||||
с `--keep-local` остаётся своя.
|
||||
|
||||
Правила выбираются по имени сайта: его mihomo знает из своего DNS или достаёт сниффером из
|
||||
рукопожатия TLS/QUIC. Сайты за Cloudflare с ECH (браузер получил ключи через свой DoH)
|
||||
показывают в рукопожатии не своё имя, а `cloudflare-ech.com`. Такое имя сниффер пропускает
|
||||
(`skip-domain`), иначе `.ru`-сайт за Cloudflare уходил бы в `MAIN`. Если устройство спрашивает DNS
|
||||
в обход роутера («Безопасный DNS» в браузере, «Частный DNS» на Android), имени у mihomo нет
|
||||
вовсе, и правила по доменам для такого трафика не работают.
|
||||
|
||||
На `foreign` российские домены не попадают в исключения fake-ip: их разрешает RU-нода, а
|
||||
для прямого трафика DNS — Cloudflare/Google вместо Яндекса.
|
||||
|
||||
\* Встроенный Tailscale в официальном mihomo через прокси не работает: при `dialer-proxy`
|
||||
он открывает UDP-сокет без адреса назначения, и любой прокси mihomo падает на его
|
||||
резолве (`magicsock: Rebind IPv4 failed: failed to bind any ports`,
|
||||
[MetaCubeX/mihomo#3142](https://github.com/MetaCubeX/mihomo/issues/3142)). Поэтому kit
|
||||
ставит своё ядро `v1.19.34-ts8` — официальный v1.19.34 с правкой
|
||||
`tools/core/tailscale-packet-listener.patch`: UDP-сокет открывается на роутере, а
|
||||
control-сервер и DERP идут по TCP через `dialer-proxy`. На белых списках прямой UDP не
|
||||
проходит, и Tailscale работает через DERP — медленнее прямого соединения, но работает.
|
||||
|
||||
Вторая правка того же ядра — `tools/core/openvpn-connect-mimic.patch`, маскировка OpenVPN
|
||||
под OpenVPN Connect (см. «OpenVPN под видом OpenVPN Connect»).
|
||||
|
||||
Третья — `tools/core/reality-client-version.patch`: в рукопожатии REALITY клиент сообщает
|
||||
серверу версию Xray, и mihomo всегда шлёт 1.8.2. Серверы с `minClientVer` выше (его ставят
|
||||
некоторые панели) такого клиента отвергают — в логе ядра `REALITY Authentication: false`, —
|
||||
а клиенты на Xray (Happ, v2rayN) с той же ссылкой проходят. Ядро kit сообщает свежую версию
|
||||
Xray (26.10.21); для отдельного сервера можно задать свою в YAML сервера:
|
||||
`reality-opts: {client-version: "25.3.6"}` (если сервер ограничивает и сверху, `maxClientVer`).
|
||||
Как собрать — в «Разработке».
|
||||
Если ядро не скачалось, `fix` оставляет текущее и запускает nikki.
|
||||
|
||||
Какое ядро на конкретном роутере — селект на вкладке «Система» (или
|
||||
`mihomo-kit.sh core stock|official|kit`), выбор хранится в `/etc/nikki/kit.env` как `CORE=`:
|
||||
- `stock` — ядро из пакета nikki/прошивки (`/usr/libexec/mihomo`), ничего не качается, место
|
||||
во флеше освобождается;
|
||||
- `official` — официальный релиз MetaCubeX `CORE_OFFICIAL`;
|
||||
- `kit` (по умолчанию) — своя сборка `CORE_KIT`: официальное ядро с правками kit (см. «Ядро kit»).
|
||||
|
||||
Распакованному ядру нужно ~56 МБ во флеше: на роутерах с маленьким `/overlay` остаётся
|
||||
`stock`.
|
||||
|
||||
Новое ядро ставится через оперативку, если в ней свободно ≥ 140 МБ (`MemAvailable`): пока
|
||||
nikki работает, ядро скачивается и распаковывается в `/tmp/mihomo.new`, там же проверяется
|
||||
`-v`. Потом nikki останавливается, текущее ядро копируется в `/tmp/mihomo.prev` и
|
||||
удаляется из флеша, новое записывается на его место. Так во флеше нужно место только под одно
|
||||
ядро. Если запись не удалась, возвращается старое. Если новое ядро после старта не ответило
|
||||
по API (`/version`) за 40 с, kit откатывается на старое и запускает его. Копия в RAM после
|
||||
этого удаляется: более старое ядро — через `MIHOMO_VERSION=…` в `kit.env` + `fix`. Если
|
||||
оперативки мало, ядро распаковывается во флеш рядом со старым (как раньше, без отката).
|
||||
Пропало питание, пока новое ядро писалось во флеш — `mihomo-kit.sh fix` скачает его заново. Версии `CORE_OFFICIAL`/`CORE_KIT` задаются в `router/mihomo-kit.sh` — роутеры с
|
||||
выбором `official`/`kit` подтягивают их при обновлении kit. Явный `MIHOMO_VERSION=…` в
|
||||
`kit.env` главнее выбора. Когда исправление появится в mihomo, вернуть официальный релиз.
|
||||
|
||||
Обновить nikki / ядро из пакета (`stock`) на роутере с маленьким флешем — ipk-файлы в `/tmp`, потом:
|
||||
|
||||
mihomo-kit.sh pkg-install /tmp/mihomo-meta_*.ipk /tmp/nikki_*.ipk /tmp/luci-i18n-nikki-ru_*.ipk
|
||||
|
||||
opkg сравнивает полный размер новых пакетов со свободным местом и не учитывает, что старые
|
||||
версии освободят своё, поэтому без `--force-space` пишет «нет места». `pkg-install` считает
|
||||
сам: свободное место + файлы старых версий в `/overlay` (не в `/rom`) против `Installed-Size`
|
||||
новых, с запасом 2 МБ (`PKG_RESERVE_KB`). Не влезает — ничего не ставит. Влезает —
|
||||
останавливает nikki (запущенное ядро держит свой старый файл на флеше), ставит с
|
||||
`--force-space` и делает `fix`: обновление nikki перезаписывает `/etc/init.d/nikki`, и
|
||||
правки kit (`TS_FORCE_NOISE_443`, провайдер OpenVPN, `GOMEMLIMIT`) нужно вернуть.
|
||||
|
||||
### Облегчённый режим (`LITE=1`)
|
||||
|
||||
Для роутеров с 256 МБ памяти (Routerich AX3000 и т.п.): галочка в настройках. Маршрутизация
|
||||
не меняется. Что делает:
|
||||
|
||||
- профиль: ноды проверяются раз в 10 минут и только пока через провайдер шёл трафик
|
||||
(`lazy`); группа RU проверяется тем же URL, что и провайдер (один проход вместо двух);
|
||||
сниффер без QUIC, HTTP только на 80/8080; `log-level: warning`, без поиска процессов;
|
||||
- nikki: `GOMEMLIMIT` для ядра (`LITE_GOMEMLIMIT`, по умолчанию `64MiB`) строкой в
|
||||
`/etc/init.d/nikki` (перекрывает GOMEMLIMIT из LuCI nikki); `log_level=warning` и
|
||||
`match_process=off` в uci (с CSQTT остаётся `strict`);
|
||||
- перехват без TUN: TCP — redirect, UDP — tproxy (`kmod-nft-tproxy` ставится, если его нет),
|
||||
`tun_enabled=0`; режимы, которые уже redirect/tproxy, не трогаются. Не удалось поставить
|
||||
модуль — всё остаётся как было. `LITE_TPROXY=0` в `common.env` — kit перехват не трогает
|
||||
(настраивай в nikki сам); выключение `LITE` назад на TUN не переключает;
|
||||
- после применения в журнале — предупреждения о том, что ещё ест память: TUN (если он
|
||||
остался), встроенный Tailscale, поиск процессов для CSQTT.
|
||||
|
||||
Память ядра — строка «Память mihomo» в «Состоянии». Если с лимитом ядро грузит процессор,
|
||||
значит лимит ниже того, что ему реально нужно: подними `LITE_GOMEMLIMIT`. После обновления
|
||||
пакета nikki строку `GOMEMLIMIT` возвращает «Починить» (`mihomo-kit.sh fix`).
|
||||
\* Встроенный Tailscale в mihomo v1.19.32 через прокси не работает: при `dialer-proxy`
|
||||
он открывает UDP-сокет без адреса назначения, а любой прокси mihomo (socks5, hysteria2,
|
||||
ss, …) сначала пытается его разрезолвить и падает — в логе
|
||||
`magicsock: Rebind IPv4 failed: failed to bind any ports (tried [0])`. Переменные
|
||||
`HTTPS_PROXY` встроенный Tailscale тоже не читает (в форке собран без `useproxy`).
|
||||
Поэтому на белых списках Tailscale не поднимется; `TS_EXIT=1` (группа `TS-EXIT`) упирается
|
||||
в ту же ошибку и оставлен на случай исправления в mihomo.
|
||||
|
||||
## Если что-то не работает
|
||||
|
||||
- **OpenVPN** `tunnel did not come up`: `ovpn.sh debug` покажет настоящую ошибку.
|
||||
- **OpenVPN** `tunnel did not come up`: `bmstu-otp.sh debug` покажет настоящую ошибку.
|
||||
`read hard reset response` — до сервера не доходят пакеты (zeroblock, правило для IP
|
||||
сервера); `AUTH_FAILED` — неверный логин или пароль, а с TOTP ещё и формат кода: «Как
|
||||
отправлять код» в настройках (`PASS_FORMAT` в `openvpn.env`) или неверное время на роутере.
|
||||
сервера); `AUTH_FAILED` — формат пароля (`PASS_FORMAT` в `bmstu.env`, сейчас `otp-last`).
|
||||
- **Tailscale** без ссылки: `mihomo-kit.sh ts-login`. Ссылка пишется в лог один раз и
|
||||
только на уровне `info` (у nikki по умолчанию `warning`), а неудачный первый запуск
|
||||
оставляет в `/etc/nikki/run/tailscale` состояние, с которым нода молчит — команда
|
||||
@ -714,82 +196,34 @@ opkg сравнивает полный размер новых пакетов с
|
||||
|
||||
```
|
||||
install.sh загрузчик: кит в /etc/nikki/kit + mihomo-kit.sh setup
|
||||
templates/ фрагменты конфига
|
||||
templates/ фрагменты конфига (общие для скрипта и страницы)
|
||||
presets/ профили, которые setup кладёт в profiles.d
|
||||
router/
|
||||
mihomo-kit.sh сборка, setup-мастер, use/update/fix
|
||||
ovpn.sh OpenVPN: провайдер из .ovpn (TOTP в пароле), cron-сторож, on/off, расписание
|
||||
luci/ страница LuCI «Службы → mihomo-kit»: rpcd.sh (бэкенд), view, ACL, меню,
|
||||
servers.js (ссылки и YAML своих серверов), qrcode.js
|
||||
tools/ push.sh, test.sh, test-servers.js, servers-ref.sh + servers-ref/ (эталоны
|
||||
для servers.js из Go-кода mihomo), core/ (ядро kit),
|
||||
nikki-mirror.sh (зеркало пакетов nikki в релизах)
|
||||
tests/fixtures/ профили для test.sh (фиктивные секреты), own.servers
|
||||
tests/expected/ эталонный YAML каждого профиля
|
||||
tests/links/, yaml/ ссылки и YAML с выводом Go-кода mihomo для luci/servers.js
|
||||
bmstu-otp.sh OpenVPN BMSTU: TOTP в пароле, cron-сторож, on/off
|
||||
luci/ страница LuCI «Службы → mihomo-kit»: rpcd.sh (бэкенд), view, ACL, меню
|
||||
web/ страница-конструктор: engine.js + index.src.html → index.html
|
||||
tools/ push.sh, test.sh, build-web.py, render.js
|
||||
tests/fixtures/ профили для test.sh (фиктивные секреты)
|
||||
```
|
||||
|
||||
Шаблоны: `templates/<секция>/NN-<модуль>[.<тег>...][.each].yaml`; секции собираются в
|
||||
порядке head, proxies, providers, sniffer, dns, groups, rules, файлы — по имени.
|
||||
|
||||
- файл включается, если активны модуль и все теги; `.each` — по разу на элемент модуля
|
||||
(`sub` — подписка: `${SUB_NAME}`, `${SUB_URL}`; `boot` — seed-нода: `${SEED_NAME}`, ...);
|
||||
(`sub` — подписка: `${SUB_NAME}`, `${SUB_URL}`; `hy2` — свой сервер: `${HY2_NAME}`, ...);
|
||||
- `${@@VAR}` — строка повторяется для каждой строки `VAR` (пустая `VAR` — строки нет);
|
||||
- `строка #@тег[,!тег]` — строка остаётся, только если условия выполнены;
|
||||
- `${@VAR}` — строка повторяется для каждого слова из `VAR`;
|
||||
- `${VAR}` — подстановка.
|
||||
|
||||
Теги: `base`, `sub`, `router`|`mobile`, `main`|`whitelist`|`foreign` (роутер), служебные `ovpn_exit` (whitelist, foreign), `my_exit` (whitelist, телефон), `own_srv` (есть свои серверы), `own` (`own_srv` или `my_links`), `boot`, `torrent`, `push`,
|
||||
`openvpn`, `tailscale`, `ts_exit`, `my_links`, `local_hosts`, `csqtt`, `lite`. Значения по умолчанию — `set_defaults` в
|
||||
`router/mihomo-kit.sh`.
|
||||
Теги: `base`, `sub`, `router`|`mobile`, `home`|`street` (роутер), `boot`, `torrent`,
|
||||
`openvpn`, `tailscale`, `ts_exit`, `hy2`. Значения по умолчанию — `set_defaults` в
|
||||
`router/mihomo-kit.sh` и `DEFAULTS` в `web/engine.js` (держать одинаковыми).
|
||||
|
||||
### Ядро kit
|
||||
|
||||
Официальный mihomo плюс правки из `tools/core/*.patch` (Tailscale через `dialer-proxy`,
|
||||
маскировка OpenVPN, версия клиента REALITY). Нужны git и Go.
|
||||
|
||||
1. `tools/core/build.sh v1.19.34 ts8` — клонирует mihomo `v1.19.34`, накладывает патчи и
|
||||
собирает `tools/core/dist/mihomo-linux-<arch>-v1.19.34-ts8.gz` для arm64, amd64, armv7,
|
||||
mips-softfloat, mipsle-softfloat.
|
||||
2. В репозитории kit создать релиз с тегом `core-v1.19.34-ts8` и приложить все `.gz`, не
|
||||
переименовывая: роутер качает `$MIHOMO_BASE/mihomo-linux-<arch>-<версия>.gz`.
|
||||
3. `CORE_KIT` в `router/mihomo-kit.sh` — та же версия. Пушить кит только после релиза:
|
||||
роутеры берут кит из `main` и иначе не найдут ядро.
|
||||
4. На роутере: `mihomo-kit.sh update` (новый кит; ядро меняется, если версия другая),
|
||||
`mihomo-kit.sh fix` (ядро и init-скрипт nikki: провайдер OpenVPN перед стартом mihomo), затем
|
||||
`ovpn.sh refresh` (провайдер OpenVPN с новыми полями). Проверить:
|
||||
`mihomo-kit.sh core-info`, `ovpn.sh status`.
|
||||
|
||||
Новая версия mihomo или новая правка — следующий суффикс (`ts9`) в шагах 1–3. Патчи
|
||||
применяются по алфавиту; если не накладываются, поправить их на новом теге.
|
||||
|
||||
### Зеркало nikki
|
||||
|
||||
Роутер ставит nikki из релиза `nikki-<NIKKI_VERSION>` репозитория kit (GitHub из России
|
||||
часто недоступен). Обновить зеркало на новый релиз nikki (нужны curl, jq; токен Gitea с
|
||||
правом `write:repository`):
|
||||
После правки шаблонов или движка:
|
||||
|
||||
```sh
|
||||
GITEA_TOKEN=... tools/nikki-mirror.sh latest # все архитектуры, OpenWrt 24.10
|
||||
GITEA_TOKEN=... tools/nikki-mirror.sh v1.26.2 aarch64_cortex-a53 mipsel_24kc # только эти
|
||||
MIHOMO=/path/to/mihomo tools/test.sh # sh и JS дают одинаковый YAML, mihomo -t проходит
|
||||
tools/build-web.py # пересобрать web/index.html
|
||||
```
|
||||
|
||||
Скрипт создаёт релиз `nikki-<версия>`, качает `nikki_<arch>-openwrt-24.10.tar.gz` с GitHub,
|
||||
убирает из них `mihomo-alpha` и переводы zh (меньше памяти на роутере; `Packages` и подпись
|
||||
не меняются) и выкладывает. Уже выложенные пропускает — можно дозапустить. Потом
|
||||
`NIKKI_VERSION` в `router/mihomo-kit.sh` — та же версия, и пушить кит. Ключ nikki
|
||||
(`router/nikki-key-build.pub`) менять, только если nikki сменит ключ подписи
|
||||
(`https://nikkinikki.pages.dev/key-build.pub`).
|
||||
|
||||
После правки шаблонов, скрипта или `luci/servers.js`:
|
||||
|
||||
```sh
|
||||
MIHOMO=/path/to/mihomo tools/test.sh # профили = tests/expected/, mihomo -t проходит, servers.js = Go
|
||||
UPDATE=1 tools/test.sh # переписать tests/expected/ (изменения — проверить в diff)
|
||||
```
|
||||
|
||||
После обновления mihomo (новый `CORE_OFFICIAL`) — сверить разбор ссылок и YAML на странице с
|
||||
новым ядром: `tools/servers-ref.sh` (или `tools/servers-ref.sh <тег>`) пересоздаёт эталоны
|
||||
`tests/links/*.expected.json` и `tests/yaml/*.expected.json` из Go-кода этой версии mihomo,
|
||||
затем `tools/test.sh`. `FAIL links/...` — mihomo теперь разбирает ссылку иначе: то же
|
||||
изменение (diff `common/convert` между тегами) перенести в `luci/servers.js`.
|
||||
|
||||
60
TODO.md
60
TODO.md
@ -1,60 +0,0 @@
|
||||
# Технический долг и планы
|
||||
|
||||
Что стоит сделать в kit дальше. Сверху — то, что страхует от поломок, ниже — новые возможности.
|
||||
|
||||
## Надёжность кода
|
||||
|
||||
- **`local` в функциях `router/mihomo-kit.sh`.** Переменные в sh глобальные, и функции затирают
|
||||
их друг другу. Уже было: `pool_vars` перезаписывал `_n` у `own_entries_check`, и проверка
|
||||
петли молча не срабатывала. ash в busybox понимает `local` — перевести на него хотя бы функции,
|
||||
которые вызывают другие (`pool_vars`, `variant_members`, `sub_vars`, `*_vars`).
|
||||
- **Тесты роутерной части.** `tools/test.sh` проверяет только рендер. Миграции
|
||||
(`migrate_openvpn`, `migrate_profiles`), `bypass_uci`, `nikki_defaults`, `opkg_fit`, cron,
|
||||
`ovpn.sh` (пароль с TOTP и без, шифры из `.ovpn`, `routes_set`) проверялись руками. Добавить
|
||||
прогоны с поддельными `uci`, `opkg`, `curl`, `/etc/init.d/*` в `PATH`, которые пишут вызовы в
|
||||
лог, и сравнивать лог с эталоном.
|
||||
- **Проверка JS.** Страницы LuCI правились без запуска: `node --check luci/*.js` в
|
||||
`tools/test.sh` (когда есть node) и тесты `tools/test-*.js` в CI.
|
||||
- **CI на Gitea Actions.** `tools/test.sh` с node и `MIHOMO=…` (`mihomo -t` по всем профилям)
|
||||
на каждый пуш: роутеры берут kit прямо из `main`.
|
||||
- **Разбить `luci/mihomo-kit.js`.** `renderSettings` — одна функция на сотни строк. После вкладок
|
||||
естественно резать её по вкладке на функцию (подписки, правила, свои серверы, OpenVPN, …).
|
||||
|
||||
## Известные слабые места
|
||||
|
||||
- **OpenVPN сразу после старта nikki.** Имя сервера резолвится через DNS mihomo (`respect-rules`,
|
||||
через `MAIN`); пока он не готов, туннель не находит сервер и поднимается только через
|
||||
`DOWN_GRACE` (5 минут). Узнавать IP сервера в `ovpn.sh` при записи провайдера напрямую
|
||||
(77.88.8.8) и писать IP вместо имени.
|
||||
- **`MAIN = DIRECT` переезжает между профилями** (`cache.db` по имени группы): выбрал дома —
|
||||
на whitelist нет интернета. Хотя бы предупреждение на «Обзоре», а лучше сброс `MAIN` при
|
||||
смене профиля или отдельный профиль `behind` (за другим роутером: только OpenVPN и Tailscale,
|
||||
остальное `DIRECT`).
|
||||
- **`OVPN-EXIT` только из RU-нод** — рассчитано на VPN-сервер в России. Дать выбор страны или
|
||||
любой ноды.
|
||||
- **OpenVPN:** профили только с сертификатом (без `auth-user-pass`) сейчас требуют логин;
|
||||
внутренние домены за VPN не резолвятся через DNS самого VPN.
|
||||
- **Ноды `[MY]` с входом ищутся по точному имени:** переименовали в подписке — вход молча
|
||||
перестаёт действовать. Показывать в LuCI заданные входы, для которых ноды больше нет.
|
||||
- **`opkg_fit`** не проверен на живом маленьком роутере: печатает ли `opkg --noaction` строки
|
||||
`Installing …` (иначе откатывается к обычному `opkg install`).
|
||||
|
||||
## Порт на OpenWrt 25.12
|
||||
|
||||
opkg заменён на apk: `cmd_install`, `opkg_fit`, `pkg-install` (`.ipk` → `.apk`, нет
|
||||
`--force-space`, свой подсчёт места), `lite_intercept`. Определять менеджер пакетов и держать
|
||||
обе ветки. Генерация конфигов, LuCI, `use`, `fix`, ядро от этого не зависят.
|
||||
|
||||
## Новые возможности
|
||||
|
||||
- **Автоопределение белых списков:** роутер раз в N минут проверяет, открываются ли зарубежные
|
||||
адреса напрямую, и сам переключает `main` ↔ `whitelist` (с гистерезисом, чтобы не прыгать).
|
||||
- **Маршрут по устройству:** развитие `BYPASS_CLIENTS` — не только «мимо mihomo», но и «это
|
||||
устройство всегда через FOREIGN / MY / пул» (`SRC-IP-CIDR` в начале правил; MAC → IP по
|
||||
DHCP-арендам).
|
||||
- **Выбор из DHCP-клиентов** в LuCI для `BYPASS_CLIENTS` и маршрутов по устройству, а не ввод MAC
|
||||
руками.
|
||||
- **Уведомления в Telegram:** OpenVPN не поднимается, обновление kit упало, подписка не
|
||||
скачивается, ядро откатилось.
|
||||
- **Откат обновления kit:** сохранять предыдущую версию перед `update`, кнопка «вернуть
|
||||
предыдущую».
|
||||
23
install.sh
23
install.sh
@ -12,13 +12,7 @@ KIT_DIR=/etc/nikki/kit
|
||||
here=$(cd "$(dirname "$0")" 2>/dev/null && pwd || echo /nonexistent)
|
||||
mkdir -p "$KIT_DIR"
|
||||
if [ -f "$here/router/mihomo-kit.sh" ]; then
|
||||
# whole directories, as below: a template renamed in the kit must not stay behind
|
||||
if [ "$here" != "$KIT_DIR" ]; then
|
||||
for d in templates presets router luci; do
|
||||
rm -rf "${KIT_DIR:?}/$d"
|
||||
cp -r "$here/$d" "$KIT_DIR/"
|
||||
done
|
||||
fi
|
||||
[ "$here" = "$KIT_DIR" ] || cp -r "$here/templates" "$here/presets" "$here/router" "$here/luci" "$KIT_DIR/"
|
||||
else
|
||||
tmp=/tmp/mihomo-kit.$$
|
||||
mkdir -p "$tmp"
|
||||
@ -38,16 +32,5 @@ else
|
||||
echo "${sha:-?} $(date '+%Y-%m-%d %H:%M')" > "$KIT_DIR/VERSION"
|
||||
rm -rf "$tmp"
|
||||
fi
|
||||
# stdin may be the piped script: the wizard (setup --cli) reads answers from /dev/tty.
|
||||
# The output is also kept in RAM: the flash may be full by the time something fails.
|
||||
log=/tmp/mihomo-kit-install.log
|
||||
rc=/tmp/mihomo-kit-install.rc
|
||||
{
|
||||
code=0
|
||||
sh "$KIT_DIR/router/mihomo-kit.sh" setup "$@" 2>&1 || code=$?
|
||||
echo "$code" > "$rc"
|
||||
} | tee "$log"
|
||||
code=$(cat "$rc" 2>/dev/null || echo 1)
|
||||
rm -f "$rc"
|
||||
echo "install log: $log"
|
||||
exit "$code"
|
||||
# stdin may be the piped script: the wizard (setup --cli) reads answers from /dev/tty
|
||||
exec sh "$KIT_DIR/router/mihomo-kit.sh" setup "$@"
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
{
|
||||
"luci-app-mihomo-kit": {
|
||||
"description": "mihomo-kit: profiles, OpenVPN, Tailscale, CSQTT",
|
||||
"description": "mihomo-kit: profiles, OpenVPN, Tailscale",
|
||||
"read": {
|
||||
"ubus": {
|
||||
"mihomo-kit": [ "status", "ovpn_status", "ovpn_probe", "csqtt_status", "job", "update_check", "ts_check", "graph", "api" ]
|
||||
"mihomo-kit": [ "status", "ovpn_status", "job", "update_check", "ts_check" ]
|
||||
}
|
||||
},
|
||||
"write": {
|
||||
"ubus": {
|
||||
"mihomo-kit": [ "run", "config_get", "config_set", "export", "import", "group", "services_set" ]
|
||||
"mihomo-kit": [ "run", "config_get", "config_set" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1645
luci/graph.js
1645
luci/graph.js
File diff suppressed because it is too large
Load Diff
@ -3,26 +3,11 @@
|
||||
"title": "mihomo-kit",
|
||||
"order": 61,
|
||||
"action": {
|
||||
"type": "firstchild"
|
||||
"type": "view",
|
||||
"path": "mihomo-kit"
|
||||
},
|
||||
"depends": {
|
||||
"acl": [ "luci-app-mihomo-kit" ]
|
||||
}
|
||||
},
|
||||
"admin/services/mihomo-kit/main": {
|
||||
"title": "Управление",
|
||||
"order": 1,
|
||||
"action": {
|
||||
"type": "view",
|
||||
"path": "mihomo-kit"
|
||||
}
|
||||
},
|
||||
"admin/services/mihomo-kit/graph": {
|
||||
"title": "Граф",
|
||||
"order": 2,
|
||||
"action": {
|
||||
"type": "view",
|
||||
"path": "mihomo-kit-graph"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,157 +0,0 @@
|
||||
'use strict';
|
||||
'require view';
|
||||
'require rpc';
|
||||
'require dom';
|
||||
|
||||
// LuCI "Службы → mihomo-kit → Граф": a built profile as a graph (luci/graph.js), with the
|
||||
// live state of the running mihomo through the rpcd plugin (method api: read-only paths)
|
||||
// and the choice in its groups (method group); the services and pools of the settings are
|
||||
// edited here too (method services_set: rebuild and restart as the job).
|
||||
|
||||
var callStatus = rpc.declare({ object: 'mihomo-kit', method: 'status', expect: { '': {} } });
|
||||
var callGraph = rpc.declare({ object: 'mihomo-kit', method: 'graph', params: [ 'profile' ], expect: { '': {} } });
|
||||
var callApi = rpc.declare({ object: 'mihomo-kit', method: 'api', params: [ 'path' ], nobatch: true, expect: { '': {} } });
|
||||
var callServicesSet = rpc.declare({ object: 'mihomo-kit', method: 'services_set', params: [ 'services', 'pools' ], expect: { '': {} } });
|
||||
var callJob = rpc.declare({ object: 'mihomo-kit', method: 'job', expect: { '': {} } });
|
||||
var callGroup = rpc.declare({ object: 'mihomo-kit', method: 'group', params: [ 'group', 'action', 'name', 'url' ],
|
||||
nobatch: true, expect: { '': {} } });
|
||||
|
||||
function checked(r) {
|
||||
if (r && r.error)
|
||||
throw new Error(r.error);
|
||||
return r;
|
||||
}
|
||||
|
||||
function wait(ms) {
|
||||
return new Promise(function(resolve) { window.setTimeout(resolve, ms); });
|
||||
}
|
||||
|
||||
// the job to its end (rpcd may be unreachable while nikki restarts): its output on failure
|
||||
function followJob() {
|
||||
var errors = 0;
|
||||
var loop = function() {
|
||||
return wait(1500).then(callJob).then(function(j) {
|
||||
errors = 0;
|
||||
if (j.running)
|
||||
return loop();
|
||||
if (j.rc !== 0)
|
||||
throw new Error((j.log || 'ошибка').trim().split('\n').slice(-3).join('\n'));
|
||||
return j;
|
||||
}, function(e) {
|
||||
if (++errors > 20)
|
||||
throw e;
|
||||
return loop();
|
||||
});
|
||||
};
|
||||
return loop();
|
||||
}
|
||||
|
||||
// the YAML reader of the own servers (luci/servers.js) and the graph: globals mkServers, mkGraph
|
||||
function loadScript(name, global) {
|
||||
var version = '__MIHOMO_KIT_ASSETS__'; // substituted by install_luci
|
||||
if (window[global] && window[global + 'Version'] === version)
|
||||
return Promise.resolve(window[global]);
|
||||
return new Promise(function(resolve, reject) {
|
||||
var s = document.createElement('script');
|
||||
s.src = L.resource('mihomo-kit/' + name) + '?v=' + version;
|
||||
s.onload = function() { window[global + 'Version'] = version; resolve(window[global]); };
|
||||
s.onerror = function() { reject(new Error(name + ' not loaded')); };
|
||||
document.head.appendChild(s);
|
||||
});
|
||||
}
|
||||
|
||||
return view.extend({
|
||||
load: function() {
|
||||
return Promise.all([ loadScript('servers.js', 'mkServers'), loadScript('graph.js', 'mkGraph'), callGraph(''), callStatus() ]);
|
||||
},
|
||||
|
||||
// /proxies and /providers/proxies every 9 s, /connections every 3 s; only for the running
|
||||
// profile and a visible tab
|
||||
// one poll; full: also the groups and the subscriptions' nodes
|
||||
fetchLive: function(full) {
|
||||
return Promise.all([ full ? callApi('/proxies') : null, callApi('/connections'), full ? callApi('/providers/proxies') : null ]).then(L.bind(function(r) {
|
||||
r.forEach(checked);
|
||||
this.graph.live(r[0] && r[0].proxies, r[1].connections || [], r[2] && r[2].providers);
|
||||
dom.content(this.state, '');
|
||||
}, this)).catch(L.bind(function(e) {
|
||||
dom.content(this.state, E('em', 'живое состояние недоступно: ' + (e.message || e)));
|
||||
}, this));
|
||||
},
|
||||
|
||||
poll: function() {
|
||||
var tick = 0;
|
||||
var loop = L.bind(function() {
|
||||
if (document.hidden || !this.liveOn)
|
||||
return void (this.timer = window.setTimeout(loop, 3000));
|
||||
this.fetchLive(tick++ % 3 == 0).then(L.bind(function() {
|
||||
this.timer = window.setTimeout(loop, 3000);
|
||||
}, this));
|
||||
}, this);
|
||||
loop();
|
||||
},
|
||||
|
||||
show: function(g) {
|
||||
if (g.error) {
|
||||
dom.content(this.state, E('p', { 'class': 'alert-message warning' }, g.error));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
this.graph.show(window.mkServers.yamlLoad(g.yaml),
|
||||
{ services: g.services || [], pools: g.pools || [], servers: g.servers || [], subs: g.subs || [], hostlists: g.hostlists || [] });
|
||||
} catch (e) {
|
||||
dom.content(this.state, E('p', { 'class': 'alert-message warning' }, 'Не разобрал профиль: ' + e.message));
|
||||
return;
|
||||
}
|
||||
this.liveOn = g.active && g.profile == g.running;
|
||||
dom.content(this.state, this.liveOn ? '' : E('em', g.profile == g.running ? 'nikki остановлен: только схема'
|
||||
: 'профиль ' + g.profile + ' сейчас не запущен: только схема, без живого состояния'));
|
||||
},
|
||||
|
||||
render: function(data) {
|
||||
var g = data[2], st = data[3];
|
||||
this.state = E('div', { 'style': 'margin:.3em 0' });
|
||||
var box = E('div');
|
||||
var select = this.profileSelect = E('select', { 'class': 'cbi-input-select', 'change': L.bind(function(ev) {
|
||||
return callGraph(ev.target.value).then(L.bind(this.show, this));
|
||||
}, this) });
|
||||
(st.profiles || []).forEach(function(p) {
|
||||
select.appendChild(E('option', { 'value': p }, p + (p == st.profile ? ' (запущен)' : '')));
|
||||
});
|
||||
select.value = g.profile || st.profile;
|
||||
var page = E([], [
|
||||
E('h2', 'mihomo-kit: граф'),
|
||||
E('div', { 'class': 'cbi-map-descr' }, 'Как устроен профиль: правила (сверху вниз — в порядке проверки) → группы → ' +
|
||||
'подписки и серверы → через что они подключаются (dialer-proxy). Наведи или нажми на узел — подсветится всё, ' +
|
||||
'что через него идёт; колесо — масштаб, перетаскивание — сдвиг. Для запущенного профиля видно, что выбрано ' +
|
||||
'в группах сейчас и куда идут соединения; нажми на группу — выбрать или закрепить пункт (сразу, без ' +
|
||||
'перезапуска). Настройки — на странице «Управление».'),
|
||||
E('div', { 'style': 'margin:.5em 0' }, [ 'Профиль: ', select ]),
|
||||
this.state,
|
||||
box
|
||||
]);
|
||||
// once the page is in the document: the graph fits its box and takes the theme's background
|
||||
window.setTimeout(L.bind(function() {
|
||||
this.graph = window.mkGraph.view(box, {
|
||||
select: function(g, name) { return callGroup(g, 'select', name, '').then(checked); },
|
||||
unfix: function(g) { return callGroup(g, 'unfix', '', '').then(checked); },
|
||||
delay: function(g, url) { return callGroup(g, 'delay', '', url || '').then(checked); },
|
||||
refresh: L.bind(function() { return this.fetchLive(true); }, this),
|
||||
saveServices: L.bind(function(list, pools) {
|
||||
return callServicesSet(list, pools).then(checked).then(followJob).then(L.bind(function() {
|
||||
return callGraph(this.profileSelect.value);
|
||||
}, this)).then(L.bind(function(r) {
|
||||
this.show(checked(r));
|
||||
return this.fetchLive(true);
|
||||
}, this));
|
||||
}, this)
|
||||
});
|
||||
this.show(g);
|
||||
this.poll();
|
||||
}, this), 0);
|
||||
return page;
|
||||
},
|
||||
|
||||
handleSave: null,
|
||||
handleSaveApply: null,
|
||||
handleReset: null
|
||||
});
|
||||
1241
luci/mihomo-kit.js
1241
luci/mihomo-kit.js
File diff suppressed because it is too large
Load Diff
423
luci/rpcd.sh
423
luci/rpcd.sh
@ -3,27 +3,13 @@
|
||||
#
|
||||
# status profile, nikki running, which features are on, kit version,
|
||||
# mihomo API port/secret (dashboard link)
|
||||
# ovpn_status OpenVPN state (ovpn.sh state: mode, schedule, tunnel from the core,
|
||||
# no traffic) + the current one-time code (with TOTP)
|
||||
# ovpn_probe delay to OVPN_CHECK_URL through the tunnel (a request the site can log)
|
||||
# csqtt_status CSQTT state (mihomo-kit.sh csqtt state: csqtt status + group UPLINK)
|
||||
# ovpn_status OpenVPN state (up/down/off, delay to OVPN_CHECK_URL) + current OTP
|
||||
# run start a whitelisted command as the background job
|
||||
# job the job's command, state, exit code and output
|
||||
# update_check latest kit commit on the git server vs the installed one
|
||||
# ts_check Tailscale delay test to TS_CHECK_URL through the mihomo API
|
||||
# export all settings as one text file (mihomo-kit.sh export)
|
||||
# import {data, keep_local}: replace the settings with an export, as the job
|
||||
# config_get settings for the form (secrets: only whether they are set)
|
||||
# config_set save the form (via "mihomo-kit.sh configure") as the job
|
||||
# graph {profile}: the built profile's YAML for the graph page (default: the running one)
|
||||
# and the services and pools of the settings (+ servers, subs: what a pool can take;
|
||||
# hostlists: the zapret lists a service can take)
|
||||
# api {path}: GET /proxies, /connections or /providers/proxies of the mihomo API
|
||||
# services_set {services: [{name, geosite, domains, ips, via, chain, server, provider, hostlist}], pools: [{name, type, servers,
|
||||
# subs, filter, exclude, uplink}]}: replace the services and pools ("mihomo-kit.sh services")
|
||||
# as the job
|
||||
# group {group, action, name, url}: select (pick / pin name), unfix (back to automatic),
|
||||
# delay (test every member against url) - the graph page, through the mihomo API
|
||||
#
|
||||
# rpcd kills calls after ~30 s; use/update/ts-login take longer, hence the job.
|
||||
|
||||
@ -49,7 +35,7 @@ q() { printf "'%s'" "$(printf '%s' "$1" | sed "s/'/'\\\\''/g")"; }
|
||||
|
||||
job_running() { [ -f "$JOB/pid" ] && kill -0 "$(cat "$JOB/pid")" 2>/dev/null; }
|
||||
|
||||
# mihomo API base URL from nikki's mixin settings (as in ovpn.sh)
|
||||
# mihomo API base URL from nikki's mixin settings (as in bmstu-otp.sh)
|
||||
api_url() {
|
||||
l=$(uci -q get nikki.mixin.api_listen)
|
||||
port=${l##*:} host=${l%:*}
|
||||
@ -82,23 +68,8 @@ m_status() {
|
||||
json_close_array
|
||||
json_add_boolean openvpn "$(b test "$(envval OPENVPN "$prof")" = 1)"
|
||||
json_add_boolean tailscale "$(b test "$(envval TAILSCALE "$prof")" = 1)"
|
||||
json_add_boolean csqtt "$(b test "$(envval CSQTT "$prof")" = 1)"
|
||||
json_add_boolean csqtt_installed "$(b command -v csqtt)"
|
||||
json_add_boolean lite "$(b test "$(envval LITE "$prof")" = 1)"
|
||||
pid=$(pidof mihomo)
|
||||
json_add_int mem_kb "$(awk '/^VmRSS:/ {print $2}' "/proc/${pid%% *}/status" 2>/dev/null)"
|
||||
json_add_boolean ts_logged_in "$(b grep -q _current-profile "$NIKKI_DIR/run/tailscale/tailscaled.state")"
|
||||
json_add_string kit_version "$(cat "$NIKKI_DIR/kit/VERSION" 2>/dev/null)"
|
||||
# installed core vs the one the kit pins (MIHOMO_VERSION default in mihomo-kit.sh)
|
||||
json_add_string core_version "$(mihomo -v 2>/dev/null | awk '{print $3; exit}')"
|
||||
# choice, wanted, ok, stock/official/kit versions, free_kb, need_kb
|
||||
json_add_object core
|
||||
mihomo-kit.sh core-info > /tmp/mihomo-kit-core.$$ 2>/dev/null
|
||||
while read -r k v; do
|
||||
json_add_string "$k" "$v"
|
||||
done < /tmp/mihomo-kit-core.$$
|
||||
rm -f /tmp/mihomo-kit-core.$$
|
||||
json_close_object
|
||||
json_add_boolean auto_update "$(b grep -q 'mihomo-kit.sh auto-update' /etc/crontabs/root)"
|
||||
# phone config (MOBILE=1): /mihomo-kit/<token>.yaml served by uhttpd
|
||||
mob=$(ls /www/mihomo-kit/*.yaml 2>/dev/null | head -n 1)
|
||||
@ -138,43 +109,16 @@ delay_check() {
|
||||
|
||||
m_ovpn_status() {
|
||||
json_init
|
||||
# what decides the tunnel now and the next change (ovpn.sh state); only
|
||||
# known keys with plain values get through to eval
|
||||
eval "$(ovpn.sh state 2>/dev/null |
|
||||
sed -En -e 's/^(mode|want|tunnel|link|up_since|up_hm|up_day|retry_hm|retry_why|until|until_hm|until_day|after|why|next|next_to|next_hm|next_day|win|sched|sched_active|timer_max|sched_start|sched_end|sched_days|jitter)=([A-Za-z0-9:._-]*)$/st_\1=\2/p' \
|
||||
-e "s/^err='([^'\`\$\\\\]*)'\$/st_err='\\1'/p")"
|
||||
for k in mode tunnel link up_hm up_day retry_hm retry_why err until_hm until_day after why next_to next_hm next_day win sched_start sched_end sched_days; do
|
||||
eval "json_add_string $k \"\${st_$k:-}\""
|
||||
done
|
||||
for k in want up_since until next sched sched_active timer_max jitter; do
|
||||
eval "json_add_int $k \"\${st_$k:-0}\""
|
||||
done
|
||||
json_add_string otp "$(ovpn.sh otp 2>/dev/null)"
|
||||
json_add_int otp_left "$((30 - $(date +%s) % 30))"
|
||||
json_dump
|
||||
}
|
||||
|
||||
m_csqtt_status() {
|
||||
json_init
|
||||
# only known keys with plain values get through to eval (as in m_ovpn_status)
|
||||
eval "$(mihomo-kit.sh csqtt state 2>/dev/null |
|
||||
sed -En -e 's/^(link|enabled|uplink|active|stage|captcha)=([A-Za-z0-9:._-]*)$/cq_\1=\2/p' \
|
||||
-e "s/^(err|stats)='([^'\`\$\\\\]*)'\$/cq_\\1='\\2'/p")"
|
||||
for k in link uplink active stage err stats; do
|
||||
eval "json_add_string $k \"\${cq_$k:-}\""
|
||||
done
|
||||
json_add_boolean enabled "${cq_enabled:-0}"
|
||||
json_add_int captcha "${cq_captcha:-0}"
|
||||
json_dump
|
||||
}
|
||||
|
||||
# by hand only: the site sees the request (HEAD from a Go client)
|
||||
m_ovpn_probe() {
|
||||
json_init
|
||||
if [ -f "$NIKKI_DIR/bmstu.off" ]; then
|
||||
json_add_string state off
|
||||
else
|
||||
prof=$(uci -q get nikki.config.profile)
|
||||
prof=${prof#file:}
|
||||
group=$(envval OVPN_GROUP "${prof%.yaml}")
|
||||
delay_check "${group:-OPENVPN}" OVPN_CHECK_URL https://www.gstatic.com/generate_204
|
||||
delay_check "${group:-BMSTU}" OVPN_CHECK_URL https://eu.bmstu.ru
|
||||
fi
|
||||
json_add_string otp "$(bmstu-otp.sh otp 2>/dev/null)"
|
||||
json_add_int otp_left "$((30 - $(date +%s) % 30))"
|
||||
json_dump
|
||||
}
|
||||
|
||||
@ -183,42 +127,20 @@ m_run() {
|
||||
cmd=$(jsonfilter -s "$input" -e '@.cmd' 2>/dev/null)
|
||||
arg=$(jsonfilter -s "$input" -e '@.arg' 2>/dev/null)
|
||||
case "$cmd" in
|
||||
ovpn-on) set -- ovpn.sh on ;;
|
||||
ovpn-off) set -- ovpn.sh off ;;
|
||||
ovpn-refresh) set -- ovpn.sh refresh ;;
|
||||
ovpn-for | ovpn-extend)
|
||||
case "$arg" in '' | *[!0-9]* | 0) reply_error "bad minutes" ;; esac
|
||||
set -- ovpn.sh "${cmd#ovpn-}" "$arg"
|
||||
;;
|
||||
ovpn-stop) set -- ovpn.sh stop ;;
|
||||
ovpn-sched)
|
||||
# arg: "off" | "on" | "HH:MM HH:MM [DAYS]" (DAYS: digits 1..7); unquoted below to split
|
||||
case "$arg" in
|
||||
off | on | [0-9][0-9]:[0-9][0-9]\ [0-9][0-9]:[0-9][0-9]) ;;
|
||||
[0-9][0-9]:[0-9][0-9]\ [0-9][0-9]:[0-9][0-9]\ [1-7]*)
|
||||
case "${arg#* * }" in *[!1-7]*) reply_error "bad schedule days" ;; esac
|
||||
;;
|
||||
*) reply_error "bad schedule" ;;
|
||||
esac
|
||||
set -- ovpn.sh sched $arg
|
||||
;;
|
||||
ovpn-on) set -- bmstu-otp.sh on ;;
|
||||
ovpn-off) set -- bmstu-otp.sh off ;;
|
||||
ovpn-refresh) set -- bmstu-otp.sh refresh ;;
|
||||
use)
|
||||
case "$arg" in '' | *[!A-Za-z0-9_-]*) reply_error "bad profile name" ;; esac
|
||||
[ -f "$NIKKI_DIR/profiles/$arg.yaml" ] || reply_error "no profile $arg"
|
||||
set -- mihomo-kit.sh use "$arg"
|
||||
;;
|
||||
ts-login) set -- mihomo-kit.sh ts-login ;;
|
||||
csqtt-on) set -- mihomo-kit.sh csqtt on ;;
|
||||
csqtt-off) set -- mihomo-kit.sh csqtt off ;;
|
||||
ts-relogin) set -- mihomo-kit.sh ts-login -f ;;
|
||||
build | update | fix) set -- mihomo-kit.sh "$cmd" ;;
|
||||
autoupdate-on) set -- mihomo-kit.sh auto-update on ;;
|
||||
autoupdate-off) set -- mihomo-kit.sh auto-update off ;;
|
||||
mobile-new) set -- mihomo-kit.sh mobile new ;;
|
||||
core)
|
||||
case "$arg" in stock | official | kit) ;; *) reply_error "bad core choice" ;; esac
|
||||
set -- mihomo-kit.sh core "$arg"
|
||||
;;
|
||||
*) reply_error "unknown command: $cmd" ;;
|
||||
esac
|
||||
start_job "$@"
|
||||
@ -243,7 +165,7 @@ start_job() {
|
||||
|
||||
m_config_get() {
|
||||
[ -f "$PROFILES_D/common.env" ] && . "$PROFILES_D/common.env"
|
||||
[ -f "$NIKKI_DIR/openvpn.env" ] && . "$NIKKI_DIR/openvpn.env"
|
||||
[ -f "$NIKKI_DIR/bmstu.env" ] && . "$NIKKI_DIR/bmstu.env"
|
||||
[ -f /etc/openwrt_release ] && . /etc/openwrt_release
|
||||
json_init
|
||||
json_add_boolean configured "$(b test -f "$PROFILES_D/common.env")"
|
||||
@ -265,7 +187,7 @@ m_config_get() {
|
||||
K=$(echo "$id" | tr 'a-z' 'A-Z')
|
||||
eval "p=\${SUB_${K}_PROXY:-\${SUB${i}_PROXY:-}} h=\${SUB_${K}_HWID:-\${SUB${i}_HWID:-0}}
|
||||
off=\${SUB_${K}_DISABLED:-\${SUB${i}_DISABLED:-0}}"
|
||||
[ -n "$p" ] || p=BOOT-AUTO
|
||||
[ -n "$p" ] || { [ "${BOOT:-0}" = 1 ] && p=BOOT-AUTO || p=DIRECT; }
|
||||
json_add_object ""
|
||||
json_add_string id "$id"
|
||||
json_add_string url "$w"
|
||||
@ -283,57 +205,19 @@ m_config_get() {
|
||||
json_add_string hwid_os_ver "${HWID_OS_VER:-${DISTRIB_RELEASE:-}}"
|
||||
json_add_string hwid_model "${HWID_MODEL:-$(cat /tmp/sysinfo/model 2>/dev/null)}"
|
||||
json_add_string hwid_id "${HWID_ID:-$(md5sum < /sys/class/net/br-lan/address 2>/dev/null | cut -c1-16)}"
|
||||
# a new router: torrents and push off, the phone config on
|
||||
json_add_boolean torrent "${TORRENT:-0}"
|
||||
json_add_boolean push "${PUSH:-0}"
|
||||
json_add_boolean torrent "${TORRENT:-1}"
|
||||
json_add_string ru_ips "${RU_IPS:-}"
|
||||
json_add_string foreign_ips "${FOREIGN_IPS:-}"
|
||||
json_add_string my_ips "${MY_IPS:-}"
|
||||
json_add_string ru_domains "${RU_DOMAINS:-}"
|
||||
json_add_string foreign_domains "${FOREIGN_DOMAINS:-}"
|
||||
json_add_string my_domains "${MY_DOMAINS:-}"
|
||||
json_add_string local_hosts "${LOCAL_HOSTS:-}"
|
||||
json_add_string bypass_clients "${BYPASS_CLIENTS:-}"
|
||||
# [MY] nodes of the subscriptions with an entry of their own: "<ENTRY>|<id>-my|<name>" lines
|
||||
# (MY_NODE_1, MY_NODE_2, ... in common.env)
|
||||
json_add_string my_node_entries "$(
|
||||
_mk=1
|
||||
while eval "[ -n \"\${MY_NODE_$_mk+x}\" ]"; do
|
||||
eval "printf '%s\n' \"\$MY_NODE_$_mk\""
|
||||
_mk=$((_mk + 1))
|
||||
done
|
||||
)"
|
||||
blocks_json services "${SERVICES:-}" SVC geosite domains ips via chain server provider hostlist
|
||||
blocks_json pools "${POOLS:-}" POOL type servers subs filter exclude uplink
|
||||
hostlist_files
|
||||
# own servers: one JSON proxy per line (luci/servers.js); the old hy2 / my_links
|
||||
# below are moved into it by the page on the next save
|
||||
json_add_string servers_text "$(cat "$NIKKI_DIR/my-servers" 2>/dev/null)"
|
||||
# own servers as links: one per line in the form
|
||||
set -f
|
||||
json_add_string my_links "$(printf '%s\n' ${MY_LINKS:-})"
|
||||
set +f
|
||||
json_add_boolean openvpn "${OPENVPN:-0}"
|
||||
json_add_boolean csqtt "${CSQTT:-0}"
|
||||
json_add_boolean ovpn_file "$(b test -f "$NIKKI_DIR/openvpn.ovpn")"
|
||||
json_add_string ovpn_routes "${OVPN_ROUTES:-}"
|
||||
json_add_string pass_format "${PASS_FORMAT:-auto}"
|
||||
json_add_boolean ovpn_file "$(b test -f "$NIKKI_DIR/bmstu.ovpn")"
|
||||
json_add_string vpn_username "${VPN_USERNAME:-}"
|
||||
json_add_boolean has_vpn_password "$(b test -n "${VPN_PASSWORD:-}")"
|
||||
json_add_boolean has_totp "$(b test -n "${TOTP_SECRET:-}")"
|
||||
json_add_boolean tailscale "${TAILSCALE:-0}"
|
||||
json_add_string ts_hostname "${TS_HOSTNAME:-$(uci -q get 'system.@system[0].hostname' | tr 'A-Z' 'a-z')-mihomo}"
|
||||
json_add_string ts_domains "${TS_DOMAINS:-}"
|
||||
json_add_string ovpn_check_url "${OVPN_CHECK_URL:-}"
|
||||
json_add_string ovpn_check_url "${OVPN_CHECK_URL:-https://eu.bmstu.ru}"
|
||||
json_add_string ts_check_url "${TS_CHECK_URL:-http://100.69.216.50:8080}"
|
||||
# common.env has MOBILE=1 only when on
|
||||
if [ -f "$PROFILES_D/common.env" ]; then
|
||||
json_add_boolean mobile "${MOBILE:-0}"
|
||||
else
|
||||
json_add_boolean mobile 1
|
||||
fi
|
||||
json_add_boolean lite "${LITE:-0}"
|
||||
json_add_string lite_gomemlimit "${LITE_GOMEMLIMIT:-}"
|
||||
json_add_array hy2
|
||||
for n in ${HY2:-}; do
|
||||
k=HY2_$(echo "$n" | tr 'a-z-' 'A-Z_')
|
||||
@ -349,38 +233,21 @@ m_config_get() {
|
||||
json_dump
|
||||
}
|
||||
|
||||
# {"data": {boot_links (one per line), subs: [{url, via, hwid}], hwid_*, torrent, push, ru_ips,
|
||||
# foreign_ips, my_ips, ru_domains, foreign_domains, my_domains, local_hosts, my_links (one per line),
|
||||
# services: [{name, geosite, domains, ips, via, chain, server, provider, hostlist}], pools: [{name, type, servers, subs, filter, exclude, uplink}],
|
||||
# servers_text (own servers, one JSON proxy per line: written to /etc/nikki/my-servers),
|
||||
# openvpn, csqtt, ovpn (file text, optional), vpn_username, vpn_password, totp_secret,
|
||||
# totp_clear (1: no codes any more), pass_format, ovpn_routes (only from a page that has it),
|
||||
# tailscale, ts_hostname, ts_domains, lite, lite_gomemlimit, hy2: [{name, server, port, password,
|
||||
# {"data": {boot_links (one per line), subs: [{url, via, hwid}], hwid_*, torrent, ru_ips,
|
||||
# openvpn, ovpn (file text, optional), vpn_username, vpn_password, totp_secret,
|
||||
# tailscale, ts_hostname, ts_domains, hy2: [{name, server, port, password,
|
||||
# obfs_password, sni, insecure, up, down}]}}; empty OpenVPN secrets keep the saved ones
|
||||
m_config_set() {
|
||||
json_load "$(cat)" || reply_error "bad request"
|
||||
json_select data || reply_error "no data"
|
||||
job_running && reply_error "busy: $(cat "$JOB/cmd")"
|
||||
for v in boot_links hwid_ua hwid_os hwid_os_ver hwid_model hwid_id torrent push ru_ips foreign_ips my_ips \
|
||||
ru_domains foreign_domains my_domains local_hosts my_links openvpn csqtt ovpn \
|
||||
vpn_username vpn_password totp_secret totp_clear pass_format tailscale ts_hostname ts_domains ovpn_check_url \
|
||||
ts_check_url mobile lite lite_gomemlimit; do
|
||||
for v in boot_links hwid_ua hwid_os hwid_os_ver hwid_model hwid_id torrent ru_ips openvpn ovpn \
|
||||
vpn_username vpn_password totp_secret tailscale ts_hostname ts_domains ovpn_check_url ts_check_url mobile; do
|
||||
json_get_var "$v" "$v" ""
|
||||
done
|
||||
# own servers: only a page that sends them (an old cached one sends hy2 instead)
|
||||
json_get_type _st servers_text
|
||||
if [ -n "$_st" ]; then
|
||||
json_get_var servers_text servers_text ""
|
||||
umask 077
|
||||
if [ -n "$servers_text" ]; then
|
||||
printf '%s\n' "$servers_text" > "$NIKKI_DIR/my-servers.tmp" && mv "$NIKKI_DIR/my-servers.tmp" "$NIKKI_DIR/my-servers"
|
||||
else
|
||||
rm -f "$NIKKI_DIR/my-servers"
|
||||
fi
|
||||
fi
|
||||
if [ -n "$ovpn" ]; then
|
||||
umask 077
|
||||
printf '%s\n' "$ovpn" > "$NIKKI_DIR/openvpn.ovpn.tmp" && mv "$NIKKI_DIR/openvpn.ovpn.tmp" "$NIKKI_DIR/openvpn.ovpn"
|
||||
printf '%s\n' "$ovpn" > "$NIKKI_DIR/bmstu.ovpn.tmp" && mv "$NIKKI_DIR/bmstu.ovpn.tmp" "$NIKKI_DIR/bmstu.ovpn"
|
||||
fi
|
||||
umask 077
|
||||
env=$(mktemp /tmp/mihomo-kit-form.XXXXXX) || reply_error "mktemp failed"
|
||||
@ -411,42 +278,11 @@ m_config_set() {
|
||||
echo "HWID_MODEL=$(q "$hwid_model")"
|
||||
echo "HWID_ID=$(q "$hwid_id")"
|
||||
echo "TORRENT=$(q "${torrent:-0}")"
|
||||
echo "PUSH=$(q "${push:-0}")"
|
||||
echo "RU_IPS=$(q "$ru_ips")"
|
||||
echo "FOREIGN_IPS=$(q "$foreign_ips")"
|
||||
echo "MY_IPS=$(q "$my_ips")"
|
||||
echo "RU_DOMAINS=$(q "$ru_domains")"
|
||||
echo "FOREIGN_DOMAINS=$(q "$foreign_domains")"
|
||||
echo "MY_DOMAINS=$(q "$my_domains")"
|
||||
echo "LOCAL_HOSTS=$(q "$local_hosts")"
|
||||
# one link per line; a space is never part of a link (a name with spaces after # -> %20)
|
||||
echo "MY_LINKS=$(q "$(printf '%s\n' "$my_links" | sed 's/^[[:space:]]*//; s/[[:space:]]*$//; s/[[:space:]]/%20/g' | grep . | tr '\n' ' ' | sed 's/ $//')")"
|
||||
echo "OPENVPN=$(q "${openvpn:-0}")"
|
||||
echo "CSQTT=$(q "${csqtt:-0}")"
|
||||
echo "VPN_USERNAME=$(q "$vpn_username")"
|
||||
[ -n "$vpn_password" ] && echo "VPN_PASSWORD=$(q "$vpn_password")"
|
||||
if [ "$totp_clear" = 1 ]; then
|
||||
echo "TOTP_SECRET=''"
|
||||
elif [ -n "$totp_secret" ]; then
|
||||
echo "TOTP_SECRET=$(q "$totp_secret")"
|
||||
fi
|
||||
case "$pass_format" in auto | scrv1 | otp-last | otp-first) echo "PASS_FORMAT=$pass_format" ;; esac
|
||||
# an old cached page does not send these: the saved ones stay
|
||||
json_get_type _bc bypass_clients
|
||||
if [ -n "$_bc" ]; then
|
||||
json_get_var bypass_clients bypass_clients ""
|
||||
echo "BYPASS_CLIENTS=$(q "$(echo $bypass_clients)")"
|
||||
fi
|
||||
json_get_type _me my_node_entries
|
||||
if [ -n "$_me" ]; then
|
||||
json_get_var my_node_entries my_node_entries ""
|
||||
echo "MY_NODE_ENTRIES=$(q "$my_node_entries")"
|
||||
fi
|
||||
json_get_type _rt ovpn_routes
|
||||
if [ -n "$_rt" ]; then
|
||||
json_get_var ovpn_routes ovpn_routes ""
|
||||
echo "OVPN_ROUTES=$(q "$(echo $ovpn_routes)")"
|
||||
fi
|
||||
[ -n "$totp_secret" ] && echo "TOTP_SECRET=$(q "$totp_secret")"
|
||||
echo "TAILSCALE=$(q "${tailscale:-0}")"
|
||||
echo "TS_HOSTNAME=$(q "$ts_hostname")"
|
||||
echo "TS_DOMAINS=$(q "$ts_domains")"
|
||||
@ -454,8 +290,6 @@ m_config_set() {
|
||||
echo "OVPN_CHECK_URL=$(q "$ovpn_check_url")"
|
||||
echo "TS_CHECK_URL=$(q "$ts_check_url")"
|
||||
echo "MOBILE=$(q "${mobile:-0}")"
|
||||
echo "LITE=$(q "${lite:-0}")"
|
||||
echo "LITE_GOMEMLIMIT=$(q "$lite_gomemlimit")"
|
||||
hy2=
|
||||
if json_select hy2; then
|
||||
json_get_keys keys
|
||||
@ -476,186 +310,11 @@ m_config_set() {
|
||||
json_select ..
|
||||
fi
|
||||
echo "HY2=$(q "$hy2")"
|
||||
blocks_env services SERVICES SVC geosite domains ips via chain server provider hostlist
|
||||
blocks_env pools POOLS POOL type servers subs filter exclude uplink
|
||||
} > "$env"
|
||||
umask 022
|
||||
start_job mihomo-kit.sh configure "$env"
|
||||
}
|
||||
|
||||
# blocks_json <array> <names> <key prefix> <fields...>: SERVICES / POOLS of the sourced
|
||||
# settings as an array of {name, <field>...} (keys <prefix>_<NAME>_<FIELD>)
|
||||
blocks_json() {
|
||||
_arr=$1 _list=$2 _pre=$3
|
||||
shift 3
|
||||
json_add_array "$_arr"
|
||||
for n in $_list; do
|
||||
k=${_pre}_$(echo "$n" | tr 'a-z-' 'A-Z_')
|
||||
json_add_object ""
|
||||
json_add_string name "$n"
|
||||
for v in "$@"; do
|
||||
eval "val=\${${k}_$(echo "$v" | tr 'a-z' 'A-Z'):-}"
|
||||
json_add_string "$v" "$val"
|
||||
done
|
||||
json_close_object
|
||||
done
|
||||
json_close_array
|
||||
}
|
||||
|
||||
# blocks_env <array> <LIST key> <key prefix> <fields...>: the request's array as env lines
|
||||
# (<prefix>_<NAME>_<FIELD>=..., then LIST=names); no such array in the request: no lines
|
||||
blocks_env() {
|
||||
_arr=$1 _var=$2 _pre=$3
|
||||
shift 3
|
||||
json_get_type _t "$_arr"
|
||||
[ "$_t" = array ] || return 0
|
||||
_names=
|
||||
json_select "$_arr"
|
||||
json_get_keys _keys
|
||||
for _i in $_keys; do
|
||||
json_select "$_i"
|
||||
json_get_var name name ""
|
||||
name=$(printf '%s' "$name" | tr -d ' \t\r\n')
|
||||
if [ -n "$name" ]; then
|
||||
_names="${_names:+$_names }$name"
|
||||
K=${_pre}_$(echo "$name" | tr 'a-z-' 'A-Z_')
|
||||
for v in "$@"; do
|
||||
json_get_var val "$v" ""
|
||||
[ -n "$val" ] && echo "${K}_$(echo "$v" | tr 'a-z' 'A-Z')=$(q "$val")"
|
||||
done
|
||||
fi
|
||||
json_select ..
|
||||
done
|
||||
json_select ..
|
||||
echo "$_var=$(q "$_names")"
|
||||
}
|
||||
|
||||
# zapret hostlists a service can take (SVC_<NAME>_HOSTLIST): [{path, lines}] - the
|
||||
# domain lists of zapret2 / zapret (not the exclude lists, not the IP sets)
|
||||
hostlist_files() {
|
||||
json_add_array hostlists
|
||||
for f in /opt/zapret2/ipset/* /opt/zapret/ipset/*; do
|
||||
[ -f "$f" ] || continue
|
||||
case "${f##*/}" in *exclude*) continue ;; *host*.txt | *host*.txt.gz | *host*.lst) ;; *) continue ;; esac
|
||||
json_add_object ""
|
||||
json_add_string path "$f"
|
||||
case "$f" in *.gz) n=$(gzip -dc "$f" 2>/dev/null | grep -c '^[^#]') ;; *) n=$(grep -c '^[^#]' "$f") ;; esac
|
||||
json_add_int lines "${n:-0}"
|
||||
json_close_object
|
||||
done
|
||||
json_close_array
|
||||
}
|
||||
|
||||
# what a pool can take: own servers by name, providers of the subscriptions ("<id>", "<id>-my")
|
||||
pool_sources() {
|
||||
# not a pipe: json_add_* must run in this shell
|
||||
json_add_array servers
|
||||
grep -v '^[[:space:]]*$' "$NIKKI_DIR/my-servers" > /tmp/mihomo-kit-srv.$$ 2>/dev/null
|
||||
while IFS= read -r l; do
|
||||
json_add_string "" "$(jsonfilter -s "$l" -e '@.name')"
|
||||
done < /tmp/mihomo-kit-srv.$$
|
||||
rm -f /tmp/mihomo-kit-srv.$$
|
||||
for n in ${HY2:-}; do json_add_string "" "$n"; done
|
||||
json_close_array
|
||||
json_add_array subs
|
||||
SUBS=${SUBS:-} mihomo-kit.sh sub-ids > /tmp/mihomo-kit-ids.$$
|
||||
while read -r id w; do
|
||||
json_add_string "" "$id"
|
||||
json_add_string "" "$id-my"
|
||||
done < /tmp/mihomo-kit-ids.$$
|
||||
rm -f /tmp/mihomo-kit-ids.$$
|
||||
[ -n "${MY_LINKS:-}" ] && json_add_string "" my-links
|
||||
json_close_array
|
||||
}
|
||||
|
||||
m_graph() {
|
||||
json_load "$(cat)"
|
||||
json_get_var want profile ""
|
||||
prof=$(uci -q get nikki.config.profile)
|
||||
prof=${prof#file:}
|
||||
prof=${prof%.yaml}
|
||||
case "$want" in '' | *[!A-Za-z0-9_-]*) want=$prof ;; esac
|
||||
[ -f "$NIKKI_DIR/profiles/$want.yaml" ] || reply_error "нет профиля $want (mihomo-kit.sh build)"
|
||||
json_init
|
||||
json_add_string running "$prof"
|
||||
json_add_boolean active "$(b pidof mihomo)"
|
||||
json_add_string profile "$want"
|
||||
json_add_string yaml "$(cat "$NIKKI_DIR/profiles/$want.yaml")"
|
||||
# the services and pools, as config_get gives them, and what a pool can take: the graph edits these
|
||||
[ -f "$PROFILES_D/common.env" ] && . "$PROFILES_D/common.env"
|
||||
blocks_json services "${SERVICES:-}" SVC geosite domains ips via chain server provider hostlist
|
||||
blocks_json pools "${POOLS:-}" POOL type servers subs filter exclude uplink
|
||||
hostlist_files
|
||||
pool_sources
|
||||
json_dump
|
||||
}
|
||||
|
||||
m_services_set() {
|
||||
json_load "$(cat)"
|
||||
job_running && reply_error "busy: $(cat "$JOB/cmd")"
|
||||
umask 077
|
||||
env=$(mktemp /tmp/mihomo-kit-svc.XXXXXX) || reply_error "mktemp failed"
|
||||
{
|
||||
blocks_env services SERVICES SVC geosite domains ips via chain server provider hostlist
|
||||
blocks_env pools POOLS POOL type servers subs filter exclude uplink
|
||||
} > "$env"
|
||||
umask 022
|
||||
start_job mihomo-kit.sh services "$env"
|
||||
}
|
||||
|
||||
# the API's answer as it is: only these read-only paths
|
||||
m_api() {
|
||||
json_load "$(cat)"
|
||||
json_get_var path path ""
|
||||
case "$path" in /proxies | /connections | /providers/proxies) ;; *) reply_error "path not allowed" ;; esac
|
||||
sec=$(uci -q get nikki.mixin.api_secret)
|
||||
res=$(curl -fsS -m 10 ${sec:+-H "Authorization: Bearer $sec"} "$(api_url)$path" 2>&1) ||
|
||||
reply_error "mihomo API: $res"
|
||||
# connections without their metadata (flat, most of the size): the graph needs the
|
||||
# rule and chains, and ubus has a limit on the answer
|
||||
[ "$path" = /connections ] && res=$(printf '%s' "$res" | sed 's/"metadata":{[^}]*},//g')
|
||||
printf '%s\n' "$res"
|
||||
}
|
||||
|
||||
# api_call <curl args...>: the answer of the mihomo API, or reply_error with its message
|
||||
api_call() {
|
||||
sec=$(uci -q get nikki.mixin.api_secret)
|
||||
out=$(curl -sS -m 25 -w '\n%{http_code}' ${sec:+-H "Authorization: Bearer $sec"} "$@" 2>&1) ||
|
||||
reply_error "mihomo API: $out"
|
||||
code=$(printf '%s' "$out" | tail -n 1)
|
||||
body=$(printf '%s' "$out" | sed '$d')
|
||||
case "$code" in 2??) ;; *) reply_error "mihomo API: $(jsonfilter -s "$body" -e '@.message' 2>/dev/null || echo "HTTP $code")" ;; esac
|
||||
}
|
||||
|
||||
m_group() {
|
||||
json_load "$(cat)"
|
||||
json_get_vars group action name url
|
||||
# the kit's group names; anything else would need escaping in the URL
|
||||
case "$group" in '' | *[!A-Za-z0-9_.-]*) reply_error "bad group name" ;; esac
|
||||
case "$action" in
|
||||
select)
|
||||
json_init
|
||||
json_add_string name "$name"
|
||||
api_call -X PUT -H 'Content-Type: application/json' -d "$(json_dump)" "$(api_url)/proxies/$group"
|
||||
;;
|
||||
unfix)
|
||||
api_call -X DELETE "$(api_url)/proxies/$group"
|
||||
;;
|
||||
delay)
|
||||
api_call -G --data-urlencode "url=${url:-https://www.gstatic.com/generate_204}" \
|
||||
--data-urlencode timeout=5000 "$(api_url)/group/$group/delay"
|
||||
# {"name": ms} of the members that answered
|
||||
[ -n "$body" ] || body='{}'
|
||||
printf '%s\n' "$body"
|
||||
return
|
||||
;;
|
||||
*) reply_error "bad action" ;;
|
||||
esac
|
||||
json_init
|
||||
json_add_boolean ok 1
|
||||
json_dump
|
||||
}
|
||||
|
||||
m_ts_check() {
|
||||
json_init
|
||||
delay_check TAILSCALE TS_CHECK_URL http://100.69.216.50:8080
|
||||
@ -673,30 +332,6 @@ m_update_check() {
|
||||
json_dump
|
||||
}
|
||||
|
||||
m_export() {
|
||||
json_init
|
||||
json_add_string name "mihomo-kit-$(uci -q get 'system.@system[0].hostname')-$(date '+%Y%m%d').kit"
|
||||
json_add_string data "$(mihomo-kit.sh export 2>/dev/null)"
|
||||
json_dump
|
||||
}
|
||||
|
||||
m_import() {
|
||||
json_load "$(cat)" || reply_error "bad request"
|
||||
json_get_var data data ""
|
||||
json_get_var keep keep_local 0
|
||||
job_running && reply_error "busy: $(cat "$JOB/cmd")"
|
||||
umask 077
|
||||
f=$(mktemp /tmp/mihomo-kit-import.XXXXXX) || reply_error "mktemp failed"
|
||||
printf '%s\n' "$data" > "$f"
|
||||
umask 022
|
||||
head -n 1 "$f" | grep -q '^# mihomo-kit export v1' || { rm -f "$f"; reply_error "это не файл экспорта mihomo-kit"; }
|
||||
if [ "$keep" = 1 ]; then
|
||||
start_job mihomo-kit.sh import "$f" --keep-local
|
||||
else
|
||||
start_job mihomo-kit.sh import "$f"
|
||||
fi
|
||||
}
|
||||
|
||||
m_job() {
|
||||
json_init
|
||||
json_add_string cmd "$(cat "$JOB/cmd" 2>/dev/null)"
|
||||
@ -708,26 +343,18 @@ m_job() {
|
||||
|
||||
case "$1" in
|
||||
list)
|
||||
echo '{"status":{},"ovpn_status":{},"ovpn_probe":{},"csqtt_status":{},"job":{},"run":{"cmd":"str","arg":"str"},"config_get":{},"config_set":{"data":{}},"update_check":{},"ts_check":{},"export":{},"import":{"data":"str","keep_local":true},"graph":{"profile":"str"},"api":{"path":"str"},"group":{"group":"str","action":"str","name":"str","url":"str"},"services_set":{"services":[],"pools":[]}}'
|
||||
echo '{"status":{},"ovpn_status":{},"job":{},"run":{"cmd":"str","arg":"str"},"config_get":{},"config_set":{"data":{}},"update_check":{},"ts_check":{}}'
|
||||
;;
|
||||
call)
|
||||
case "$2" in
|
||||
status) m_status ;;
|
||||
ovpn_status) m_ovpn_status ;;
|
||||
ovpn_probe) m_ovpn_probe ;;
|
||||
csqtt_status) m_csqtt_status ;;
|
||||
job) m_job ;;
|
||||
run) m_run ;;
|
||||
config_get) m_config_get ;;
|
||||
config_set) m_config_set ;;
|
||||
update_check) m_update_check ;;
|
||||
ts_check) m_ts_check ;;
|
||||
export) m_export ;;
|
||||
import) m_import ;;
|
||||
graph) m_graph ;;
|
||||
api) m_api ;;
|
||||
group) m_group ;;
|
||||
services_set) m_services_set ;;
|
||||
*) reply_error "unknown method" ;;
|
||||
esac
|
||||
;;
|
||||
|
||||
1715
luci/servers.js
1715
luci/servers.js
File diff suppressed because it is too large
Load Diff
@ -1,3 +0,0 @@
|
||||
# foreign (abroad): .ru and ru-inside through the RU pool, the rest direct (MAIN: DIRECT,
|
||||
# own servers by hand), OpenVPN through OVPN-EXIT (a RU node), Tailscale and own servers direct
|
||||
LOCATION=foreign
|
||||
2
presets/home.env
Normal file
2
presets/home.env
Normal file
@ -0,0 +1,2 @@
|
||||
# home: OpenVPN/Tailscale go direct
|
||||
LOCATION=home
|
||||
@ -1,2 +0,0 @@
|
||||
# main: normal use (home in Russia or abroad): OpenVPN/Tailscale/own servers go direct
|
||||
LOCATION=main
|
||||
2
presets/street.env
Normal file
2
presets/street.env
Normal file
@ -0,0 +1,2 @@
|
||||
# street (whitelisted network): OpenVPN goes through OVPN-EXIT, pick a RU node in the dashboard
|
||||
LOCATION=street
|
||||
@ -1,3 +0,0 @@
|
||||
# whitelist (whitelisted network): OpenVPN through OVPN-EXIT (pick a RU node in the dashboard),
|
||||
# own servers through MY-EXIT, Tailscale through MY
|
||||
LOCATION=whitelist
|
||||
285
router/bmstu-otp.sh
Executable file
285
router/bmstu-otp.sh
Executable file
@ -0,0 +1,285 @@
|
||||
#!/bin/sh
|
||||
# OpenVPN (BMSTU) + TOTP for mihomo / nikki on OpenWrt.
|
||||
#
|
||||
# mihomo has no static-challenge support: the password in the proxy config is
|
||||
# static, and the tunnel is started lazily on first use. This script builds the
|
||||
# file proxy-provider from the .ovpn with a fresh OTP baked into the password,
|
||||
# reloads the provider via the mihomo API and immediately warms the tunnel up
|
||||
# (delay test) while the code is still valid. After that the server's
|
||||
# auth-token (if pushed) keeps rekeys alive without an OTP.
|
||||
#
|
||||
# Usage:
|
||||
# bmstu-otp.sh otp print the current TOTP code
|
||||
# bmstu-otp.sh authfile print username/password lines (openvpn auth-user-pass file)
|
||||
# bmstu-otp.sh refresh regenerate provider with fresh OTP, reload, warm up
|
||||
# bmstu-otp.sh check warm-up test; refresh only if the tunnel is dead (cron)
|
||||
# bmstu-otp.sh off close the tunnel and keep it closed (BMSTU traffic goes without it);
|
||||
# frees the single server session for another client
|
||||
# (the server drops the old session after its ping-restart, up to ~5 min)
|
||||
# bmstu-otp.sh on allow the tunnel again and bring it up
|
||||
# bmstu-otp.sh status on/off and whether the tunnel answers
|
||||
# bmstu-otp.sh debug show the real handshake error in the nikki log
|
||||
|
||||
set -u
|
||||
|
||||
ENV_FILE="${ENV_FILE:-/etc/nikki/bmstu.env}"
|
||||
[ -f "$ENV_FILE" ] && . "$ENV_FILE"
|
||||
|
||||
: "${OVPN_FILE:=/etc/nikki/bmstu.ovpn}"
|
||||
: "${PROVIDER_FILE:=/etc/nikki/run/providers/bmstu.yaml}"
|
||||
: "${PROVIDER_NAME:=bmstu}"
|
||||
: "${PROXY_NAME:=bmstu-ovpn}"
|
||||
: "${GROUP_NAME:=BMSTU}"
|
||||
# API address/secret: from nikki's mixin settings unless set in the env file
|
||||
uci_get() { uci -q get "$1" 2>/dev/null; }
|
||||
# api_listen is host:port; a wildcard/empty host means loopback works
|
||||
api_from_uci() {
|
||||
l=$(uci_get nikki.mixin.api_listen)
|
||||
port=${l##*:} host=${l%:*}
|
||||
case "$port" in '' | *[!0-9]*) port=9090 ;; esac
|
||||
case "$host" in '' | 0.0.0.0 | '[::]' | '::' | '*' | "$l") host=127.0.0.1 ;; esac
|
||||
echo "http://$host:$port"
|
||||
}
|
||||
: "${API:=$(api_from_uci)}"
|
||||
: "${API_SECRET:=$(uci_get nikki.mixin.api_secret)}"
|
||||
# while this file exists the tunnel stays off (bmstu-otp.sh off/on)
|
||||
: "${OFF_FLAG:=/etc/nikki/bmstu.off}"
|
||||
: "${CHECK_URL:=https://www.bmstu.ru}"
|
||||
# ms, must exceed HANDSHAKE_TIMEOUT (max 32767)
|
||||
: "${CHECK_TIMEOUT:=25000}"
|
||||
# otp-last - <password><otp> (what the BMSTU server accepts)
|
||||
# otp-first - <otp><password>
|
||||
# scrv1 - what openvpn sends for "static-challenge ... 1": SCRV1:b64(pass):b64(otp)
|
||||
: "${PASS_FORMAT:=otp-last}"
|
||||
: "${TOTP_DIGITS:=6}"
|
||||
: "${TOTP_PERIOD:=30}"
|
||||
# do not use a code that expires sooner than this (seconds)
|
||||
: "${TOTP_MIN_LEFT:=8}"
|
||||
# 0 = omit (handshake errors then show up in "dial ... error:" log lines)
|
||||
: "${HANDSHAKE_TIMEOUT:=20}"
|
||||
# nikki mixed port and its login, used by "debug"
|
||||
: "${MIXED_PORT:=$(uci_get nikki.mixin.mixed_port || echo 7890)}"
|
||||
: "${MIXED_AUTH:=$(u=$(uci_get 'nikki.@authentication[0].username') && echo "$u:$(uci_get 'nikki.@authentication[0].password')")}"
|
||||
|
||||
log() { logger -t bmstu-otp "$*" 2>/dev/null; echo "$*" >&2; }
|
||||
die() { log "error: $*"; exit 1; }
|
||||
|
||||
# --- TOTP (RFC 6238, HMAC-SHA1) --------------------------------------------
|
||||
|
||||
base32_to_hex() {
|
||||
echo "$1" | tr -d ' =-' | tr 'a-z' 'A-Z' | awk '
|
||||
BEGIN { a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567" }
|
||||
{
|
||||
bits = ""
|
||||
for (i = 1; i <= length($0); i++) {
|
||||
v = index(a, substr($0, i, 1)) - 1
|
||||
if (v < 0) { print "bad base32" > "/dev/stderr"; exit 1 }
|
||||
for (b = 16; b >= 1; b /= 2) { bits = bits (v >= b ? "1" : "0"); if (v >= b) v -= b }
|
||||
}
|
||||
out = ""
|
||||
for (i = 1; i + 7 <= length(bits); i += 8) {
|
||||
n = 0
|
||||
for (j = 0; j < 8; j++) n = n * 2 + substr(bits, i + j, 1)
|
||||
out = out sprintf("%02x", n)
|
||||
}
|
||||
print out
|
||||
}'
|
||||
}
|
||||
|
||||
totp() {
|
||||
now=$(date +%s)
|
||||
if command -v oathtool >/dev/null 2>&1; then
|
||||
oathtool --totp -b -d "$TOTP_DIGITS" -s "${TOTP_PERIOD}s" "$TOTP_SECRET"
|
||||
return
|
||||
fi
|
||||
command -v openssl >/dev/null 2>&1 || die "need oathtool or openssl (opkg install oath-toolkit | openssl-util)"
|
||||
key=$(base32_to_hex "$TOTP_SECRET") || die "TOTP_SECRET is not valid base32"
|
||||
counter=$((now / TOTP_PERIOD))
|
||||
# 8-byte big-endian counter as octal escapes (busybox printf has no \x)
|
||||
esc="" i=7
|
||||
while [ $i -ge 0 ]; do
|
||||
esc="$esc$(printf '\\%03o' $(( (counter >> (i * 8)) & 255 )))"
|
||||
i=$((i - 1))
|
||||
done
|
||||
mac=$(printf "$esc" | openssl dgst -sha1 -mac HMAC -macopt "hexkey:$key" | awk '{print $NF}')
|
||||
off=$(( 0x$(echo "$mac" | cut -c40) * 2 + 1 ))
|
||||
word=$(echo "$mac" | cut -c"$off-$((off + 7))")
|
||||
mod=1 i=0
|
||||
while [ $i -lt "$TOTP_DIGITS" ]; do mod=$((mod * 10)); i=$((i + 1)); done
|
||||
printf "%0${TOTP_DIGITS}d\n" $(( (0x$word & 0x7fffffff) % mod ))
|
||||
}
|
||||
|
||||
# wait for a fresh window if the current code is about to expire
|
||||
fresh_totp() {
|
||||
left=$((TOTP_PERIOD - $(date +%s) % TOTP_PERIOD))
|
||||
[ "$left" -lt "$TOTP_MIN_LEFT" ] && sleep "$left"
|
||||
totp
|
||||
}
|
||||
|
||||
b64() { printf '%s' "$1" | openssl base64 -A 2>/dev/null || printf '%s' "$1" | base64 | tr -d '\n'; }
|
||||
|
||||
make_password() {
|
||||
otp=$1
|
||||
case "$PASS_FORMAT" in
|
||||
scrv1) echo "SCRV1:$(b64 "$VPN_PASSWORD"):$(b64 "$otp")" ;;
|
||||
otp-first) echo "$otp$VPN_PASSWORD" ;;
|
||||
otp-last) echo "$VPN_PASSWORD$otp" ;;
|
||||
*) die "unknown PASS_FORMAT=$PASS_FORMAT" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# --- provider generation ----------------------------------------------------
|
||||
|
||||
# print inline <tag>...</tag> block from the .ovpn, YAML-indented, no comments
|
||||
ovpn_block() {
|
||||
awk -v tag="$1" '
|
||||
$0 ~ "^<" tag ">" { on = 1; next }
|
||||
$0 ~ "^</" tag ">" { on = 0; next }
|
||||
on && $0 !~ /^#/ && NF { print " " $0 }
|
||||
' "$OVPN_FILE"
|
||||
}
|
||||
|
||||
ovpn_opt() { awk -v k="$1" '$1 == k { $1 = ""; sub(/^ /, ""); print; exit }' "$OVPN_FILE"; }
|
||||
|
||||
yaml_str() { printf '"%s"' "$(printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g')"; }
|
||||
|
||||
write_provider() {
|
||||
[ -f "$OVPN_FILE" ] || die "no $OVPN_FILE"
|
||||
[ -n "${VPN_USERNAME:-}" ] || die "VPN_USERNAME is empty"
|
||||
[ -n "${VPN_PASSWORD:-}" ] || die "VPN_PASSWORD is empty"
|
||||
[ -n "${TOTP_SECRET:-}" ] || die "TOTP_SECRET is empty"
|
||||
|
||||
# first "remote host port proto" line
|
||||
set -- $(ovpn_opt remote)
|
||||
host=$1 port=${2:-1194} proto=${3:-udp}
|
||||
case "$proto" in tcp*) proto=tcp ;; *) proto=udp ;; esac
|
||||
fallback=$(ovpn_opt data-ciphers-fallback)
|
||||
|
||||
pass=$(make_password "$(fresh_totp)") || exit 1
|
||||
|
||||
mkdir -p "$(dirname "$PROVIDER_FILE")"
|
||||
tmp="$PROVIDER_FILE.tmp"
|
||||
{
|
||||
echo "# generated by bmstu-otp.sh at $(date '+%F %T') - do not edit"
|
||||
echo "proxies:"
|
||||
echo " - name: $PROXY_NAME"
|
||||
echo " type: openvpn"
|
||||
echo " server: $host"
|
||||
echo " port: $port"
|
||||
echo " proto: $proto"
|
||||
echo " udp: true"
|
||||
echo " username: $(yaml_str "$VPN_USERNAME")"
|
||||
echo " password: $(yaml_str "$pass")"
|
||||
# the server pushes AES-256-GCM
|
||||
echo " data-ciphers: [AES-256-GCM, AES-128-GCM]"
|
||||
[ -n "$fallback" ] && echo " data-ciphers-fallback: $fallback"
|
||||
echo " ping: 10"
|
||||
echo " ping-restart: 60"
|
||||
[ "$HANDSHAKE_TIMEOUT" -gt 0 ] && echo " handshake-timeout: $HANDSHAKE_TIMEOUT"
|
||||
for t in ca cert key tls-crypt tls-auth; do
|
||||
body=$(ovpn_block "$t")
|
||||
[ -n "$body" ] && printf ' %s: |\n%s\n' "$t" "$body"
|
||||
done
|
||||
kd=$(ovpn_opt key-direction)
|
||||
[ -n "$kd" ] && echo " key-direction: \"$kd\""
|
||||
true
|
||||
} > "$tmp" && chmod 600 "$tmp" && mv "$tmp" "$PROVIDER_FILE"
|
||||
}
|
||||
|
||||
# --- mihomo API -------------------------------------------------------------
|
||||
|
||||
api() {
|
||||
method=$1 path=$2
|
||||
shift 2
|
||||
if [ -n "$API_SECRET" ]; then
|
||||
curl -fsS -m 30 -X "$method" -H "Authorization: Bearer $API_SECRET" "$@" "$API$path"
|
||||
else
|
||||
curl -fsS -m 30 -X "$method" "$@" "$API$path"
|
||||
fi
|
||||
}
|
||||
|
||||
# right after "nikki restart" the API is not up yet
|
||||
wait_api() {
|
||||
i=0
|
||||
until api GET /version >/dev/null 2>&1; do
|
||||
i=$((i + 1))
|
||||
[ "$i" -ge "${API_WAIT:-30}" ] && die "mihomo API not reachable at $API (nikki running? check nikki.mixin.api_listen)"
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
alive() {
|
||||
api GET "/proxies/$GROUP_NAME/delay" -G \
|
||||
--data-urlencode "url=$CHECK_URL" --data-urlencode "timeout=$CHECK_TIMEOUT" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# provider with a single direct proxy: the old tunnel gets closed with the
|
||||
# outdated proxy, and BMSTU traffic goes without it (public resources still
|
||||
# open; on street the provider's dialer-proxy sends it through OVPN-EXIT)
|
||||
write_off_provider() {
|
||||
mkdir -p "$(dirname "$PROVIDER_FILE")"
|
||||
printf '# bmstu-otp.sh off\nproxies:\n - name: %s-off\n type: direct\n' "$PROVIDER_NAME" > "$PROVIDER_FILE"
|
||||
}
|
||||
|
||||
refresh() {
|
||||
[ -f "$OFF_FLAG" ] && die "OpenVPN is off (bmstu-otp.sh on)"
|
||||
write_provider
|
||||
wait_api
|
||||
api PUT "/providers/proxies/$PROVIDER_NAME" >/dev/null || die "provider reload failed (API $API)"
|
||||
# handshake right now, while the OTP is valid
|
||||
if alive; then
|
||||
log "tunnel is up"
|
||||
else
|
||||
log "tunnel did not come up after refresh (check nikki log)"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
case "${1:-}" in
|
||||
otp) totp ;;
|
||||
# auth-user-pass file for testing with the real openvpn client
|
||||
authfile) printf '%s\n%s\n' "$VPN_USERNAME" "$(make_password "$(fresh_totp)")" ;;
|
||||
refresh) refresh ;;
|
||||
check)
|
||||
[ -f "$OFF_FLAG" ] && exit 0
|
||||
alive || { log "tunnel is down, refreshing"; refresh; }
|
||||
;;
|
||||
off)
|
||||
touch "$OFF_FLAG"
|
||||
write_off_provider
|
||||
wait_api
|
||||
api PUT "/providers/proxies/$PROVIDER_NAME" >/dev/null || die "provider reload failed (API $API)"
|
||||
log "OpenVPN off: tunnel closed, the server frees the session within its ping-restart (~5 min)"
|
||||
;;
|
||||
on)
|
||||
rm -f "$OFF_FLAG"
|
||||
refresh
|
||||
;;
|
||||
status)
|
||||
if [ -f "$OFF_FLAG" ]; then
|
||||
echo "off"
|
||||
elif alive; then
|
||||
echo "on, tunnel is up"
|
||||
else
|
||||
echo "on, tunnel is down (cron brings it up within a minute)"
|
||||
fi
|
||||
;;
|
||||
# show the real handshake error: no handshake-timeout, debug log,
|
||||
# one request through the mixed port so the dial error gets logged
|
||||
debug)
|
||||
HANDSHAKE_TIMEOUT=0 write_provider
|
||||
api PATCH /configs -H 'Content-Type: application/json' -d '{"log-level":"debug"}' >/dev/null
|
||||
api PUT "/providers/proxies/$PROVIDER_NAME" >/dev/null || die "provider reload failed (API $API)"
|
||||
echo "password format: $PASS_FORMAT, length $(sed -n 's/^ password: "\(.*\)"$/\1/p' "$PROVIDER_FILE" | wc -c)"
|
||||
curl -skS -m 25 -o /dev/null -w "request via mihomo: http %{http_code}\n" \
|
||||
${MIXED_AUTH:+--proxy-user "$MIXED_AUTH"} \
|
||||
-x "http://127.0.0.1:$MIXED_PORT" "${DEBUG_URL:-https://195.19.34.102/}"
|
||||
# let LAN clients trigger a handshake and hit the 5s dial timeout
|
||||
sleep 20
|
||||
echo "--- log ---"
|
||||
{ cat /var/log/nikki/core.log 2>/dev/null || logread; } | grep -iE "openvpn|bmstu" | tail -n 30
|
||||
echo "--- handshake errors ---"
|
||||
{ cat /var/log/nikki/core.log 2>/dev/null || logread; } | grep -E "OpenVPN" | tail -n 5
|
||||
;;
|
||||
*) echo "usage: $0 otp|authfile|refresh|check|on|off|status|debug" >&2; exit 2 ;;
|
||||
esac
|
||||
17
router/bmstu.env.example
Normal file
17
router/bmstu.env.example
Normal file
@ -0,0 +1,17 @@
|
||||
# /etc/nikki/bmstu.env on the router, chmod 600 (mihomo-kit.sh setup writes it)
|
||||
VPN_USERNAME="username"
|
||||
VPN_PASSWORD="your-password"
|
||||
# base32 secret from the TOTP QR (otpauth://totp/...?secret=XXXX)
|
||||
TOTP_SECRET="XXXXXXXXXXXXXXXX"
|
||||
# otp-last (default: <password><otp>) | otp-first | scrv1
|
||||
#PASS_FORMAT=otp-last
|
||||
|
||||
# nikki API: read from uci (nikki.mixin.api_listen / api_secret) unless set here
|
||||
#API="http://192.168.1.1:9090"
|
||||
#API_SECRET=""
|
||||
|
||||
# something reachable only (or at least) through the VPN
|
||||
#CHECK_URL="https://www.bmstu.ru"
|
||||
|
||||
#OVPN_FILE=/etc/nikki/bmstu.ovpn
|
||||
#PROVIDER_FILE=/etc/nikki/run/providers/bmstu.yaml
|
||||
1924
router/mihomo-kit.sh
1924
router/mihomo-kit.sh
File diff suppressed because it is too large
Load Diff
@ -1,3 +0,0 @@
|
||||
untrusted comment: Nikki
|
||||
RWSrAXyIqregizvXvG9kJI/JoTkaCCPDy6CQrrVQ4IZ8Qgu+iWMql0UW
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
# /etc/nikki/openvpn.env on the router, chmod 600 (LuCI / mihomo-kit.sh setup writes it)
|
||||
VPN_USERNAME="username"
|
||||
VPN_PASSWORD="your-password"
|
||||
# only for a VPN that asks for a one-time code: the base32 secret from the TOTP QR
|
||||
# (otpauth://totp/...?secret=XXXX); without it the password goes as is
|
||||
#TOTP_SECRET="XXXXXXXXXXXXXXXX"
|
||||
# how the code goes: auto (default: scrv1 when the .ovpn has static-challenge, else
|
||||
# otp-last) | scrv1 (as OpenVPN Connect: SCRV1:b64(pass):b64(otp)) | otp-last | otp-first
|
||||
#PASS_FORMAT=auto
|
||||
# connect-mac (default: present as OpenVPN Connect 3.7.1 for macOS) | mihomo
|
||||
#OVPN_MIMIC=connect-mac
|
||||
# kit core, pauses before reconnecting (seconds): after a drop or a failed connect
|
||||
# (doubled while it keeps failing, up to 10 min), after the server ended the session
|
||||
# (a kick; doubled per kick in a row, up to 30 min), and the random spread of each
|
||||
#OVPN_RECONNECT_PAUSE=120
|
||||
#OVPN_KICK_PAUSE=120
|
||||
#OVPN_RECONNECT_JITTER=30
|
||||
|
||||
# nikki API: read from uci (nikki.mixin.api_listen / api_secret) unless set here
|
||||
#API="http://192.168.1.1:9090"
|
||||
#API_SECRET=""
|
||||
|
||||
# something reachable only (or at least) through the VPN
|
||||
#CHECK_URL="https://intranet.example.com"
|
||||
|
||||
#OVPN_FILE=/etc/nikki/openvpn.ovpn
|
||||
#PROVIDER_FILE=/etc/nikki/run/providers/openvpn.yaml
|
||||
|
||||
# Schedule: with OVPN_SCHED=1 the tunnel is up only inside these local-time (MSK)
|
||||
# hours, with up to OVPN_SCHED_JITTER minutes of deterministic per-day jitter on
|
||||
# each edge. Managed from LuCI or `ovpn.sh sched ...`; shown here for reference.
|
||||
#OVPN_SCHED=0
|
||||
#OVPN_SCHED_START=09:00
|
||||
#OVPN_SCHED_END=17:00
|
||||
#OVPN_SCHED_JITTER=10
|
||||
985
router/ovpn.sh
985
router/ovpn.sh
@ -1,985 +0,0 @@
|
||||
#!/bin/sh
|
||||
# OpenVPN (with an optional TOTP second factor) for mihomo / nikki on OpenWrt.
|
||||
#
|
||||
# mihomo has no static-challenge support: the password in the proxy config is
|
||||
# static. This script builds the file proxy-provider from the .ovpn (with a fresh
|
||||
# OTP baked into the password when TOTP_SECRET is set), reloads the provider via
|
||||
# the mihomo API and brings the tunnel up while the code is still valid. After
|
||||
# that the server's auth-token keeps rekeys alive without an OTP. With the kit core (auto-connect, as OpenVPN
|
||||
# Connect) the tunnel comes up as soon as the provider loads, reconnects by itself
|
||||
# with the auth-token, and sends the server EXIT when closed; once the token is
|
||||
# rejected it waits for a provider with a fresh OTP (cron check).
|
||||
#
|
||||
# No traffic of its own through the tunnel: OpenVPN Connect sends none, and a
|
||||
# periodic URL test shows up in the logs of the site it opens (a HEAD from a Go
|
||||
# client every minute). With the kit core the watchdog reads the tunnel state
|
||||
# from the mihomo API instead; only "probe" (by hand) opens CHECK_URL. Other
|
||||
# cores report no state: there the cron check probes, rarely and at random moments.
|
||||
#
|
||||
# Usage:
|
||||
# ovpn.sh otp print the current TOTP code
|
||||
# ovpn.sh authfile print username/password lines (openvpn auth-user-pass file)
|
||||
# ovpn.sh refresh regenerate provider with fresh OTP, reload, warm up
|
||||
# ovpn.sh up bring the tunnel up if it should be up and does not answer
|
||||
# ovpn.sh write only regenerate the provider and routes (nikki init, before mihomo starts)
|
||||
# ovpn.sh check reconcile to the desired state (timer/manual/schedule) and
|
||||
# refresh a dead tunnel (cron, once a minute; no traffic with the kit core)
|
||||
# Three modes, one at a time: on (always), off, schedule. A timer runs over any of them
|
||||
# and hands back to the mode when it ends.
|
||||
# ovpn.sh on always on: drops the manual off, the schedule and the timer
|
||||
# ovpn.sh off close the tunnel and keep it closed: drops the schedule and the
|
||||
# timer (the VPN's addresses go without it); frees the server
|
||||
# session (the kit core sends EXIT; other cores leave it until
|
||||
# ping-restart, ~5 min)
|
||||
# ovpn.sh sched on the schedule decides (drops the manual off; the timer stays)
|
||||
# ovpn.sh sched off schedule off, the tunnel off (as "off", the timer stays)
|
||||
# ovpn.sh sched HH:MM HH:MM [DAYS] | days DAYS: only store the work hours
|
||||
# (router time; DAYS 12345 | weekdays | weekend | all); "sched on" uses them
|
||||
# ovpn.sh for N up for N minutes from now over the mode, then back to it
|
||||
# ovpn.sh extend N N more minutes on the timer (starts one if none runs); a timer
|
||||
# never reaches past TIMER_MAX minutes from now
|
||||
# ovpn.sh stop end the timer now, back to the mode
|
||||
# ovpn.sh status what decides now, the next change, the tunnel state (no traffic)
|
||||
# ovpn.sh probe open CHECK_URL through the tunnel (a request the site can log)
|
||||
# ovpn.sh state the same as key=value lines (LuCI)
|
||||
# ovpn.sh want exit code: should the tunnel be up now
|
||||
# ovpn.sh debug show the real handshake error in the nikki log
|
||||
|
||||
set -u
|
||||
|
||||
# the files of kits before 2026-11 (bmstu.*), until mihomo-kit.sh moves them
|
||||
_old() { [ -f "/etc/nikki/$1" ] && [ ! -f "/etc/nikki/$2" ] && echo "/etc/nikki/$1" || echo "/etc/nikki/$2"; }
|
||||
ENV_FILE="${ENV_FILE:-$(_old bmstu.env openvpn.env)}"
|
||||
[ -f "$ENV_FILE" ] && . "$ENV_FILE"
|
||||
|
||||
: "${OVPN_FILE:=$(_old bmstu.ovpn openvpn.ovpn)}"
|
||||
: "${PROVIDER_FILE:=/etc/nikki/run/providers/openvpn.yaml}"
|
||||
: "${PROVIDER_NAME:=openvpn}"
|
||||
: "${PROXY_NAME:=openvpn}"
|
||||
: "${GROUP_NAME:=OPENVPN}"
|
||||
# API address/secret: from nikki's mixin settings unless set in the env file
|
||||
uci_get() { uci -q get "$1" 2>/dev/null; }
|
||||
# api_listen is host:port; a wildcard/empty host means loopback works
|
||||
api_from_uci() {
|
||||
l=$(uci_get nikki.mixin.api_listen)
|
||||
port=${l##*:} host=${l%:*}
|
||||
case "$port" in '' | *[!0-9]*) port=9090 ;; esac
|
||||
case "$host" in '' | 0.0.0.0 | '[::]' | '::' | '*' | "$l") host=127.0.0.1 ;; esac
|
||||
echo "http://$host:$port"
|
||||
}
|
||||
: "${API:=$(api_from_uci)}"
|
||||
: "${API_SECRET:=$(uci_get nikki.mixin.api_secret)}"
|
||||
# while this file exists the tunnel stays off (ovpn.sh off/on); it is the
|
||||
# sticky manual off and wins over the schedule
|
||||
: "${OFF_FLAG:=$(_old bmstu.off openvpn.off)}"
|
||||
# timer (ovpn.sh for N): holds an epoch; the tunnel stays up until then,
|
||||
# overriding the schedule, then this file is removed and the schedule resumes
|
||||
: "${UNTIL_FLAG:=$(_old bmstu.until openvpn.until)}"
|
||||
# the longest a timer (for / extend) reaches from now, minutes
|
||||
: "${TIMER_MAX:=720}"
|
||||
# schedule: with OVPN_SCHED=1 the tunnel is up only inside [START,END], the
|
||||
# router's local time. A deterministic per-day jitter of up to OVPN_SCHED_JITTER
|
||||
# minutes is added to each edge so the on/off moments are not identical every day.
|
||||
# OVPN_SCHED_DAYS: weekdays the window opens on, digits 1 (Mon) .. 7 (Sun); a window
|
||||
# past midnight belongs to the day it starts on.
|
||||
: "${OVPN_SCHED:=0}" "${OVPN_SCHED_START:=09:00}" "${OVPN_SCHED_END:=17:00}" "${OVPN_SCHED_JITTER:=10}"
|
||||
: "${OVPN_SCHED_DAYS:=1234567}"
|
||||
# what "probe" opens through the tunnel: OVPN_CHECK_URL of the profiles (LuCI)
|
||||
: "${CHECK_URL:=$(sed -n 's/^OVPN_CHECK_URL=//p' /etc/nikki/profiles.d/common.env 2>/dev/null | tail -n 1 | tr -d "'\"")}"
|
||||
: "${CHECK_URL:=https://www.gstatic.com/generate_204}"
|
||||
# ms, must exceed HANDSHAKE_TIMEOUT (max 32767)
|
||||
: "${CHECK_TIMEOUT:=25000}"
|
||||
# cores without the tunnel state: the cron check probes at most every PROBE_EVERY
|
||||
# seconds, after a random pause of up to PROBE_SPREAD seconds
|
||||
: "${PROBE_EVERY:=600}" "${PROBE_SPREAD:=45}"
|
||||
# kit core: a tunnel that has not come up for this long gets a fresh OTP (it
|
||||
# reconnects by itself meanwhile)
|
||||
: "${DOWN_GRACE:=300}"
|
||||
# kit core: no quick reconnects, a quick reconnect into a drop or a kick gets the
|
||||
# account blocked. After the tunnel went down, a failed connect or rejected
|
||||
# credentials the core waits OVPN_RECONNECT_PAUSE seconds, doubled while attempts
|
||||
# fail or tunnels drop within 5 min (up to 10 min); after the server ended the
|
||||
# session itself (RESTART/HALT, an admin's kick) OVPN_KICK_PAUSE, doubled for each
|
||||
# kick in a row (up to 30 min). Each pause +-OVPN_RECONNECT_JITTER seconds at random.
|
||||
# No fresh OTP during a pause either.
|
||||
: "${OVPN_RECONNECT_PAUSE:=120}" "${OVPN_RECONNECT_JITTER:=30}"
|
||||
: "${OVPN_KICK_PAUSE:=$OVPN_RECONNECT_PAUSE}"
|
||||
# with TOTP_SECRET, how the code goes with the password:
|
||||
# scrv1 - what openvpn / OpenVPN Connect send for "static-challenge ... 1":
|
||||
# SCRV1:b64(pass):b64(otp)
|
||||
# otp-last - <password><otp>
|
||||
# otp-first - <otp><password>
|
||||
# auto (default): scrv1 when the .ovpn has static-challenge, else otp-last
|
||||
: "${PASS_FORMAT:=auto}"
|
||||
# client the server sees (key-method 2 options string and peer-info):
|
||||
# connect-mac - OpenVPN Connect 3.7.1 (5558) for macOS, as its log shows them
|
||||
# mihomo - what mihomo sends itself (IV_VER=mihomo-openvpn)
|
||||
# connect-mac needs the kit core (v1.19.32-ts2+): it announces IV_PROTO=8094, and the
|
||||
# server then turns on tls-ekm, dyn-tls-crypt and aead-epoch. Other cores ignore the fields.
|
||||
: "${OVPN_MIMIC:=connect-mac}"
|
||||
: "${TOTP_DIGITS:=6}"
|
||||
: "${TOTP_PERIOD:=30}"
|
||||
# do not use a code that expires sooner than this (seconds)
|
||||
: "${TOTP_MIN_LEFT:=8}"
|
||||
# 0 = omit (handshake errors then show up in "dial ... error:" log lines)
|
||||
: "${HANDSHAKE_TIMEOUT:=20}"
|
||||
# nikki mixed port and its login, used by "debug"
|
||||
: "${MIXED_PORT:=$(uci_get nikki.mixin.mixed_port || echo 7890)}"
|
||||
: "${MIXED_AUTH:=$(u=$(uci_get 'nikki.@authentication[0].username') && echo "$u:$(uci_get 'nikki.@authentication[0].password')")}"
|
||||
|
||||
log() { logger -t openvpn "$*" 2>/dev/null; echo "$*" >&2; }
|
||||
die() { log "error: $*"; exit 1; }
|
||||
|
||||
# --- TOTP (RFC 6238, HMAC-SHA1) --------------------------------------------
|
||||
|
||||
base32_to_hex() {
|
||||
echo "$1" | tr -d ' =-' | tr 'a-z' 'A-Z' | awk '
|
||||
BEGIN { a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567" }
|
||||
{
|
||||
bits = ""
|
||||
for (i = 1; i <= length($0); i++) {
|
||||
v = index(a, substr($0, i, 1)) - 1
|
||||
if (v < 0) { print "bad base32" > "/dev/stderr"; exit 1 }
|
||||
for (b = 16; b >= 1; b /= 2) { bits = bits (v >= b ? "1" : "0"); if (v >= b) v -= b }
|
||||
}
|
||||
out = ""
|
||||
for (i = 1; i + 7 <= length(bits); i += 8) {
|
||||
n = 0
|
||||
for (j = 0; j < 8; j++) n = n * 2 + substr(bits, i + j, 1)
|
||||
out = out sprintf("%02x", n)
|
||||
}
|
||||
print out
|
||||
}'
|
||||
}
|
||||
|
||||
totp() {
|
||||
now=$(date +%s)
|
||||
if command -v oathtool >/dev/null 2>&1; then
|
||||
oathtool --totp -b -d "$TOTP_DIGITS" -s "${TOTP_PERIOD}s" "$TOTP_SECRET"
|
||||
return
|
||||
fi
|
||||
command -v openssl >/dev/null 2>&1 || die "need oathtool or openssl (opkg install oath-toolkit | openssl-util)"
|
||||
key=$(base32_to_hex "$TOTP_SECRET") || die "TOTP_SECRET is not valid base32"
|
||||
counter=$((now / TOTP_PERIOD))
|
||||
# 8-byte big-endian counter as octal escapes (busybox printf has no \x)
|
||||
esc="" i=7
|
||||
while [ $i -ge 0 ]; do
|
||||
esc="$esc$(printf '\\%03o' $(( (counter >> (i * 8)) & 255 )))"
|
||||
i=$((i - 1))
|
||||
done
|
||||
mac=$(printf "$esc" | openssl dgst -sha1 -mac HMAC -macopt "hexkey:$key" | awk '{print $NF}')
|
||||
off=$(( 0x$(echo "$mac" | cut -c40) * 2 + 1 ))
|
||||
word=$(echo "$mac" | cut -c"$off-$((off + 7))")
|
||||
mod=1 i=0
|
||||
while [ $i -lt "$TOTP_DIGITS" ]; do mod=$((mod * 10)); i=$((i + 1)); done
|
||||
printf "%0${TOTP_DIGITS}d\n" $(( (0x$word & 0x7fffffff) % mod ))
|
||||
}
|
||||
|
||||
# wait for a fresh window if the current code is about to expire
|
||||
fresh_totp() {
|
||||
left=$((TOTP_PERIOD - $(date +%s) % TOTP_PERIOD))
|
||||
[ "$left" -lt "$TOTP_MIN_LEFT" ] && sleep "$left"
|
||||
totp
|
||||
}
|
||||
|
||||
b64() { printf '%s' "$1" | openssl base64 -A 2>/dev/null || printf '%s' "$1" | base64 | tr -d '\n'; }
|
||||
|
||||
# the password the provider carries: as is without TOTP_SECRET
|
||||
make_password() {
|
||||
[ -n "${TOTP_SECRET:-}" ] || { echo "$VPN_PASSWORD"; return; }
|
||||
otp=$(fresh_totp) || return 1
|
||||
_pf=$PASS_FORMAT
|
||||
if [ "$_pf" = auto ]; then
|
||||
_pf=otp-last
|
||||
grep -q '^[[:space:]]*static-challenge' "$OVPN_FILE" 2>/dev/null && _pf=scrv1
|
||||
fi
|
||||
case "$_pf" in
|
||||
scrv1) echo "SCRV1:$(b64 "$VPN_PASSWORD"):$(b64 "$otp")" ;;
|
||||
otp-first) echo "$otp$VPN_PASSWORD" ;;
|
||||
otp-last) echo "$VPN_PASSWORD$otp" ;;
|
||||
*) die "unknown PASS_FORMAT=$PASS_FORMAT" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# --- provider generation ----------------------------------------------------
|
||||
|
||||
# print inline <tag>...</tag> block from the .ovpn, YAML-indented, no comments
|
||||
ovpn_block() {
|
||||
awk -v tag="$1" '
|
||||
$0 ~ "^<" tag ">" { on = 1; next }
|
||||
$0 ~ "^</" tag ">" { on = 0; next }
|
||||
on && $0 !~ /^#/ && NF { print " " $0 }
|
||||
' "$OVPN_FILE"
|
||||
}
|
||||
|
||||
ovpn_opt() { awk -v k="$1" '$1 == k { $1 = ""; sub(/^ /, ""); print; exit }' "$OVPN_FILE"; }
|
||||
|
||||
# OpenVPN Connect 3.7.1 (5558) for macOS: "Tunnel Options" and "Sending Peer Info" from
|
||||
# its log. link-mtu is openvpn3's tun-mtu + overhead of its default BF-CBC/SHA1 (+2 on TCP).
|
||||
mimic_connect_mac() {
|
||||
case "$1" in
|
||||
tcp) p=TCPv4_CLIENT mtu=1543 ;;
|
||||
*) p=UDPv4 mtu=1541 ;;
|
||||
esac
|
||||
echo " options-string: \"V4,dev-type tun,link-mtu $mtu,tun-mtu 1500,proto $p,cipher BF-CBC,auth SHA1,keysize 128,key-method 2,tls-client\""
|
||||
# up right away, reconnect with the auth-token, EXIT on close (kit core)
|
||||
echo " auto-connect: true"
|
||||
echo " reconnect-pause: $OVPN_RECONNECT_PAUSE"
|
||||
echo " reconnect-jitter: $OVPN_RECONNECT_JITTER"
|
||||
echo " kick-pause: $OVPN_KICK_PAUSE"
|
||||
echo " peer-info-raw: |"
|
||||
for l in IV_VER=3.11.1 IV_PLAT=mac IV_NCP=2 IV_TCPNL=1 IV_PROTO=8094 IV_MTU=1600 \
|
||||
IV_CIPHERS=AES-128-CBC:AES-192-CBC:AES-256-CBC:AES-128-GCM:AES-192-GCM:AES-256-GCM:CHACHA20-POLY1305 \
|
||||
IV_GUI_VER=OCmacOS_3.7.1-5558 IV_SSO=webauth,crtext IV_BS64DL=1; do
|
||||
echo " $l"
|
||||
done
|
||||
}
|
||||
|
||||
yaml_str() { printf '"%s"' "$(printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g')"; }
|
||||
|
||||
write_provider() {
|
||||
[ -f "$OVPN_FILE" ] || die "no $OVPN_FILE"
|
||||
[ -n "${VPN_USERNAME:-}" ] || die "VPN_USERNAME is empty"
|
||||
[ -n "${VPN_PASSWORD:-}" ] || die "VPN_PASSWORD is empty"
|
||||
|
||||
# first "remote host port proto" line
|
||||
set -- $(ovpn_opt remote)
|
||||
host=$1 port=${2:-1194} proto=${3:-udp}
|
||||
case "$proto" in tcp*) proto=tcp ;; *) proto=udp ;; esac
|
||||
fallback=$(ovpn_opt data-ciphers-fallback)
|
||||
# the .ovpn's list (data-ciphers, or the older ncp-ciphers), else the usual AEAD ones
|
||||
ciphers=$(ovpn_opt data-ciphers)
|
||||
[ -n "$ciphers" ] || ciphers=$(ovpn_opt ncp-ciphers)
|
||||
ciphers=$(printf '%s' "${ciphers:-AES-256-GCM:AES-128-GCM}" | sed 's/:/, /g')
|
||||
|
||||
pass=$(make_password) || exit 1
|
||||
|
||||
mkdir -p "$(dirname "$PROVIDER_FILE")"
|
||||
# per process: the init hook can write while a cron refresh does
|
||||
tmp="$PROVIDER_FILE.tmp.$$"
|
||||
{
|
||||
echo "# generated by ovpn.sh at $(date '+%F %T') - do not edit"
|
||||
echo "proxies:"
|
||||
echo " - name: $PROXY_NAME"
|
||||
echo " type: openvpn"
|
||||
echo " server: $host"
|
||||
echo " port: $port"
|
||||
echo " proto: $proto"
|
||||
echo " udp: true"
|
||||
echo " username: $(yaml_str "$VPN_USERNAME")"
|
||||
echo " password: $(yaml_str "$pass")"
|
||||
echo " data-ciphers: [$ciphers]"
|
||||
[ -n "$fallback" ] && echo " data-ciphers-fallback: $fallback"
|
||||
# what servers usually push (and OpenVPN Connect uses); mihomo ignores pushed ping.
|
||||
# A dead tunnel is noticed by the cron check sooner than by ping-restart.
|
||||
echo " ping: 60"
|
||||
echo " ping-restart: 300"
|
||||
[ "$HANDSHAKE_TIMEOUT" -gt 0 ] && echo " handshake-timeout: $HANDSHAKE_TIMEOUT"
|
||||
case "$OVPN_MIMIC" in
|
||||
connect-mac) mimic_connect_mac "$proto" ;;
|
||||
mihomo) ;;
|
||||
*) die "unknown OVPN_MIMIC=$OVPN_MIMIC" ;;
|
||||
esac
|
||||
for t in ca cert key tls-crypt tls-auth; do
|
||||
body=$(ovpn_block "$t")
|
||||
[ -n "$body" ] && printf ' %s: |\n%s\n' "$t" "$body"
|
||||
done
|
||||
kd=$(ovpn_opt key-direction)
|
||||
[ -n "$kd" ] && echo " key-direction: \"$kd\""
|
||||
true
|
||||
} > "$tmp" && chmod 600 "$tmp" && mv "$tmp" "$PROVIDER_FILE"
|
||||
}
|
||||
|
||||
# --- mihomo API -------------------------------------------------------------
|
||||
|
||||
api() {
|
||||
method=$1 path=$2
|
||||
shift 2
|
||||
if [ -n "$API_SECRET" ]; then
|
||||
curl -fsS -m 30 -X "$method" -H "Authorization: Bearer $API_SECRET" "$@" "$API$path"
|
||||
else
|
||||
curl -fsS -m 30 -X "$method" "$@" "$API$path"
|
||||
fi
|
||||
}
|
||||
|
||||
# right after "nikki restart" the API is not up yet
|
||||
wait_api() {
|
||||
i=0
|
||||
until api GET /version >/dev/null 2>&1; do
|
||||
i=$((i + 1))
|
||||
[ "$i" -ge "${API_WAIT:-30}" ] && die "mihomo API not reachable at $API (nikki running? check nikki.mixin.api_listen)"
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
# HTTP check through the tunnel. The site sees it (HEAD from a Go client), so it
|
||||
# runs only by hand and for cores that report no tunnel state.
|
||||
probe() {
|
||||
api GET "/proxies/$GROUP_NAME/delay" -G \
|
||||
--data-urlencode "url=$CHECK_URL" --data-urlencode "timeout=$CHECK_TIMEOUT" 2>/dev/null
|
||||
}
|
||||
|
||||
# tunnel state from the kit core, no traffic: _cs_since (unix, 0 = down),
|
||||
# _cs_failed (true once the server rejected the credentials), _cs_err (last
|
||||
# connect error), _cs_retry (unix: reconnect pause, no attempt before then;
|
||||
# 0 = none) and _cs_why (why the pause: drop | kick | failed | rejected). Non-zero when the core reports none (stock / official core,
|
||||
# OVPN_MIMIC=mihomo without auto-connect, no such proxy, API down).
|
||||
core_state() {
|
||||
_j=$(api GET "/providers/proxies/$PROVIDER_NAME/$PROXY_NAME" 2>/dev/null) || return 1
|
||||
[ "$(jsonfilter -s "$_j" -e '@.openvpn.auto_connect' 2>/dev/null)" = true ] || return 1
|
||||
_cs_since=$(jsonfilter -s "$_j" -e '@.openvpn.connected_since' 2>/dev/null)
|
||||
_cs_failed=$(jsonfilter -s "$_j" -e '@.openvpn.auth_failed' 2>/dev/null)
|
||||
_cs_err=$(jsonfilter -s "$_j" -e '@.openvpn.last_error' 2>/dev/null)
|
||||
_cs_retry=$(jsonfilter -s "$_j" -e '@.openvpn.retry_at' 2>/dev/null)
|
||||
_cs_why=$(jsonfilter -s "$_j" -e '@.openvpn.retry_why' 2>/dev/null)
|
||||
case "$_cs_since" in '' | *[!0-9]*) _cs_since=0 ;; esac
|
||||
case "$_cs_retry" in '' | *[!0-9]*) _cs_retry=0 ;; esac
|
||||
return 0
|
||||
}
|
||||
|
||||
# wait_up <s>: 0 once the kit core reports the tunnel up, 1 when it is still down
|
||||
# after <s> seconds or the credentials were rejected, 2 when the core reports no state
|
||||
wait_up() {
|
||||
_i=0
|
||||
while :; do
|
||||
core_state || return 2
|
||||
[ "$_cs_since" -gt 0 ] && return 0
|
||||
[ "$_cs_failed" = true ] && return 1
|
||||
[ "$_cs_retry" -gt "$(date +%s)" ] && return 1
|
||||
[ "$_i" -ge "$1" ] && return 1
|
||||
sleep 1
|
||||
_i=$((_i + 1))
|
||||
done
|
||||
}
|
||||
|
||||
# is the tunnel up: the core's state (allowing a handshake in progress to
|
||||
# finish), or a probe for cores without it
|
||||
tunnel_ok() {
|
||||
wait_up "$((HANDSHAKE_TIMEOUT + 5))"
|
||||
case $? in
|
||||
0) return 0 ;;
|
||||
1) return 1 ;;
|
||||
esac
|
||||
probe >/dev/null
|
||||
}
|
||||
|
||||
# provider with a single direct proxy: the old tunnel gets closed with the
|
||||
# outdated proxy, and the VPN's addresses go without it (on whitelist / foreign
|
||||
# the provider's dialer-proxy sends them through OVPN-EXIT)
|
||||
write_off_provider() {
|
||||
mkdir -p "$(dirname "$PROVIDER_FILE")"
|
||||
printf '# ovpn.sh off\nproxies:\n - name: %s-off\n type: direct\n' "$PROVIDER_NAME" > "$PROVIDER_FILE"
|
||||
}
|
||||
|
||||
# rule-provider <PROVIDER_NAME>-routes (written by mihomo-kit.sh build): with the
|
||||
# tunnel off it is emptied, so the VPN's addresses follow the normal rules
|
||||
ROUTES=${ROUTES:-$(dirname "$PROVIDER_FILE")/$PROVIDER_NAME-routes}
|
||||
routes_body() {
|
||||
if [ "$1" = off ] || { [ -f "$ROUTES.all" ] && ! grep -q . "$ROUTES.all"; }; then
|
||||
echo 'payload: []'
|
||||
elif [ -f "$ROUTES.all" ]; then
|
||||
echo 'payload:'
|
||||
while read -r r; do [ -n "$r" ] && echo " - '$r'"; done < "$ROUTES.all"
|
||||
fi
|
||||
}
|
||||
# routes_set on|off [file]: write the routes for that state and reload them in
|
||||
# mihomo if they changed ("file": only write, mihomo is not running yet)
|
||||
routes_set() {
|
||||
_body=$(routes_body "$1")
|
||||
[ -n "$_body" ] || return 0
|
||||
[ "$(cat "$ROUTES.yaml" 2>/dev/null)" = "$_body" ] && return 0
|
||||
printf '%s\n' "$_body" > "$ROUTES.yaml"
|
||||
[ "${2:-}" = file ] && return 0
|
||||
api PUT "/providers/rules/$PROVIDER_NAME-routes" >/dev/null ||
|
||||
log "warning: routes reload failed (API $API), applies on the next nikki restart"
|
||||
}
|
||||
|
||||
# reconnect pause: no new provider (its OTP would be stale by the end of the
|
||||
# pause, and a new proxy waits for it all the same)
|
||||
pause_held() {
|
||||
core_state && [ "$_cs_retry" -gt "$(date +%s)" ]
|
||||
}
|
||||
|
||||
refresh() {
|
||||
if pause_held; then
|
||||
log "reconnect pause ($_cs_why${_cs_err:+: $_cs_err}), no attempt before $(date -d "@$_cs_retry" '+%H:%M:%S')"
|
||||
return 1
|
||||
fi
|
||||
write_provider
|
||||
wait_api
|
||||
api PUT "/providers/proxies/$PROVIDER_NAME" >/dev/null || die "provider reload failed (API $API)"
|
||||
rm -f "$DOWN_SINCE"
|
||||
# the handshake has to happen now, while the OTP is valid: the kit core
|
||||
# starts it by itself, other cores dial on the first request (the probe)
|
||||
_cs_err=
|
||||
if tunnel_ok; then
|
||||
log "tunnel is up"
|
||||
else
|
||||
log "tunnel did not come up after refresh (${_cs_err:-check nikki log})"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# kit core, steady state (cron): it reconnects by itself with the session
|
||||
# token. A fresh OTP is needed once the server rejected the token, or when the
|
||||
# tunnel has stayed down for DOWN_GRACE seconds.
|
||||
DOWN_SINCE=${DOWN_SINCE:-/tmp/openvpn.down}
|
||||
watch_core() {
|
||||
if [ "$_cs_since" -gt 0 ]; then
|
||||
rm -f "$DOWN_SINCE"
|
||||
return 0
|
||||
fi
|
||||
# reconnect pause: the core waits it out by itself (a rejected session gets
|
||||
# its new OTP after it), and the down grace counts from its end
|
||||
if [ "$_cs_retry" -gt "$(date +%s)" ]; then
|
||||
echo "$_cs_retry" > "$DOWN_SINCE"
|
||||
return 0
|
||||
fi
|
||||
if [ "$_cs_failed" = true ]; then
|
||||
log "the server rejected the session (${_cs_err:-AUTH_FAILED}), new OTP"
|
||||
refresh
|
||||
return
|
||||
fi
|
||||
_now=$(date +%s)
|
||||
_d=$(cat "$DOWN_SINCE" 2>/dev/null)
|
||||
case "$_d" in '' | *[!0-9]*) _d=$_now && echo "$_d" > "$DOWN_SINCE" ;; esac
|
||||
[ $((_now - _d)) -ge "$DOWN_GRACE" ] || return 0
|
||||
log "tunnel down for $((_now - _d)) s (${_cs_err:-no error}), new OTP"
|
||||
refresh
|
||||
}
|
||||
|
||||
# other cores (no tunnel state): probe CHECK_URL, but only every PROBE_EVERY
|
||||
# seconds and not on the minute mark, so it does not look like a clock
|
||||
PROBE_LAST=${PROBE_LAST:-/tmp/openvpn.probe}
|
||||
watch_probe() {
|
||||
_now=$(date +%s)
|
||||
_last=$(cat "$PROBE_LAST" 2>/dev/null)
|
||||
case "$_last" in '' | *[!0-9]*) _last=0 ;; esac
|
||||
[ $((_now - _last)) -ge "$PROBE_EVERY" ] || return 0
|
||||
echo "$_now" > "$PROBE_LAST"
|
||||
sleep $(($(od -An -N2 -tu2 /dev/urandom | tr -d ' ') % (PROBE_SPREAD + 1)))
|
||||
probe >/dev/null && return 0
|
||||
# a single lost probe on a long chain (whitelist: RU node + tunnel) is not a
|
||||
# dead tunnel; refreshing then would break a working one
|
||||
log "probe failed, checking again"
|
||||
sleep 10
|
||||
probe >/dev/null && return 0
|
||||
log "tunnel is down (2 failed probes), refreshing"
|
||||
refresh
|
||||
}
|
||||
|
||||
# --- schedule / timer -------------------------------------------------------
|
||||
|
||||
# "HH:MM" -> minutes since midnight on stdout; non-zero on a malformed value
|
||||
hhmm_to_min() {
|
||||
case "$1" in
|
||||
[0-9][0-9]:[0-9][0-9]) : ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
_h=${1%:*} _m=${1#*:}
|
||||
# strip one leading zero so 08/09 are not read as octal, without the
|
||||
# bash-only 10# radix (busybox ash lacks it)
|
||||
_h=${_h#0} _m=${_m#0}
|
||||
_h=${_h:-0} _m=${_m:-0}
|
||||
[ "$_h" -le 23 ] && [ "$_m" -le 59 ] || return 1
|
||||
echo $((_h * 60 + _m))
|
||||
}
|
||||
|
||||
# minutes since midnight (may be out of 0..1439 by the jitter) -> HH:MM
|
||||
min_to_hhmm() {
|
||||
_x=$((($1 % 1440 + 1440) % 1440))
|
||||
printf '%02d:%02d\n' $((_x / 60)) $((_x % 60))
|
||||
}
|
||||
|
||||
# deterministic offset in [-JITTER, +JITTER] minutes for a seed (date + edge),
|
||||
# so each edge shifts by a fixed amount for the whole day and differs day to day
|
||||
jitter_min() {
|
||||
[ "${OVPN_SCHED_JITTER:-0}" -gt 0 ] 2>/dev/null || { echo 0; return; }
|
||||
_span=$((OVPN_SCHED_JITTER * 2 + 1))
|
||||
_hex=$(printf '%s' "$1" | md5sum 2>/dev/null | cut -c1-6)
|
||||
[ -n "$_hex" ] || { echo 0; return; }
|
||||
echo $((0x$_hex % _span - OVPN_SCHED_JITTER))
|
||||
}
|
||||
|
||||
# jittered window edges of a day (YYYY-MM-DD) in minutes since its midnight ->
|
||||
# _s _e; non-zero on a malformed setting
|
||||
sched_edges() {
|
||||
_s=$(hhmm_to_min "$OVPN_SCHED_START") || { log "bad OVPN_SCHED_START=$OVPN_SCHED_START"; return 1; }
|
||||
_e=$(hhmm_to_min "$OVPN_SCHED_END") || { log "bad OVPN_SCHED_END=$OVPN_SCHED_END"; return 1; }
|
||||
_s=$((_s + $(jitter_min "$1 start")))
|
||||
_e=$((_e + $(jitter_min "$1 end")))
|
||||
}
|
||||
|
||||
# weekday of YYYY-MM-DD, 1 (Mon) .. 7 (Sun), plain arithmetic (Sakamoto)
|
||||
dow_of() {
|
||||
_y=${1%%-*} _mo=${1#*-} _dd=${1##*-}
|
||||
_mo=${_mo%-*} _mo=${_mo#0} _dd=${_dd#0}
|
||||
[ "$_mo" -lt 3 ] && _y=$((_y - 1))
|
||||
set -- 0 3 2 5 0 3 5 1 4 6 2 4
|
||||
shift $((_mo - 1))
|
||||
_w=$(((_y + _y / 4 - _y / 100 + _y / 400 + $1 + _dd) % 7))
|
||||
echo $((_w == 0 ? 7 : _w))
|
||||
}
|
||||
|
||||
# day_on <1..7>: the window opens on that weekday (OVPN_SCHED_DAYS)
|
||||
day_on() { case "$OVPN_SCHED_DAYS" in *"$1"*) return 0 ;; esac; return 1; }
|
||||
|
||||
# days_norm <1234567 | weekdays | weekend | all | digits>: sorted digits 1..7, or nothing
|
||||
days_norm() {
|
||||
case "$1" in
|
||||
all | '') set -- 1234567 ;;
|
||||
weekdays) set -- 12345 ;;
|
||||
weekend) set -- 67 ;;
|
||||
*[!1-7]*) return 1 ;;
|
||||
esac
|
||||
_o=""
|
||||
for _x in 1 2 3 4 5 6 7; do
|
||||
case "$1" in *"$_x"*) _o=$_o$_x ;; esac
|
||||
done
|
||||
echo "$_o"
|
||||
}
|
||||
|
||||
# in_window [day minute]: true when that moment (default: now) is inside the
|
||||
# jittered window of the day; a window with END < START wraps past midnight, its
|
||||
# part after midnight belongs to the previous day (OVPN_SCHED_DAYS).
|
||||
# A malformed setting counts as inside. NOW_MIN/SCHED_DAY override the clock in tests.
|
||||
in_window() {
|
||||
_day=${1:-${SCHED_DAY:-$(date +%F)}}
|
||||
_now=${2:-${NOW_MIN:-$(hhmm_to_min "$(date +%H:%M)")}}
|
||||
sched_edges "$_day" || return 0
|
||||
_dw=$(dow_of "$_day")
|
||||
if [ "$_s" -le "$_e" ]; then
|
||||
day_on "$_dw" && [ "$_now" -ge "$_s" ] && [ "$_now" -lt "$_e" ]
|
||||
elif [ "$_now" -ge "$_s" ]; then
|
||||
day_on "$_dw"
|
||||
elif [ "$_now" -lt "$_e" ]; then
|
||||
day_on $((_dw == 1 ? 7 : _dw - 1))
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# end of the running timer (epoch) on stdout; an expired or broken one is removed
|
||||
timer_until() {
|
||||
[ -f "$UNTIL_FLAG" ] || return 1
|
||||
_u=$(cat "$UNTIL_FLAG" 2>/dev/null)
|
||||
case "$_u" in
|
||||
'' | *[!0-9]*) ;;
|
||||
*) [ "$(date +%s)" -lt "$_u" ] && { echo "$_u"; return 0; } ;;
|
||||
esac
|
||||
rm -f "$UNTIL_FLAG"
|
||||
return 1
|
||||
}
|
||||
|
||||
# the state without a timer, at [day minute] (default: now):
|
||||
# "off manual" | "on always" | "on schedule" | "off schedule"
|
||||
base_state() {
|
||||
if [ -f "$OFF_FLAG" ]; then
|
||||
echo "off manual"
|
||||
elif [ "${OVPN_SCHED:-0}" != 1 ]; then
|
||||
echo "on always"
|
||||
elif in_window "$@"; then
|
||||
echo "on schedule"
|
||||
else
|
||||
echo "off schedule"
|
||||
fi
|
||||
}
|
||||
|
||||
# desired state: should the tunnel be up now? Priority: the timer (for N), then
|
||||
# the manual off, then the schedule. The timer lifts a manual off only while it
|
||||
# runs: when it ends, the off holds again.
|
||||
want_up() {
|
||||
timer_until >/dev/null && return 0
|
||||
case "$(base_state)" in on*) return 0 ;; esac
|
||||
return 1
|
||||
}
|
||||
|
||||
# next schedule change after now -> _next (epoch) _next_to (on|off). Walks the
|
||||
# candidate moments (midnight and the jittered edges of each day, up to 8 days
|
||||
# ahead: weekdays may be skipped) and asks in_window, so both always agree.
|
||||
sched_next() {
|
||||
_t=$(date +%s)
|
||||
set -- $(date -d "@$_t" '+%F %H:%M %S')
|
||||
_m=$(hhmm_to_min "$2") || return 1
|
||||
_mid=$((_t - _m * 60 - ${3#0}))
|
||||
sched_edges "$1" || return 1
|
||||
_cur=0
|
||||
in_window "$1" "$_m" && _cur=1
|
||||
_k=0
|
||||
while [ "$_k" -le 8 ]; do
|
||||
_d=$1
|
||||
[ "$_k" -gt 0 ] && _d=$(date -d "@$((_mid + _k * 86400 + 3600))" +%F)
|
||||
sched_edges "$_d"
|
||||
if [ "$_s" -le "$_e" ]; then _cs="0 $_s $_e"; else _cs="0 $_e $_s"; fi
|
||||
for _c in $_cs; do
|
||||
[ "$_c" -ge 0 ] && [ "$_c" -le 1439 ] || continue
|
||||
[ "$_k" -eq 0 ] && [ "$_c" -le "$_m" ] && continue
|
||||
_on=0
|
||||
in_window "$_d" "$_c" && _on=1
|
||||
if [ "$_on" != "$_cur" ]; then
|
||||
_next=$((_mid + _k * 86400 + _c * 60)) _next_to=off
|
||||
[ "$_on" = 1 ] && _next_to=on
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
_k=$((_k + 1))
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# epoch -> "HH:MM today|tomorrow|YYYY-MM-DD" in router-local time
|
||||
when() {
|
||||
_d=$(date -d "@$1" +%F)
|
||||
if [ "$_d" = "$(date +%F)" ]; then
|
||||
_d=today
|
||||
elif [ "$_d" = "$(date -d "@$(($(date +%s) + 86400))" +%F)" ]; then
|
||||
_d=tomorrow
|
||||
fi
|
||||
echo "$(date -d "@$1" +%H:%M) $_d"
|
||||
}
|
||||
|
||||
# the whole picture as key=value lines (for status and LuCI):
|
||||
# mode timer | manual | schedule | always: what decides now
|
||||
# want 1 when the tunnel should be up now
|
||||
# tunnel up | down: whether the provider holds the tunnel (not a probe)
|
||||
# link closed | up | connecting | rejected | held | unknown: the kit core's tunnel
|
||||
# state, no traffic (held: reconnect pause; unknown: the core reports none)
|
||||
# retry_hm end of the reconnect pause, retry_why drop | kick | failed | rejected
|
||||
# up_since when the tunnel came up (epoch, 0 = not up), up_hm, up_day
|
||||
# err the core's last connect error, single-quoted
|
||||
# until timer end (epoch, 0 = none), until_hm, until_day (today|tomorrow|date)
|
||||
# after on | off once the timer ends, why: manual | schedule | always
|
||||
# next next schedule change (epoch, 0 = none), next_to on | off, next_hm, next_day
|
||||
# win today's window with the jitter, HH:MM-HH:MM
|
||||
# sched sched_start sched_end sched_days jitter: the settings
|
||||
state() {
|
||||
_until=$(timer_until) || _until=0
|
||||
set -- $(base_state)
|
||||
if [ "$_until" -gt 0 ]; then
|
||||
_mode=timer _want=1
|
||||
set -- $(date -d "@$_until" '+%F %H:%M')
|
||||
set -- $(base_state "$1" "$(hhmm_to_min "$2")")
|
||||
_after=$1 _why=$2
|
||||
set -- $(when "$_until")
|
||||
echo "until=$_until"
|
||||
echo "until_hm=$1"
|
||||
echo "until_day=$2"
|
||||
echo "after=$_after"
|
||||
echo "why=$_why"
|
||||
else
|
||||
_mode=$2 _want=0
|
||||
[ "$1" = on ] && _want=1
|
||||
echo "until=0"
|
||||
fi
|
||||
echo "mode=$_mode"
|
||||
echo "want=$_want"
|
||||
_link=unknown _cs_since=0 _cs_retry=0
|
||||
if tunnel_is_down; then
|
||||
echo "tunnel=down"
|
||||
_link=closed
|
||||
else
|
||||
echo "tunnel=up"
|
||||
if core_state; then
|
||||
if [ "$_cs_since" -gt 0 ]; then
|
||||
_link=up
|
||||
elif [ "$_cs_failed" = true ]; then
|
||||
_link=rejected
|
||||
elif [ "$_cs_retry" -gt "$(date +%s)" ]; then
|
||||
_link=held
|
||||
else
|
||||
_link=connecting
|
||||
fi
|
||||
if [ "$_cs_since" -eq 0 ] && [ "$_cs_retry" -gt "$(date +%s)" ]; then
|
||||
set -- $(when "$_cs_retry")
|
||||
echo "retry_hm=$1"
|
||||
echo "retry_why=$_cs_why"
|
||||
fi
|
||||
# quotes and shell specials dropped: the line is eval'ed
|
||||
[ -n "$_cs_err" ] && echo "err='$(printf '%s' "$_cs_err" | tr -d "'\"\`\\\\\$\n" | cut -c1-200)'"
|
||||
fi
|
||||
fi
|
||||
echo "link=$_link"
|
||||
echo "up_since=$_cs_since"
|
||||
if [ "$_cs_since" -gt 0 ]; then
|
||||
set -- $(when "$_cs_since")
|
||||
echo "up_hm=$1"
|
||||
echo "up_day=$2"
|
||||
fi
|
||||
if [ "${OVPN_SCHED:-0}" = 1 ] && sched_next; then
|
||||
set -- $(when "$_next")
|
||||
echo "next=$_next"
|
||||
echo "next_to=$_next_to"
|
||||
echo "next_hm=$1"
|
||||
echo "next_day=$2"
|
||||
else
|
||||
echo "next=0"
|
||||
fi
|
||||
if sched_edges "$(date +%F)"; then
|
||||
echo "win=$(min_to_hhmm "$_s")-$(min_to_hhmm "$_e")"
|
||||
fi
|
||||
echo "sched=${OVPN_SCHED:-0}"
|
||||
# the schedule decides (the mode is "schedule": not under a manual off)
|
||||
_sa=0
|
||||
[ "${OVPN_SCHED:-0}" = 1 ] && [ ! -f "$OFF_FLAG" ] && _sa=1
|
||||
echo "sched_active=$_sa"
|
||||
echo "timer_max=$TIMER_MAX"
|
||||
echo "sched_start=$OVPN_SCHED_START"
|
||||
echo "sched_end=$OVPN_SCHED_END"
|
||||
echo "sched_days=$OVPN_SCHED_DAYS"
|
||||
echo "jitter=$OVPN_SCHED_JITTER"
|
||||
}
|
||||
|
||||
# persist KEY=value in the env file (openvpn.env) and apply it to this process,
|
||||
# so the cron and the init hook that source the file pick the change up
|
||||
sched_set() {
|
||||
eval "$1=\$2"
|
||||
[ -f "$ENV_FILE" ] || { umask 077; : > "$ENV_FILE"; }
|
||||
_tmp=$(mktemp "$ENV_FILE.XXXXXX") || die "mktemp failed"
|
||||
grep -v "^$1=" "$ENV_FILE" > "$_tmp" 2>/dev/null
|
||||
# values here are simple (0/1 or HH:MM); single-quote so the file stays sourceable
|
||||
echo "$1='$2'" >> "$_tmp"
|
||||
chmod 600 "$_tmp" && mv "$_tmp" "$ENV_FILE"
|
||||
}
|
||||
|
||||
# the provider currently holds the direct "off" proxy (tunnel torn down)
|
||||
tunnel_is_down() { grep -q "name: $PROVIDER_NAME-off" "$PROVIDER_FILE" 2>/dev/null; }
|
||||
|
||||
# tear the tunnel down without touching OFF_FLAG (used by off and by the
|
||||
# schedule): the kit core sends the server EXIT when the provider is replaced
|
||||
tunnel_down() {
|
||||
write_off_provider
|
||||
wait_api
|
||||
api PUT "/providers/proxies/$PROVIDER_NAME" >/dev/null || die "provider reload failed (API $API)"
|
||||
routes_set off
|
||||
}
|
||||
|
||||
# bring the desired state about, routes included. "repair" uses the two-probe
|
||||
# test before a refresh of an already-up tunnel (steady-state cron); otherwise
|
||||
# act at once.
|
||||
reconcile() {
|
||||
if want_up; then
|
||||
routes_set on
|
||||
if tunnel_is_down; then
|
||||
log "bringing the tunnel up"
|
||||
refresh
|
||||
elif [ "${1:-}" = repair ]; then
|
||||
if core_state; then
|
||||
watch_core
|
||||
else
|
||||
watch_probe
|
||||
fi
|
||||
elif tunnel_ok; then
|
||||
log "tunnel is up"
|
||||
else
|
||||
refresh
|
||||
fi
|
||||
elif tunnel_is_down; then
|
||||
routes_set off
|
||||
else
|
||||
log "OpenVPN should be off now ($(base_state | cut -d' ' -f2)), taking the tunnel down"
|
||||
tunnel_down
|
||||
fi
|
||||
}
|
||||
|
||||
# one state change at a time (cron check, LuCI buttons, use): lock_take <wait s>
|
||||
LOCK=${LOCK:-/tmp/openvpn.lock}
|
||||
lock_take() {
|
||||
_w=0
|
||||
until mkdir "$LOCK" 2>/dev/null; do
|
||||
_p=$(cat "$LOCK/pid" 2>/dev/null)
|
||||
# a holder that died; an empty pid is one that has not written it yet
|
||||
if [ -n "$_p" ] && ! kill -0 "$_p" 2>/dev/null; then
|
||||
rm -rf "$LOCK"
|
||||
continue
|
||||
fi
|
||||
[ "$_w" -ge "$1" ] && return 1
|
||||
sleep 1
|
||||
_w=$((_w + 1))
|
||||
done
|
||||
echo $$ > "$LOCK/pid"
|
||||
trap 'rm -rf "$LOCK"' EXIT
|
||||
}
|
||||
# a check with two probes and a refresh takes up to ~2 min
|
||||
lock_wait() { lock_take 150 || die "busy: another ovpn.sh run holds $LOCK"; }
|
||||
|
||||
case "${1:-}" in
|
||||
otp)
|
||||
[ -n "${TOTP_SECRET:-}" ] || die "no TOTP_SECRET: the password goes without a code"
|
||||
totp
|
||||
;;
|
||||
# auth-user-pass file for testing with the real openvpn client
|
||||
authfile) printf '%s\n%s\n' "$VPN_USERNAME" "$(make_password)" ;;
|
||||
refresh)
|
||||
lock_wait
|
||||
want_up || die "OpenVPN is off now ($(base_state | cut -d' ' -f2)): ovpn.sh on, or for <min>"
|
||||
routes_set on
|
||||
refresh
|
||||
;;
|
||||
up)
|
||||
lock_wait
|
||||
want_up || { log "OpenVPN is off now ($(base_state | cut -d' ' -f2)), staying down"; exit 0; }
|
||||
wait_api
|
||||
reconcile
|
||||
;;
|
||||
write)
|
||||
# init-script hook: before mihomo starts, a fresh-OTP provider (or the off
|
||||
# one) and the matching routes, only where OpenVPN is set up
|
||||
[ -f "$PROVIDER_FILE" ] || exit 0
|
||||
if want_up; then
|
||||
routes_set on file
|
||||
write_provider
|
||||
else
|
||||
routes_set off file
|
||||
write_off_provider
|
||||
fi
|
||||
;;
|
||||
# exit code only: should the tunnel be up now (mihomo-kit.sh build, routes)
|
||||
want) want_up ;;
|
||||
check)
|
||||
# one run at a time: two slow probes can outlast the cron minute
|
||||
lock_take 0 || exit 0
|
||||
reconcile repair
|
||||
;;
|
||||
off)
|
||||
lock_wait
|
||||
touch "$OFF_FLAG"
|
||||
rm -f "$UNTIL_FLAG"
|
||||
[ "${OVPN_SCHED:-0}" = 1 ] && sched_set OVPN_SCHED 0
|
||||
tunnel_down
|
||||
log "OpenVPN off: tunnel closed and its routes dropped; the kit core tells the server (EXIT), other cores leave the session until its ping-restart (~5 min)"
|
||||
;;
|
||||
on)
|
||||
lock_wait
|
||||
rm -f "$OFF_FLAG" "$UNTIL_FLAG"
|
||||
[ "${OVPN_SCHED:-0}" = 1 ] && sched_set OVPN_SCHED 0
|
||||
wait_api
|
||||
reconcile
|
||||
;;
|
||||
# bring the tunnel up for N minutes, over the manual off and the schedule;
|
||||
# then whatever was in force before holds again (the cron applies it)
|
||||
for | extend)
|
||||
case "${2:-}" in '' | *[!0-9]* | 0) die "usage: ovpn.sh $1 <minutes>" ;; esac
|
||||
lock_wait
|
||||
_now=$(date +%s)
|
||||
# extend: from the end of the running timer, from now when none runs
|
||||
[ "$1" = extend ] && _from=$(timer_until) || _from=$_now
|
||||
_end=$((_from + $2 * 60))
|
||||
[ "$_end" -gt $((_now + TIMER_MAX * 60)) ] && _end=$((_now + TIMER_MAX * 60))
|
||||
echo "$_end" > "$UNTIL_FLAG"
|
||||
wait_api
|
||||
reconcile
|
||||
rc=$?
|
||||
eval "$(state)"
|
||||
log "OpenVPN on by timer until $until_hm $until_day; then $after ($why)"
|
||||
exit $rc
|
||||
;;
|
||||
stop)
|
||||
lock_wait
|
||||
rm -f "$UNTIL_FLAG"
|
||||
wait_api
|
||||
reconcile
|
||||
;;
|
||||
# schedule: "sched off" | "sched on" | "sched HH:MM HH:MM [DAYS]" (and enable) |
|
||||
# "sched days DAYS"; DAYS: digits 1 (Mon) .. 7 (Sun), weekdays, weekend, all.
|
||||
# Persists to the env file so the cron and the init hook read the same thing.
|
||||
sched)
|
||||
case "${2:-}" in
|
||||
'' | show)
|
||||
if [ "${OVPN_SCHED:-0}" = 1 ]; then
|
||||
echo "schedule on: $OVPN_SCHED_START-$OVPN_SCHED_END (router time), days $OVPN_SCHED_DAYS, jitter +-$OVPN_SCHED_JITTER min"
|
||||
else
|
||||
echo "schedule off"
|
||||
fi
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
lock_wait
|
||||
case "$2" in
|
||||
off)
|
||||
sched_set OVPN_SCHED 0
|
||||
touch "$OFF_FLAG"
|
||||
;;
|
||||
on)
|
||||
rm -f "$OFF_FLAG"
|
||||
sched_set OVPN_SCHED 1
|
||||
;;
|
||||
days)
|
||||
_dz=$(days_norm "${3:-}") && [ -n "$_dz" ] || die "usage: ovpn.sh sched days 12345 | weekdays | weekend | all"
|
||||
sched_set OVPN_SCHED_DAYS "$_dz"
|
||||
;;
|
||||
[0-9][0-9]:[0-9][0-9])
|
||||
_a=$(hhmm_to_min "$2") && _b=$(hhmm_to_min "${3:-}") || die "usage: ovpn.sh sched HH:MM HH:MM"
|
||||
# the jittered edges must not cross, or the window flips between
|
||||
# almost the whole day and nothing from day to day
|
||||
_j=$((${OVPN_SCHED_JITTER:-0} * 2))
|
||||
_len=$(((_b - _a + 1440) % 1440))
|
||||
[ "$_len" -gt "$_j" ] && [ "$_len" -lt $((1440 - _j)) ] ||
|
||||
die "the window must be longer than $_j min and shorter than 24 h minus $_j min (jitter +-${OVPN_SCHED_JITTER:-0} min)"
|
||||
if [ -n "${4:-}" ]; then
|
||||
_dz=$(days_norm "$4") && [ -n "$_dz" ] || die "days: digits 1 (Mon) .. 7 (Sun), weekdays, weekend or all"
|
||||
sched_set OVPN_SCHED_DAYS "$_dz"
|
||||
fi
|
||||
sched_set OVPN_SCHED_START "$2"
|
||||
sched_set OVPN_SCHED_END "$3"
|
||||
;;
|
||||
*) die "usage: ovpn.sh sched off | on | HH:MM HH:MM [DAYS] | days DAYS" ;;
|
||||
esac
|
||||
wait_api
|
||||
reconcile
|
||||
;;
|
||||
state) state ;;
|
||||
probe)
|
||||
tunnel_is_down && die "the tunnel is closed"
|
||||
wait_api
|
||||
if r=$(probe); then
|
||||
echo "$CHECK_URL through the tunnel: $(jsonfilter -s "$r" -e '@.delay' 2>/dev/null || echo '?') ms"
|
||||
else
|
||||
echo "$CHECK_URL does not open through the tunnel"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
status)
|
||||
eval "$(state)"
|
||||
case "$mode" in
|
||||
timer) echo "on by timer until $until_hm $until_day, then $after ($why)" ;;
|
||||
manual) echo "off (manual, until ovpn.sh on)" ;;
|
||||
always) echo "on (no schedule)" ;;
|
||||
schedule)
|
||||
[ "$want" = 1 ] && echo "on by schedule" || echo "off by schedule"
|
||||
;;
|
||||
esac
|
||||
if [ "$next" -gt 0 ]; then
|
||||
echo "schedule: $sched_start-$sched_end (router time), days $sched_days, today $win (jitter +-$jitter min)"
|
||||
[ "$mode" = schedule ] && echo "turns $next_to at $next_hm $next_day"
|
||||
fi
|
||||
case "$link" in
|
||||
closed) echo "tunnel closed" ;;
|
||||
up) echo "tunnel up since $up_hm $up_day" ;;
|
||||
connecting) echo "tunnel connecting${err:+ (last error: $err)}" ;;
|
||||
rejected) echo "the server rejected the session: the cron check gets a new OTP${retry_hm:+ after the pause, at $retry_hm}" ;;
|
||||
held) echo "reconnect pause ($retry_why${err:+: $err}): next attempt at $retry_hm" ;;
|
||||
*) echo "tunnel state unknown: this core does not report it (ovpn.sh probe opens $CHECK_URL)" ;;
|
||||
esac
|
||||
[ "$want" = 1 ] && [ "$tunnel" = down ] && echo "the cron check brings it up within a minute"
|
||||
[ "$want" = 0 ] && [ "$tunnel" = up ] && echo "the cron check takes it down within a minute"
|
||||
true
|
||||
;;
|
||||
# show the real handshake error: no handshake-timeout, debug log,
|
||||
# one request through the mixed port so the dial error gets logged
|
||||
debug)
|
||||
HANDSHAKE_TIMEOUT=0 write_provider
|
||||
api PATCH /configs -H 'Content-Type: application/json' -d '{"log-level":"debug"}' >/dev/null
|
||||
api PUT "/providers/proxies/$PROVIDER_NAME" >/dev/null || die "provider reload failed (API $API)"
|
||||
echo "password format: ${TOTP_SECRET:+$PASS_FORMAT}${TOTP_SECRET:-no TOTP}, length $(sed -n 's/^ password: "\(.*\)"$/\1/p' "$PROVIDER_FILE" | wc -c)"
|
||||
curl -skS -m 25 -o /dev/null -w "request via mihomo: http %{http_code}\n" \
|
||||
${MIXED_AUTH:+--proxy-user "$MIXED_AUTH"} \
|
||||
-x "http://127.0.0.1:$MIXED_PORT" "${DEBUG_URL:-$CHECK_URL}"
|
||||
# let LAN clients trigger a handshake and hit the 5s dial timeout
|
||||
sleep 20
|
||||
echo "--- log ---"
|
||||
{ cat /var/log/nikki/core.log 2>/dev/null || logread; } | grep -iE "openvpn" | tail -n 30
|
||||
echo "--- handshake errors ---"
|
||||
{ cat /var/log/nikki/core.log 2>/dev/null || logread; } | grep -E "OpenVPN" | tail -n 5
|
||||
;;
|
||||
*) echo "usage: $0 otp|authfile|refresh|check|on|off|sched|for|extend|stop|status|debug" >&2; exit 2 ;;
|
||||
esac
|
||||
@ -1,16 +1,14 @@
|
||||
# mihomo-kit profile. On the router:
|
||||
# /etc/nikki/profiles.d/common.env shared part (secrets: subscriptions, BOOT)
|
||||
# /etc/nikki/profiles.d/<name>.env per profile, overrides common.env
|
||||
# e.g. main.env = "LOCATION=main", whitelist.env = "LOCATION=whitelist".
|
||||
# Then: mihomo-kit.sh build && mihomo-kit.sh use main
|
||||
# e.g. home.env = "LOCATION=home", street.env = "LOCATION=street".
|
||||
# Then: mihomo-kit.sh build && mihomo-kit.sh use home
|
||||
# chmod 600: this file holds secrets.
|
||||
|
||||
# router | mobile (mobile: no torrent/OpenVPN/Tailscale, FlClash-style DNS)
|
||||
TARGET=router
|
||||
# main: normal use (home in Russia or abroad), OpenVPN/Tailscale/own servers go direct;
|
||||
# whitelist: OpenVPN through OVPN-EXIT (RU node), own servers through MY-EXIT, Tailscale through MY;
|
||||
# foreign (abroad): ru-inside and .ru through RU, the rest direct, OpenVPN through OVPN-EXIT
|
||||
LOCATION=main
|
||||
# home: OpenVPN/Tailscale go direct; street: OpenVPN goes through OVPN-EXIT (RU node)
|
||||
LOCATION=home
|
||||
|
||||
# subscription URLs, space separated. Provider name = id from the domain
|
||||
# (https://sub.kittyvpn.com/x -> kittyvpn; repeats -> kittyvpn2), or "name=url"
|
||||
@ -42,59 +40,14 @@ BOOT_SID=xxxxxxxxxxxxxxxx
|
||||
# torrent group for clients using source ports 20000-20199
|
||||
TORRENT=1
|
||||
|
||||
# own lists, space separated, above torrents / ru-inside / .ru / MAIN; first match:
|
||||
# MY, FOREIGN, RU. RU on main (home, own white IP) goes directly. IPs: CIDR (bare IP = /32);
|
||||
# domains: with subdomains ("example.com" = "*.example.com"); MY_*: group MY (HY2 and "[MY] ..." nodes of the subscriptions)
|
||||
# extra IPs routed through RU, space separated CIDRs
|
||||
RU_IPS="194.190.191.112/32"
|
||||
#FOREIGN_IPS="1.2.3.0/24"
|
||||
#MY_IPS="10.8.0.0/24"
|
||||
#RU_DOMAINS="example.ru *.example.com"
|
||||
#FOREIGN_DOMAINS="example.org"
|
||||
#MY_DOMAINS="home.example.org"
|
||||
#LOCAL_HOSTS="example.org=192.168.1.10" # own servers in this router's LAN: domain (+ subdomains)=LAN IP
|
||||
|
||||
# services: a site or app that always takes its own way and has its own group (name in
|
||||
# upper case); rules above the own lists. GEOSITE: lists of MetaCubeX/meta-rules-dat;
|
||||
# VIA: MY (default; the first alive own server - one exit IP), FOREIGN, RU, DIRECT, MAIN
|
||||
#SERVICES="claude"
|
||||
#SVC_CLAUDE_GEOSITE="anthropic"
|
||||
#SVC_CLAUDE_DOMAINS=""
|
||||
#SVC_CLAUDE_IPS=""
|
||||
#SVC_CLAUDE_VIA=MY # or a pool's group: DE
|
||||
#SVC_CLAUDE_SERVER="my-de" # fixed exit in every profile; empty = group above
|
||||
#SVC_CLAUDE_PROVIDER="" # empty = own server; or provider ID, e.g. sam_hub-my
|
||||
#SVC_CLAUDE_CHAIN=WL # entry for VIA = MY / a pool: DIRECT FOREIGN RU MY MY-EXIT or a pool
|
||||
|
||||
# pools: own servers and subscription nodes picked by hand, a group each (the name in upper
|
||||
# case) for the services' VIA. TYPE: fallback (default) | url-test | select; SERVERS: own
|
||||
# servers by name, ";" between; SUBS: "<id>" (nodes without [MY]) / "<id>-my" (only [MY]);
|
||||
# FILTER / EXCLUDE: mihomo regex over the subscription nodes' names
|
||||
#POOLS="de"
|
||||
#POOL_DE_TYPE=fallback
|
||||
#POOL_DE_SERVERS="de-1; nl-2"
|
||||
#POOL_DE_SUBS="sam_hub sam_hub-my"
|
||||
#POOL_DE_FILTER='(?i)🇩🇪|\bde\b'
|
||||
#POOL_DE_EXCLUDE='(?i)torrent'
|
||||
#POOL_DE_UPLINK=1 # offer in UPLINK: everything through the pool first
|
||||
|
||||
# [MY] nodes of the subscriptions with an entry of their own (LuCI: «Свои серверы» →
|
||||
# «Из подписок ([MY])»): "<ENTRY>|<id>-my|<exact node name>", ENTRY FOREIGN, RU, DIRECT or a pool
|
||||
#MY_NODE_1='FOREIGN|sam_hub-my|[MY] 🇩🇪 de-1'
|
||||
|
||||
# OpenVPN by /etc/nikki/openvpn.ovpn, login in /etc/nikki/openvpn.env (ovpn.sh)
|
||||
# OpenVPN (BMSTU), needs /etc/nikki/bmstu.env and bmstu-otp.sh
|
||||
OPENVPN=0
|
||||
#OVPN_ROUTES="10.0.0.0/8 192.168.50.0/24" # what goes through the VPN (LuCI: the .ovpn's route lines)
|
||||
#OVPN_SERVER_HOST=vpn.example.com # default: the remote lines of the .ovpn
|
||||
#OVPN_SERVER_IPS="203.0.113.10"
|
||||
#OVPN_CHECK_URL=https://intranet.example.com # a page behind the VPN for the manual check
|
||||
|
||||
# weak routers (256 MB RAM): health checks every 10 min and only with traffic, sniffer
|
||||
# without QUIC, quiet core; on apply also GOMEMLIMIT (LITE_GOMEMLIMIT, default 64MiB)
|
||||
# for mihomo, nikki log level warning, no process lookup, interception without TUN
|
||||
# (TCP redirect, UDP tproxy + kmod-nft-tproxy; LITE_TPROXY=0: leave nikki's modes alone)
|
||||
LITE=0
|
||||
#LITE_GOMEMLIMIT=64MiB
|
||||
#LITE_TPROXY=0
|
||||
#OVPN_SERVER_HOST=openvpn4.bmstu.ru
|
||||
#OVPN_SERVER_IPS="195.19.40.7 195.19.33.86"
|
||||
#OVPN_ROUTES="172.16.0.0/16 172.19.33.0/24 195.19.32.0/19"
|
||||
|
||||
# Tailscale (first login: URL in /var/log/nikki/core.log)
|
||||
TAILSCALE=0
|
||||
|
||||
@ -7,14 +7,9 @@ dns:
|
||||
fake-ip-filter:
|
||||
- '*.lan'
|
||||
- '*.local' #@router
|
||||
- '+.ru' #@!foreign
|
||||
- '+.xn--p1ai' #@router,!foreign
|
||||
- rule-set:ru-inside #@router,!foreign
|
||||
# tailnet names: real 100.x addresses from MagicDNS (nameserver-policy below) #@tailscale
|
||||
- '+.ts.net' #@tailscale
|
||||
- '+.${@TS_DOMAINS}' #@tailscale
|
||||
# own servers in the LAN (LOCAL_HOSTS): clients get the real LAN address #@local_hosts
|
||||
- '+.${@LOCAL_DOMAINS}' #@local_hosts
|
||||
- '+.ru'
|
||||
- '+.xn--p1ai' #@router
|
||||
- geosite:ru-inside #@router
|
||||
|
||||
default-nameserver:
|
||||
- 77.88.8.8
|
||||
@ -25,22 +20,10 @@ dns:
|
||||
- https://77.88.8.8/dns-query
|
||||
|
||||
direct-nameserver:
|
||||
- 77.88.8.8 #@!foreign
|
||||
- 77.88.8.1 #@!foreign
|
||||
- 1.1.1.1 #@foreign
|
||||
- 8.8.8.8 #@foreign
|
||||
- 77.88.8.8
|
||||
- 77.88.8.1
|
||||
|
||||
nameserver:
|
||||
- https://1.1.1.1/dns-query #@router
|
||||
- https://dns.google/dns-query
|
||||
- https://1.1.1.1/dns-query #@mobile
|
||||
|
||||
# MagicDNS of the embedded Tailscale (the proxy named "tailscale") #@tailscale
|
||||
nameserver-policy: #@tailscale
|
||||
'+.ts.net': tailscale://tailscale #@tailscale
|
||||
'+.${@TS_DOMAINS}': tailscale://tailscale #@tailscale
|
||||
|
||||
# LOCAL_HOSTS: own domains -> LAN addresses (dns.use-hosts is on by default), so neither #@local_hosts
|
||||
# the core nor the clients go out to the white IP and back into the router itself #@local_hosts
|
||||
hosts: #@local_hosts
|
||||
${@@LOCAL_HOSTS_YAML} #@local_hosts
|
||||
|
||||
@ -5,3 +5,12 @@
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
# default for downloading subscriptions: BOOT, else the nodes of the saved
|
||||
# subscriptions (providers are cached on disk), else direct
|
||||
- name: BOOT-AUTO
|
||||
type: fallback
|
||||
proxies: [BOOT, FOREIGN, DIRECT]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
# default for downloading subscriptions: BOOT (if set), else the nodes of the
|
||||
# saved subscriptions (providers are cached on disk), else direct. FOREIGN goes
|
||||
# before DIRECT: the health check of DIRECT (gstatic) passes in Russia even when
|
||||
# the subscription site itself is blocked.
|
||||
- name: BOOT-AUTO
|
||||
type: fallback
|
||||
proxies: [BOOT, FOREIGN, DIRECT] #@boot
|
||||
proxies: [FOREIGN, DIRECT] #@!boot
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
@ -2,9 +2,7 @@
|
||||
type: url-test
|
||||
use: [${SUB_LIST}]
|
||||
filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
# lite: the provider's URL, so RU nodes are not tested a second time
|
||||
url: "https://ya.ru" #@!lite
|
||||
url: "https://www.gstatic.com/generate_204" #@lite
|
||||
url: "https://ya.ru"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
# url: what the dashboard's delay test opens through the tunnel;
|
||||
# interval 0: no background checks (they would redial with a stale code)
|
||||
# interval 0: no background checks (they would redial with a stale OTP)
|
||||
- name: ${OVPN_GROUP}
|
||||
type: select
|
||||
use: [${OVPN_PROVIDER}]
|
||||
|
||||
@ -1,7 +0,0 @@
|
||||
# what the OpenVPN tunnel itself goes through on whitelist and foreign (ovpn_exit):
|
||||
# a RU node, for a VPN server in Russia. select, not url-test: switching nodes
|
||||
# would break the tunnel. Pick one in the dashboard, the choice is remembered.
|
||||
- name: OVPN-EXIT
|
||||
type: select
|
||||
use: [${SUB_LIST}]
|
||||
filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
7
templates/groups/41-openvpn.street.yaml
Normal file
7
templates/groups/41-openvpn.street.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
# what the OpenVPN tunnel itself goes through on a whitelisted network.
|
||||
# select, not url-test: switching nodes would break the tunnel.
|
||||
# Pick a concrete RU node in the dashboard, the choice is remembered.
|
||||
- name: OVPN-EXIT
|
||||
type: select
|
||||
use: [${SUB_LIST}]
|
||||
filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
@ -1,15 +0,0 @@
|
||||
# pool ${POOL_NAME} (POOLS, POOL_*): own servers and subscription nodes picked in the settings;
|
||||
# filter / exclude-filter apply to the subscriptions' nodes only
|
||||
- name: ${POOL_GROUP}
|
||||
type: ${POOL_TYPE}
|
||||
empty-fallback: REJECT #@pool_fixed
|
||||
proxies: [${POOL_PROXIES}] #@pool_proxies
|
||||
use: [${POOL_USE}] #@pool_use
|
||||
filter: "${POOL_FILTER}" #@pool_filter
|
||||
exclude-filter: "${POOL_EXCLUDE}" #@pool_exclude
|
||||
url: "https://www.gstatic.com/generate_204" #@!pool_select
|
||||
interval: 300 #@!pool_select,!lite
|
||||
interval: 600 #@!pool_select,lite
|
||||
tolerance: 50 #@pool_urltest
|
||||
lazy: false #@!pool_select,!lite
|
||||
lazy: true #@!pool_select,lite
|
||||
19
templates/groups/45-hy2.yaml
Normal file
19
templates/groups/45-hy2.yaml
Normal file
@ -0,0 +1,19 @@
|
||||
# own hysteria2 servers: the fastest alive one; pin one in the dashboard if needed
|
||||
- name: MY
|
||||
type: url-test
|
||||
proxies: [${HY2_LIST}]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
# street and mobile (hy2_exit): what own servers are reached through; switches only when the node is
|
||||
# clearly worse or dead (each switch breaks everything going through MY)
|
||||
- name: MY-EXIT #@hy2_exit
|
||||
type: url-test #@hy2_exit
|
||||
use: [${SUB_LIST}] #@hy2_exit
|
||||
exclude-filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск" #@hy2_exit
|
||||
url: "https://www.gstatic.com/generate_204" #@hy2_exit
|
||||
interval: 300 #@hy2_exit
|
||||
tolerance: 300 #@hy2_exit
|
||||
lazy: false #@hy2_exit
|
||||
@ -1,23 +0,0 @@
|
||||
# own servers: those of the settings (proxies/30-own_srv) and the "[MY] ..." nodes of
|
||||
# the subscriptions (providers <id>-my); the fastest alive one; pin one in the dashboard if needed
|
||||
- name: MY
|
||||
type: url-test
|
||||
proxies: [${OWN_LIST}] #@own_srv
|
||||
use: [${MY_SUB_LIST}]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300 #@!lite
|
||||
interval: 600 #@lite
|
||||
tolerance: 50
|
||||
lazy: false #@!lite
|
||||
lazy: true #@lite
|
||||
|
||||
# whitelist and mobile (my_exit): what own servers are reached through; switches only when the node is
|
||||
# clearly worse or dead (each switch breaks everything going through MY)
|
||||
- name: MY-EXIT #@my_exit
|
||||
type: url-test #@my_exit
|
||||
use: [${SUB_LIST}] #@my_exit
|
||||
exclude-filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск" #@my_exit
|
||||
url: "https://www.gstatic.com/generate_204" #@my_exit
|
||||
interval: 300 #@my_exit
|
||||
tolerance: 300 #@my_exit
|
||||
lazy: false #@my_exit
|
||||
@ -1,15 +0,0 @@
|
||||
# service ${SVC_NAME} (SERVICES, SVC_*): its own way, whatever MAIN is
|
||||
# through own servers: the first alive one, not the fastest - the exit IP stays the #@svc_my
|
||||
# same while the server lives (a site that checks the region sees one country); #@svc_my
|
||||
# pick another in the dashboard, the choice is remembered #@svc_my
|
||||
- name: ${SVC_GROUP}
|
||||
type: fallback #@svc_my
|
||||
proxies: [${OWN_LIST}] #@svc_my,own_srv
|
||||
use: [${MY_SUB_LIST}] #@svc_my
|
||||
url: "https://www.gstatic.com/generate_204" #@svc_my
|
||||
interval: 300 #@svc_my,!lite
|
||||
interval: 600 #@svc_my,lite
|
||||
lazy: false #@svc_my,!lite
|
||||
lazy: true #@svc_my,lite
|
||||
type: select #@!svc_my
|
||||
proxies: [${SVC_PROXIES}] #@!svc_my
|
||||
@ -1,15 +0,0 @@
|
||||
# ${VG_POOL} through ${VG_ENTRY} (SVC_<NAME>_CHAIN, POOL_<NAME>_UPLINK): its servers and
|
||||
# nodes, each dialing through ${VG_ENTRY}
|
||||
- name: "${VG_NAME}"
|
||||
type: ${VG_TYPE}
|
||||
empty-fallback: REJECT #@vg_fixed
|
||||
proxies: [${VG_PROXIES}] #@vg_proxies
|
||||
use: [${VG_USE}] #@vg_use
|
||||
filter: "${VG_FILTER}" #@vg_filter
|
||||
exclude-filter: "${VG_EXCLUDE}" #@vg_exclude
|
||||
url: "https://www.gstatic.com/generate_204" #@!vg_select
|
||||
interval: 300 #@!vg_select,!lite
|
||||
interval: 600 #@!vg_select,lite
|
||||
tolerance: 50 #@vg_urltest
|
||||
lazy: false #@!vg_select,!lite
|
||||
lazy: true #@!vg_select,lite
|
||||
@ -2,6 +2,6 @@
|
||||
# cannot do it in mihomo, so only ss / hysteria2 / tuic / socks5 nodes here.
|
||||
- name: TS-EXIT
|
||||
type: select
|
||||
proxies: [MY] #@own
|
||||
proxies: [MY] #@hy2
|
||||
use: [${SUB_LIST}]
|
||||
exclude-type: "vless|vmess|trojan"
|
||||
|
||||
@ -1,8 +0,0 @@
|
||||
# UPLINK: what the subscription nodes, BOOT seeds and own servers connect
|
||||
# through. DIRECT - as before; CSQTT - through csqtt0 first (out of the
|
||||
# whitelist); a pool (POOL_<NAME>_UPLINK=1) - through its servers, they themselves
|
||||
# direct; then FOREIGN / MY / RU work on top of it as usual.
|
||||
# On whitelist own servers go MY-EXIT -> node -> UPLINK.
|
||||
- name: UPLINK
|
||||
type: select
|
||||
proxies: [DIRECT${UPLINK_MORE}]
|
||||
@ -1,5 +1,3 @@
|
||||
- name: MAIN
|
||||
type: select
|
||||
proxies: [FOREIGN, MY, RU, DIRECT${CSQTT_MAIN}] #@!foreign
|
||||
# abroad: direct by default, own servers / pools by hand #@foreign
|
||||
proxies: [DIRECT, MY, FOREIGN, RU${CSQTT_MAIN}] #@foreign
|
||||
proxies: [FOREIGN, ${HY2_MAIN}RU, DIRECT]
|
||||
|
||||
4
templates/groups/92-base.router.yaml
Normal file
4
templates/groups/92-base.router.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
- name: PUSH
|
||||
type: select
|
||||
proxies: [DIRECT, ${HY2_MAIN}FOREIGN] #@home
|
||||
proxies: [${HY2_MAIN}FOREIGN, DIRECT] #@street
|
||||
@ -1,6 +0,0 @@
|
||||
- name: PUSH
|
||||
type: select
|
||||
proxies: [DIRECT, MY, FOREIGN] #@!whitelist
|
||||
proxies: [MY, FOREIGN, DIRECT] #@whitelist,own
|
||||
# no own servers in the settings: MY may be empty (no [MY] nodes in the subscriptions) #@whitelist,!own
|
||||
proxies: [FOREIGN, MY, DIRECT] #@whitelist,!own
|
||||
7
templates/head/10-base.yaml
Normal file
7
templates/head/10-base.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
geodata-mode: true
|
||||
geodata-loader: memconservative
|
||||
geo-auto-update: true
|
||||
geo-update-interval: 24
|
||||
geox-url:
|
||||
geoip: "${GEOIP_URL}"
|
||||
geosite: "${GEOSITE_URL}"
|
||||
@ -1,7 +0,0 @@
|
||||
# LITE=1 (weak routers). nikki's mixin overrides keys whose uci options are set
|
||||
# (mihomo-kit.sh puts log_level / match_process there); these cover the rest
|
||||
log-level: warning
|
||||
find-process-mode: off #@!csqtt
|
||||
tcp-concurrent: false
|
||||
unified-delay: false
|
||||
geo-auto-update: false
|
||||
@ -4,20 +4,13 @@
|
||||
path: ./providers/${SUB_NAME}.yaml
|
||||
interval: 3600
|
||||
proxy: ${@SUB_PROXY}
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
override: #@uplink
|
||||
dialer-proxy: UPLINK #@uplink
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь"
|
||||
header:
|
||||
User-Agent: ["${SUB_UA}"]
|
||||
${@@SUB_HEADERS}
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300 #@!lite
|
||||
interval: 600 #@lite
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false #@!lite
|
||||
lazy: true #@lite
|
||||
lazy: false
|
||||
|
||||
@ -1,32 +0,0 @@
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
${SUB_NAME}-my:
|
||||
type: file #@router
|
||||
path: ./providers/${SUB_NAME}.yaml #@router
|
||||
type: http #@mobile
|
||||
url: "${SUB_URL}" #@mobile
|
||||
path: ./providers/${SUB_NAME}-my.yaml #@mobile
|
||||
interval: 3600 #@mobile
|
||||
proxy: ${@SUB_PROXY} #@mobile
|
||||
filter: "(?i)\\[MY\\]"
|
||||
exclude-filter: "${@@SUB_MY_EXCLUDE}"
|
||||
override: #@my_exit
|
||||
dialer-proxy: MY-EXIT #@my_exit
|
||||
override: #@uplink,!my_exit
|
||||
dialer-proxy: UPLINK #@uplink,!my_exit
|
||||
header: #@mobile
|
||||
User-Agent: ["${SUB_UA}"] #@mobile
|
||||
${@@SUB_HEADERS} #@mobile
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300 #@!lite
|
||||
interval: 600 #@lite
|
||||
timeout: 3000
|
||||
lazy: false #@!lite
|
||||
lazy: true #@lite
|
||||
@ -1,24 +0,0 @@
|
||||
# [MY] nodes of ${SUB_NAME} with an entry of their own (LuCI «Свои серверы» → «Вход»):
|
||||
# out of ${SUB_NAME}-my, dialing through ${MV_ENTRY} in every profile
|
||||
${MV_NAME}:
|
||||
type: file #@router
|
||||
path: ./providers/${SUB_NAME}.yaml #@router
|
||||
type: http #@mobile
|
||||
url: "${SUB_URL}" #@mobile
|
||||
path: ./providers/${MV_NAME}.yaml #@mobile
|
||||
interval: 3600 #@mobile
|
||||
proxy: ${@SUB_PROXY} #@mobile
|
||||
filter: "${MV_FILTER}"
|
||||
override:
|
||||
dialer-proxy: ${MV_ENTRY}
|
||||
header: #@mobile
|
||||
User-Agent: ["${SUB_UA}"] #@mobile
|
||||
${@@SUB_HEADERS} #@mobile
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300 #@!lite
|
||||
interval: 600 #@lite
|
||||
timeout: 3000
|
||||
lazy: false #@!lite
|
||||
lazy: true #@lite
|
||||
@ -1,18 +0,0 @@
|
||||
# own servers as links (MY_LINKS, LuCI "Свои серверы (ссылки)"): kit writes them to
|
||||
# this file on build, mihomo parses vless/vmess/trojan/ss/hysteria2/tuic/anytls links
|
||||
# like a subscription; group MY, named "[MY] ..." like the [MY] nodes of the subscriptions
|
||||
my-links:
|
||||
type: file
|
||||
path: ./providers/my-links.txt
|
||||
override:
|
||||
additional-prefix: "[MY] "
|
||||
dialer-proxy: MY-EXIT #@my_exit
|
||||
dialer-proxy: UPLINK #@uplink,!my_exit
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300 #@!lite
|
||||
interval: 600 #@lite
|
||||
timeout: 3000
|
||||
lazy: false #@!lite
|
||||
lazy: true #@lite
|
||||
@ -1,26 +0,0 @@
|
||||
# ${VP_BASE} for the chains through ${VP_ENTRY}: the same nodes, named "... ⟶ ${VP_ENTRY}"
|
||||
${VP_NAME}:
|
||||
type: file #@router
|
||||
path: ${VP_PATH} #@router
|
||||
type: http #@mobile
|
||||
url: "${SUB_URL}" #@mobile
|
||||
path: ./providers/${VP_NAME}.yaml #@mobile
|
||||
interval: 3600 #@mobile
|
||||
proxy: ${@SUB_PROXY} #@mobile
|
||||
filter: "(?i)\\[MY\\]" #@vp_my
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]" #@vp_sub
|
||||
override:
|
||||
additional-prefix: "[MY] " #@vp_links
|
||||
additional-suffix: " ⟶ ${VP_ENTRY}"
|
||||
dialer-proxy: ${VP_ENTRY} #@!vp_direct
|
||||
header: #@mobile
|
||||
User-Agent: ["${SUB_UA}"] #@mobile
|
||||
${@@SUB_HEADERS} #@mobile
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300 #@!lite
|
||||
interval: 600 #@lite
|
||||
timeout: 3000
|
||||
lazy: false #@!lite
|
||||
lazy: true #@lite
|
||||
@ -1,10 +1,10 @@
|
||||
# OpenVPN: file written on the router by ovpn.sh (with TOTP: a fresh code in the
|
||||
# OpenVPN: file written on the router by bmstu-otp.sh (fresh TOTP in the
|
||||
# password). No health-check here: a dead tunnel would be redialed with a
|
||||
# stale code; the cron watchdog (ovpn.sh check) handles it.
|
||||
# stale OTP; the cron watchdog (bmstu-otp.sh check) handles it.
|
||||
${OVPN_PROVIDER}:
|
||||
type: file
|
||||
path: ./providers/${OVPN_PROVIDER}.yaml
|
||||
health-check:
|
||||
enable: false
|
||||
override: #@ovpn_exit
|
||||
dialer-proxy: OVPN-EXIT #@ovpn_exit
|
||||
override: #@street
|
||||
dialer-proxy: OVPN-EXIT #@street
|
||||
|
||||
@ -12,4 +12,3 @@
|
||||
reality-opts:
|
||||
public-key: ${SEED_PBK}
|
||||
short-id: ${SEED_SID}
|
||||
dialer-proxy: UPLINK #@uplink
|
||||
|
||||
@ -9,7 +9,3 @@
|
||||
udp: true
|
||||
accept-routes: true
|
||||
dialer-proxy: TS-EXIT #@ts_exit
|
||||
# whitelist: control and DERP over TCP through own servers (MY -> own node -> MY-EXIT); #@whitelist,!ts_exit
|
||||
# MY holds hysteria2 from the settings and "[MY]" nodes of the subscriptions; empty MY is direct #@whitelist,!ts_exit
|
||||
# needs the kit's core (v1.19.32-ts1, tools/core/*.patch, MetaCubeX/mihomo#3142) #@whitelist,!ts_exit
|
||||
dialer-proxy: MY #@whitelist,!ts_exit
|
||||
|
||||
13
templates/proxies/30-hy2.each.yaml
Normal file
13
templates/proxies/30-hy2.each.yaml
Normal file
@ -0,0 +1,13 @@
|
||||
- name: ${HY2_NAME}
|
||||
type: hysteria2
|
||||
server: ${HY2_SERVER}
|
||||
port: ${HY2_PORT}
|
||||
password: "${HY2_PASSWORD}"
|
||||
obfs: ${@HY2_OBFS}
|
||||
obfs-password: "${@@HY2_OBFS_PASSWORD}"
|
||||
sni: ${@HY2_SNI}
|
||||
skip-cert-verify: ${HY2_INSECURE}
|
||||
up: "${@@HY2_UP}"
|
||||
down: "${@@HY2_DOWN}"
|
||||
udp: true
|
||||
dialer-proxy: MY-EXIT #@hy2_exit
|
||||
@ -1,8 +0,0 @@
|
||||
# own servers of the settings (LuCI "Свои серверы", /etc/nikki/my-servers): one JSON
|
||||
# proxy per line, as mihomo's own config would have it; the kit puts dialer-proxy in
|
||||
# front: whitelist and the phone through MY-EXIT, else with UPLINK (CSQTT, pools) through it.
|
||||
# A server with an entry of its own (LuCI "Вход") keeps it in every profile
|
||||
- {"dialer-proxy": "MY-EXIT", ${@@OWN_PLAIN} #@my_exit
|
||||
- {"dialer-proxy": "UPLINK", ${@@OWN_PLAIN} #@uplink,!my_exit
|
||||
- {${@@OWN_PLAIN} #@!my_exit,!uplink
|
||||
${@@OWN_ENTRY}
|
||||
@ -1,3 +0,0 @@
|
||||
# copies of own servers for the chains (SVC_<NAME>_CHAIN, POOL_<NAME>_UPLINK): the same
|
||||
# server dialing through another entry, named "<server> ⟶ <entry>" (group "<pool> ⟶ <entry>")
|
||||
${@@VARIANT_PROXIES}
|
||||
@ -1,6 +0,0 @@
|
||||
# CSQTT (star-panel-csqtt): tunnel interface csqtt0 on the router, mihomo
|
||||
# just sends the connection out of it (the interface does not change routes)
|
||||
- name: CSQTT
|
||||
type: direct
|
||||
interface-name: ${CSQTT_IFACE}
|
||||
udp: true
|
||||
@ -1,18 +0,0 @@
|
||||
# Russian services (geosite ru-inside of russia-only, as .mrs): an ordinary
|
||||
# http rule-set, so every client fetches it with the config, no geodata setup
|
||||
ru-inside:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "${RULESET_URL}/ru-inside.mrs"
|
||||
path: ./ruleset/ru-inside.mrs
|
||||
interval: 86400
|
||||
# Russian services outside ru-inside and outside .ru/.su/.рф (russia-only ru-services):
|
||||
# not on the whitelist, so through RU everywhere but main
|
||||
ru-services:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "${RULESET_URL}/ru-services.mrs"
|
||||
path: ./ruleset/ru-services.mrs
|
||||
interval: 86400
|
||||
@ -1,7 +0,0 @@
|
||||
# OpenVPN routes (OVPN_ROUTES): the file is written by mihomo-kit.sh build and
|
||||
# emptied by ovpn.sh off, so with the tunnel off these addresses follow
|
||||
# the normal rules instead of a dead OpenVPN group
|
||||
${OVPN_PROVIDER}-routes:
|
||||
type: file
|
||||
behavior: ipcidr
|
||||
path: ./providers/${OVPN_PROVIDER}-routes.yaml
|
||||
@ -1,8 +0,0 @@
|
||||
# services (SERVICES): geosite list ${GEOSITE_NAME} of MetaCubeX/meta-rules-dat
|
||||
geosite-${GEOSITE_NAME}:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "${GEOSITE_URL}/${GEOSITE_NAME}.mrs"
|
||||
path: ./ruleset/geosite-${GEOSITE_NAME}.mrs
|
||||
interval: 86400
|
||||
@ -1,7 +0,0 @@
|
||||
# service ${SVC_NAME}: domains of its hostlists (SVC_<NAME>_HOSTLIST, e.g. zapret's #@svc_hostlist
|
||||
# /opt/zapret2/ipset/*.txt), read when the profile is built: rebuild to pick up changes #@svc_hostlist
|
||||
hostlist-${SVC_NAME}: #@svc_hostlist
|
||||
type: inline #@svc_hostlist
|
||||
behavior: domain #@svc_hostlist
|
||||
payload: #@svc_hostlist
|
||||
- "${@SVC_HOSTLIST}" #@svc_hostlist
|
||||
@ -1,2 +0,0 @@
|
||||
# the CSQTT client's own connections (peer, VK TURN) must not go into its tunnel
|
||||
- PROCESS-NAME,${@CSQTT_PROCESS},DIRECT
|
||||
@ -1,8 +1,7 @@
|
||||
# the OpenVPN server itself (remote lines of the .ovpn) must not go into its own tunnel
|
||||
- IP-CIDR,${@OVPN_SERVER_IPS}/32,DIRECT,no-resolve #@!ovpn_exit
|
||||
- IP-CIDR,${@OVPN_SERVER_IPS}/32,OVPN-EXIT,no-resolve #@ovpn_exit
|
||||
- DOMAIN,${@OVPN_SERVER_HOST},DIRECT #@!ovpn_exit
|
||||
- DOMAIN,${@OVPN_SERVER_HOST},OVPN-EXIT #@ovpn_exit
|
||||
# the networks that go through the VPN (OVPN_ROUTES; before the private-range DIRECT
|
||||
# rules); a rule-provider so that ovpn.sh off can drop them without a restart
|
||||
- RULE-SET,${OVPN_PROVIDER}-routes,${OVPN_GROUP},no-resolve
|
||||
# OpenVPN server itself must not go into its own tunnel
|
||||
- IP-CIDR,${@OVPN_SERVER_IPS}/32,DIRECT,no-resolve #@home
|
||||
- IP-CIDR,${@OVPN_SERVER_IPS}/32,OVPN-EXIT,no-resolve #@street
|
||||
- DOMAIN,${OVPN_SERVER_HOST},DIRECT #@home
|
||||
- DOMAIN,${OVPN_SERVER_HOST},OVPN-EXIT #@street
|
||||
# networks pushed by the server (before the private-range DIRECT rules)
|
||||
- IP-CIDR,${@OVPN_ROUTES},${OVPN_GROUP},no-resolve
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
# push notifications (Apple APNs, Google FCM): long-lived connections on a
|
||||
# stable path - group PUSH (main/foreign: DIRECT, whitelist: MY)
|
||||
# stable path - group PUSH (home: DIRECT, street: MY)
|
||||
- DOMAIN-SUFFIX,push.apple.com,PUSH
|
||||
- IP-CIDR,17.249.0.0/16,PUSH,no-resolve
|
||||
- IP-CIDR,17.252.0.0/16,PUSH,no-resolve
|
||||
@ -1,5 +0,0 @@
|
||||
# service ${SVC_NAME}: above the own lists, below the tunnels, LAN and push
|
||||
- RULE-SET,geosite-${@SVC_GEOSITE},${SVC_GROUP}
|
||||
- DOMAIN-SUFFIX,${@SVC_DOMAINS},${SVC_GROUP}
|
||||
- IP-CIDR,${@SVC_IPS},${SVC_GROUP}
|
||||
- RULE-SET,hostlist-${SVC_NAME},${SVC_GROUP} #@svc_hostlist
|
||||
@ -1,14 +1 @@
|
||||
# own lists from the settings: above torrents, ru-inside, .ru and MATCH; below the
|
||||
# tunnels, LAN and push. Domains (DOMAIN-SUFFIX: the domain and all subdomains)
|
||||
# before IPs; first match wins: MY, then FOREIGN, then RU.
|
||||
# RU on main (home, own white IP): reachable directly; whitelist/abroad: through RU
|
||||
# LOCAL_HOSTS: own servers in the LAN, before everything else #@local_hosts
|
||||
- DOMAIN-SUFFIX,${@LOCAL_DOMAINS},DIRECT
|
||||
- DOMAIN-SUFFIX,${@MY_DOMAINS},MY
|
||||
- DOMAIN-SUFFIX,${@FOREIGN_DOMAINS},FOREIGN
|
||||
- DOMAIN-SUFFIX,${@RU_DOMAINS},DIRECT #@main
|
||||
- DOMAIN-SUFFIX,${@RU_DOMAINS},RU #@!main
|
||||
- IP-CIDR,${@MY_IPS},MY
|
||||
- IP-CIDR,${@FOREIGN_IPS},FOREIGN
|
||||
- IP-CIDR,${@RU_IPS},DIRECT #@main
|
||||
- IP-CIDR,${@RU_IPS},RU #@!main
|
||||
- IP-CIDR,${@RU_IPS},RU
|
||||
|
||||
@ -1,13 +1,4 @@
|
||||
- RULE-SET,ru-inside,DIRECT #@!foreign
|
||||
# abroad: Russian services through the RU pool too #@foreign
|
||||
- RULE-SET,ru-inside,RU #@foreign
|
||||
# main (home, own white IP): ru-services and .ru/.su/.рф directly; elsewhere through RU
|
||||
- RULE-SET,ru-services,DIRECT #@main
|
||||
- DOMAIN-SUFFIX,ru,DIRECT #@main
|
||||
- DOMAIN-SUFFIX,su,DIRECT #@main
|
||||
- DOMAIN-SUFFIX,xn--p1ai,DIRECT #@main
|
||||
- RULE-SET,ru-services,RU #@!main
|
||||
- DOMAIN-SUFFIX,ru,RU #@!main
|
||||
- DOMAIN-SUFFIX,su,RU #@!main
|
||||
- DOMAIN-SUFFIX,xn--p1ai,RU #@!main
|
||||
- GEOSITE,ru-inside,DIRECT
|
||||
- DOMAIN-SUFFIX,ru,RU
|
||||
- DOMAIN-SUFFIX,xn--p1ai,RU
|
||||
- MATCH,MAIN
|
||||
|
||||
@ -3,17 +3,10 @@ sniffer:
|
||||
force-dns-mapping: true
|
||||
parse-pure-ip: true
|
||||
override-destination: false
|
||||
# ECH: browsers show the outer name cloudflare-ech.com instead of the site behind
|
||||
# Cloudflare; the sniffed name wins in the rules, so .ru / own lists would miss the
|
||||
# site. Skipped: the rules see the name from mihomo's DNS (fake-ip / DNS mapping).
|
||||
skip-domain:
|
||||
- "+.cloudflare-ech.com"
|
||||
sniff:
|
||||
HTTP:
|
||||
ports: [80, 8080-8880] #@!lite
|
||||
ports: [80, 8080] #@lite
|
||||
ports: [80, 8080-8880]
|
||||
TLS:
|
||||
ports: [443, 8443]
|
||||
# lite: no QUIC (fake-ip already gives the domain; pure-IP QUIC goes by IP)
|
||||
QUIC: #@!lite
|
||||
ports: [443, 8443] #@!lite
|
||||
QUIC:
|
||||
ports: [443, 8443]
|
||||
|
||||
@ -1,24 +0,0 @@
|
||||
[Interface]
|
||||
Address = 10.8.1.2/32
|
||||
DNS = 1.1.1.1, 1.0.0.1
|
||||
PrivateKey = fTo2df+b5vCuulh7pOXMWiWJY2VwSe2Kuup2nA34tfI=
|
||||
Jc = 4
|
||||
Jmin = 10
|
||||
Jmax = 50
|
||||
S1 = 98
|
||||
S2 = 32
|
||||
S3 = 19
|
||||
S4 = 7
|
||||
H1 = 1458367412-1593426716
|
||||
H2 = 1863071624-1902347825
|
||||
H3 = 2091548318-2097143921
|
||||
H4 = 2112573893-2147191025
|
||||
I1 = <r 2><b 0x858000010001000000000669636c6f756403636f6d0000010001c00c000100010000105a00044d583737>
|
||||
I2 =
|
||||
|
||||
[Peer]
|
||||
PublicKey = vGYpG72gCXPNfYzr/0iNfSoL83vbrVSGUC+v+MKRVyE=
|
||||
PresharedKey = 6ut/J6EuaJ97RMFcZuiJkzIo7a5uxR98htK5NdWJW6E=
|
||||
AllowedIPs = 0.0.0.0/0, ::/0
|
||||
Endpoint = 203.0.113.10:47613
|
||||
PersistentKeepalive = 25
|
||||
@ -1,31 +0,0 @@
|
||||
{
|
||||
"servers": [
|
||||
{
|
||||
"name": "awg2",
|
||||
"type": "wireguard",
|
||||
"server": "203.0.113.10",
|
||||
"port": 47613,
|
||||
"ip": "10.8.1.2",
|
||||
"private-key": "fTo2df+b5vCuulh7pOXMWiWJY2VwSe2Kuup2nA34tfI=",
|
||||
"public-key": "vGYpG72gCXPNfYzr/0iNfSoL83vbrVSGUC+v+MKRVyE=",
|
||||
"pre-shared-key": "6ut/J6EuaJ97RMFcZuiJkzIo7a5uxR98htK5NdWJW6E=",
|
||||
"persistent-keepalive": 25,
|
||||
"udp": true,
|
||||
"amnezia-wg-option": {
|
||||
"jc": 4,
|
||||
"jmin": 10,
|
||||
"jmax": 50,
|
||||
"s1": 98,
|
||||
"s2": 32,
|
||||
"s3": 19,
|
||||
"s4": 7,
|
||||
"h1": "1458367412-1593426716",
|
||||
"h2": "1863071624-1902347825",
|
||||
"h3": "2091548318-2097143921",
|
||||
"h4": "2112573893-2147191025",
|
||||
"i1": "<r 2><b 0x858000010001000000000669636c6f756403636f6d0000010001c00c000100010000105a00044d583737>"
|
||||
}
|
||||
}
|
||||
],
|
||||
"errors": []
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
# AmneziaWG 3, IPv6 endpoint
|
||||
[Interface]
|
||||
PrivateKey = Se+IZIi2AQD3AZjN7AazYfi+j3yqITfYwkTkOzVj1Wo=
|
||||
Address = 10.8.1.3/32, fd00:8:1::3/128
|
||||
MTU = 1280
|
||||
Jc = 3
|
||||
Jmin = 10
|
||||
Jmax = 50
|
||||
S1 = 0
|
||||
S2 = 0
|
||||
H1 = 1
|
||||
H2 = 2
|
||||
H3 = 3
|
||||
H4 = 4
|
||||
HeaderProtectionKey = odnCO5zIam/+bXlGAOclYIK0o4+FVxGscfwiHQIUVcU=
|
||||
ContentPaddingAddition = 0-32
|
||||
RekeyAfterTime = 120
|
||||
RandomTrailers = true
|
||||
DisableCookies = 1
|
||||
|
||||
[Peer]
|
||||
PublicKey = zUr0LTfErDhhn+GgMPuF7VdeIpQ24pI1kihfwQjfnNg=
|
||||
Endpoint = [2001:db8::10]:51820 # comment
|
||||
PersistentKeepalive = 25-35
|
||||
@ -1,35 +0,0 @@
|
||||
{
|
||||
"servers": [
|
||||
{
|
||||
"name": "awg3",
|
||||
"type": "wireguard",
|
||||
"server": "2001:db8::10",
|
||||
"port": 51820,
|
||||
"ip": "10.8.1.3",
|
||||
"ipv6": "fd00:8:1::3",
|
||||
"private-key": "Se+IZIi2AQD3AZjN7AazYfi+j3yqITfYwkTkOzVj1Wo=",
|
||||
"public-key": "zUr0LTfErDhhn+GgMPuF7VdeIpQ24pI1kihfwQjfnNg=",
|
||||
"mtu": 1280,
|
||||
"persistent-keepalive": 25,
|
||||
"udp": true,
|
||||
"amnezia-wg-option": {
|
||||
"version": 3,
|
||||
"jc": 3,
|
||||
"jmin": 10,
|
||||
"jmax": 50,
|
||||
"s1": 0,
|
||||
"s2": 0,
|
||||
"h1": 1,
|
||||
"h2": 2,
|
||||
"h3": 3,
|
||||
"h4": 4,
|
||||
"header-protection-key": "odnCO5zIam/+bXlGAOclYIK0o4+FVxGscfwiHQIUVcU=",
|
||||
"content-padding-addition": "0-32",
|
||||
"rekey-after-time": 120,
|
||||
"random-trailers": true,
|
||||
"disable-cookies": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"errors": []
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
[Interface]
|
||||
Address = 10.0.0.2/32
|
||||
PrivateKey = 9mpa7dajJsZ00c7XLuNEOM5MYGIlPWQn/WDqg0uGHtc=
|
||||
|
||||
[Peer]
|
||||
PublicKey = 9qAqsbJr88uWikvCYZjXRZZLmRwppEfyxr/s5y9YSP0=
|
||||
@ -1,6 +0,0 @@
|
||||
{
|
||||
"servers": [],
|
||||
"errors": [
|
||||
".conf: нет Endpoint в [Peer]"
|
||||
]
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
{
|
||||
"servers": [
|
||||
{
|
||||
"name": "Амнезия NL",
|
||||
"type": "wireguard",
|
||||
"server": "198.51.100.7",
|
||||
"port": 39125,
|
||||
"ip": "10.8.1.5",
|
||||
"private-key": "sJYaurvRLIjIzrNVHIxvzLMewcvxeregrDLiAh3mjxs=",
|
||||
"public-key": "MkcJxkUHqF5oSmPPP4cKLJHqwk6m7iNQKEGvw9C4rMI=",
|
||||
"pre-shared-key": "CTu0Yl8/YvvhDkqwszsHTZfEuzCKA83sSxtdn3hwggg=",
|
||||
"persistent-keepalive": 25,
|
||||
"udp": true,
|
||||
"amnezia-wg-option": {
|
||||
"jc": 4,
|
||||
"jmin": 10,
|
||||
"jmax": 50,
|
||||
"s1": 98,
|
||||
"s2": 32,
|
||||
"s3": 19,
|
||||
"s4": 7,
|
||||
"h1": "1458367412-1593426716",
|
||||
"h2": "1863071624-1902347825",
|
||||
"h3": "2091548318-2097143921",
|
||||
"h4": "2112573893-2147191025",
|
||||
"i1": "<r 2><b 0x8580>"
|
||||
},
|
||||
"mtu": 1376
|
||||
}
|
||||
],
|
||||
"errors": []
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
vpn://AAAF9XjalVTbbuM2EP0VYp5lRaQk64L1AkGS1rcYbr1bIBsGhiIxttY2pZCSrNjIN7Q_U3Qf2n9w_2hB0nAXXe9DYECewzlzSA5nZg9pwask50xIiO_3_0GIIdlwtsuTTrJdgAXqG--hLEQFMbgRJj5YUImES7U2L0VRFRBDnZVggUZpsZ43TMi84BADAQvWiazmacGf8gXEsKdgbAoxhfsBr5h4SlL2QCm_zDLBpEQ9hB07tLHtX7iEUn49mak1W_8shG3HdmxMKZ-KvEkqNmIvqIfk8C6pRfPrePB5sBOT3_qDttmNb9k2bVom2EJcj_PLpbv53MoepXyYoh7ylLHJud5S20mLeshX9gyjHopCZRHUQ_okM1cxI2V5qIcCSnlf0bDnh2438DDpYD9yPdINcFc5VSQOu64T4C7xOjhyiOsFIfGVU4kRJ8K-F7o47BAnCrDnRkRdra_0CcbED9wwcjsEewGOsKMjB2rPdwKR9-8ekdOGfui8p5RTyu-njAmVy2n9uM5Tk5nbVTpsVx_7zz_5xWwznU69dDQe9p-3q-4myCe_jG5-brbRlSduBz2dVSaXiWCZib76UDt36_DirmmW16vnrdzJ_odPTzf17mp0Gbpy1lYZd5fbxWKhoi_X62LLssFUvaOjn8q5cCwUxxcqqzc8K4ucVzqPoe1jGzuOHcS6uNTmqnZkxXg1YqxM1nnDVCKUi4JFYVnIapJsmC6fbxW0V1UlBSNmUUjXOePVPC8N-1hUmnl0lSJv5iv2oglvqiAlIplomJiX9eNJ40251keWq1Pwm1KtgjdVba7mBl2jdkrffMVYOdcJ1BRi7j1MNfIM2OT8mJojTlqNfYNnWKMoNIho5BKD3OMTGORpZF6hb8LON4UmGKXzjaEJRvx8c2iC2e98gyjCwJzh_02iXImp0HleSgrxPYVTlWq3LlR4eIXXV-v8cGxF8gIW6L94__2AK-rqsah5puW10IMFGXtK6nV19cNhmzGZiryszOQ8_HH4-_DP4c_DX4cv__6OJmPF4BJDDMdBaBaIXtADEaxTd6jFb3oDXr8CPPbK8w
|
||||
@ -1,20 +0,0 @@
|
||||
{
|
||||
"servers": [
|
||||
{
|
||||
"name": "vpn.example.net",
|
||||
"type": "wireguard",
|
||||
"server": "vpn.example.net",
|
||||
"port": 51820,
|
||||
"ip": "10.9.0.2",
|
||||
"private-key": "4Wy1vIZv6qyqd2STfzx/wX6a0hdMWghlV6a2DpbkUlM=",
|
||||
"public-key": "L9Rfyw+PxD7/TW2mkh4C9jAimo8nHK6yRYPkHhZVY6s=",
|
||||
"persistent-keepalive": 25,
|
||||
"udp": true,
|
||||
"mtu": 1420
|
||||
}
|
||||
],
|
||||
"errors": [
|
||||
"vpn://: ключ Amnezia Free / Premium — в нём доступ к их API, а не сервер. Нужен ключ своего сервера (AmneziaWG) или его .conf",
|
||||
"vpn://: не похоже на ключ AmneziaVPN"
|
||||
]
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
vpn://AAABq3jahZBBT8JAEIX_y1ytpWygwiYeDBwwiiGIILimWeiUrm23y3ZbKE3_u7FVSbx4m8m8-fLeq2CXSsOFRJ0BfasuK1DgicSz4NdHoXGfc-2DBZeZVqBSbYBCvzsgDlgQ88x4u1QGYg8UKgZhmpknniADyqBQ0sYTT1SMtkTDwGINgAFtABaDXSxQGk-o5qHr2EPbsUmj_D4pLQovwrIR9FZlt7jfFO6hPPjkeRGcT53jq8ud0J-u9mG8dDkZq230Ek9vG0iGukDtqXz7y3gczoPyeDU7jW86ixVJorA3Gn7ciSQdyMmDW87Xs2gSbpZrN2sZiclbdz3itBlQZyIzX-4iROXxWBRtYtJnUENdv1vgY8Dz2Iz-afenMKB_64L6Eyw7kD4
|
||||
vpn://AAAAO3jaq1ZKLMiMz06tVLJSqlDSUUrOz0vLTI8vSy0qzszPU7Iy0lHKS8xNVbJScszNS63KTFQIKErNzSzNVaoFAFV2FB8
|
||||
vpn://not-a-key
|
||||
@ -1,9 +0,0 @@
|
||||
[Interface]
|
||||
Address = 172.16.0.2/32
|
||||
PrivateKey = SdgDFLQDksOZbdDs+sbQ/z06+65znzFrH5eUCoJUorc=
|
||||
DNS = 1.1.1.1
|
||||
|
||||
[Peer]
|
||||
PublicKey = b4J5nuV2f5PECf2vFOPNazXHGqkcZtMVZrYSUOD5ZgU=
|
||||
AllowedIPs = 0.0.0.0/0
|
||||
Endpoint = wg.example.com:2408
|
||||
@ -1,15 +0,0 @@
|
||||
{
|
||||
"servers": [
|
||||
{
|
||||
"name": "plain-wg",
|
||||
"type": "wireguard",
|
||||
"server": "wg.example.com",
|
||||
"port": 2408,
|
||||
"ip": "172.16.0.2",
|
||||
"private-key": "SdgDFLQDksOZbdDs+sbQ/z06+65znzFrH5eUCoJUorc=",
|
||||
"public-key": "b4J5nuV2f5PECf2vFOPNazXHGqkcZtMVZrYSUOD5ZgU=",
|
||||
"udp": true
|
||||
}
|
||||
],
|
||||
"errors": []
|
||||
}
|
||||
@ -1,324 +0,0 @@
|
||||
proxies:
|
||||
- name: seed
|
||||
type: vless
|
||||
server: 1.2.3.4
|
||||
port: 443
|
||||
uuid: 00000000-0000-0000-0000-000000000000
|
||||
network: tcp
|
||||
udp: true
|
||||
tls: true
|
||||
flow: xtls-rprx-vision
|
||||
servername: eh.vk.ru
|
||||
client-fingerprint: firefox
|
||||
reality-opts:
|
||||
public-key: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
short-id: a1b2
|
||||
|
||||
# own servers of the settings (LuCI "Свои серверы", /etc/nikki/my-servers): one JSON
|
||||
# proxy per line, as mihomo's own config would have it; the kit puts dialer-proxy in
|
||||
# front: whitelist and the phone through MY-EXIT, else with UPLINK (CSQTT, pools) through it.
|
||||
# A server with an entry of its own (LuCI "Вход") keeps it in every profile
|
||||
- {"dialer-proxy": "MY-EXIT", "name":"🇩🇪 de 1","type":"vless","server":"x.example.com","port":"443","uuid":"00000000-0000-0000-0000-000000000001","udp":true,"tls":true,"client-fingerprint":"chrome","servername":"www.example.com","reality-opts":{"public-key":"Nc9ZSDuQMwHN4M6TeDHjfJhgZ6SBTBbfMwx5iHQZ1ns","short-id":"ab"},"xudp":true,"network":"xhttp","xhttp-opts":{"path":"/x"}}
|
||||
- {"dialer-proxy": "MY-EXIT", "name":"tr \"q\"","type":"trojan","server":"t.example.org","port":"443","password":"p\u0024w","udp":true,"skip-cert-verify":false,"sni":"t.example.org","network":"grpc","grpc-opts":{"grpc-service-name":"g"},"client-fingerprint":"chrome"}
|
||||
- {"dialer-proxy": "MY-EXIT", "name":"hy-own","type":"hysteria2","server":"h.example.net","port":8443,"password":"a\u0024b","obfs":"salamander","obfs-password":"o","up":"50 mbps"}
|
||||
- {"dialer-proxy": "MY-EXIT", "name":"awg-own","type":"wireguard","server":"203.0.113.10","port":47613,"ip":"10.8.1.2","private-key":"fTo2df+b5vCuulh7pOXMWiWJY2VwSe2Kuup2nA34tfI=","public-key":"vGYpG72gCXPNfYzr/0iNfSoL83vbrVSGUC+v+MKRVyE=","pre-shared-key":"6ut/J6EuaJ97RMFcZuiJkzIo7a5uxR98htK5NdWJW6E=","persistent-keepalive":25,"udp":true,"amnezia-wg-option":{"jc":4,"jmin":10,"jmax":50,"s1":98,"s2":32,"s3":19,"s4":7,"h1":"1458367412-1593426716","h2":"1863071624-1902347825","h3":"2091548318-2097143921","h4":"2112573893-2147191025","i1":"<r 2><b 0x858000010001000000000669636c6f756403636f6d0000010001c00c000100010000105a00044d583737>"}}
|
||||
- {"dialer-proxy": "MY-EXIT", "name":"m1","type":"hysteria2","server":"m.example.com","port":443,"password":"p","udp":true}
|
||||
- {"name":"via-foreign","type":"ss","server":"f.example.com","port":8388,"cipher":"aes-256-gcm","password":"x","dialer-proxy":"FOREIGN"}
|
||||
|
||||
# copies of own servers for the chains (SVC_<NAME>_CHAIN, POOL_<NAME>_UPLINK): the same
|
||||
# server dialing through another entry, named "<server> ⟶ <entry>" (group "<pool> ⟶ <entry>")
|
||||
- {"dialer-proxy": "FOREIGN", "name":"m1 ⟶ FOREIGN","type":"hysteria2","server":"m.example.com","port":443,"password":"p","udp":true}
|
||||
|
||||
proxy-providers:
|
||||
example:
|
||||
type: http
|
||||
url: "https://sub.example.com/sub/aaa"
|
||||
path: ./providers/example.yaml
|
||||
interval: 3600
|
||||
proxy: BOOT-AUTO
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
example2:
|
||||
type: http
|
||||
url: "https://sub2.example.com/x?a=1&b=2"
|
||||
path: ./providers/example2.yaml
|
||||
interval: 3600
|
||||
proxy: BOOT-AUTO
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
example-my:
|
||||
type: http
|
||||
url: "https://sub.example.com/sub/aaa"
|
||||
path: ./providers/example-my.yaml
|
||||
interval: 3600
|
||||
proxy: BOOT-AUTO
|
||||
filter: "(?i)\\[MY\\]"
|
||||
override:
|
||||
dialer-proxy: MY-EXIT
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
example2-my:
|
||||
type: http
|
||||
url: "https://sub2.example.com/x?a=1&b=2"
|
||||
path: ./providers/example2-my.yaml
|
||||
interval: 3600
|
||||
proxy: BOOT-AUTO
|
||||
filter: "(?i)\\[MY\\]"
|
||||
override:
|
||||
dialer-proxy: MY-EXIT
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# example2-my for the chains through FOREIGN: the same nodes, named "... ⟶ FOREIGN"
|
||||
example2-my@FOREIGN:
|
||||
type: http
|
||||
url: "https://sub2.example.com/x?a=1&b=2"
|
||||
path: ./providers/example2-my@FOREIGN.yaml
|
||||
interval: 3600
|
||||
proxy: BOOT-AUTO
|
||||
filter: "(?i)\\[MY\\]"
|
||||
override:
|
||||
additional-suffix: " ⟶ FOREIGN"
|
||||
dialer-proxy: FOREIGN
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
rule-providers:
|
||||
# Russian services (geosite ru-inside of russia-only, as .mrs): an ordinary
|
||||
# http rule-set, so every client fetches it with the config, no geodata setup
|
||||
ru-inside:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/ru-inside.mrs"
|
||||
path: ./ruleset/ru-inside.mrs
|
||||
interval: 86400
|
||||
# Russian services outside ru-inside and outside .ru/.su/.рф (russia-only ru-services):
|
||||
# not on the whitelist, so through RU everywhere but main
|
||||
ru-services:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/ru-services.mrs"
|
||||
path: ./ruleset/ru-services.mrs
|
||||
interval: 86400
|
||||
|
||||
# services (SERVICES): geosite list anthropic of MetaCubeX/meta-rules-dat
|
||||
geosite-anthropic:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@meta/geo/geosite/anthropic.mrs"
|
||||
path: ./ruleset/geosite-anthropic.mrs
|
||||
interval: 86400
|
||||
|
||||
sniffer:
|
||||
enable: true
|
||||
force-dns-mapping: true
|
||||
parse-pure-ip: true
|
||||
override-destination: false
|
||||
# ECH: browsers show the outer name cloudflare-ech.com instead of the site behind
|
||||
# Cloudflare; the sniffed name wins in the rules, so .ru / own lists would miss the
|
||||
# site. Skipped: the rules see the name from mihomo's DNS (fake-ip / DNS mapping).
|
||||
skip-domain:
|
||||
- "+.cloudflare-ech.com"
|
||||
sniff:
|
||||
HTTP:
|
||||
ports: [80, 8080-8880]
|
||||
TLS:
|
||||
ports: [443, 8443]
|
||||
# lite: no QUIC (fake-ip already gives the domain; pure-IP QUIC goes by IP)
|
||||
QUIC:
|
||||
ports: [443, 8443]
|
||||
|
||||
dns:
|
||||
enable: true
|
||||
ipv6: false
|
||||
respect-rules: true
|
||||
enhanced-mode: fake-ip
|
||||
fake-ip-range: 198.18.0.1/16
|
||||
fake-ip-filter:
|
||||
- '*.lan'
|
||||
- '+.ru'
|
||||
|
||||
default-nameserver:
|
||||
- 77.88.8.8
|
||||
- 223.5.5.5
|
||||
|
||||
proxy-server-nameserver:
|
||||
- https://77.88.8.8/dns-query
|
||||
|
||||
direct-nameserver:
|
||||
- 77.88.8.8
|
||||
- 77.88.8.1
|
||||
|
||||
nameserver:
|
||||
- https://dns.google/dns-query
|
||||
- https://1.1.1.1/dns-query
|
||||
|
||||
proxy-groups:
|
||||
# BOOT: whitelisted entry nodes (BOOT_LINKS), the first alive one
|
||||
- name: BOOT
|
||||
type: fallback
|
||||
proxies: [seed]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
# default for downloading subscriptions: BOOT (if set), else the nodes of the
|
||||
# saved subscriptions (providers are cached on disk), else direct. FOREIGN goes
|
||||
# before DIRECT: the health check of DIRECT (gstatic) passes in Russia even when
|
||||
# the subscription site itself is blocked.
|
||||
- name: BOOT-AUTO
|
||||
type: fallback
|
||||
proxies: [BOOT, FOREIGN, DIRECT]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
- name: RU
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
# lite: the provider's URL, so RU nodes are not tested a second time
|
||||
url: "https://ya.ru"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
- name: FOREIGN
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
exclude-filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
# pool one (POOLS, POOL_*): own servers and subscription nodes picked in the settings;
|
||||
# filter / exclude-filter apply to the subscriptions' nodes only
|
||||
- name: ONE
|
||||
type: fallback
|
||||
proxies: ["m1"]
|
||||
use: [example2-my]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
# own servers: those of the settings (proxies/30-own_srv) and the "[MY] ..." nodes of
|
||||
# the subscriptions (providers <id>-my); the fastest alive one; pin one in the dashboard if needed
|
||||
- name: MY
|
||||
type: url-test
|
||||
proxies: ["🇩🇪 de 1", "tr \"q\"", "hy-own", "awg-own", "via-foreign", "m1"]
|
||||
use: [example-my, example2-my]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
# whitelist and mobile (my_exit): what own servers are reached through; switches only when the node is
|
||||
# clearly worse or dead (each switch breaks everything going through MY)
|
||||
- name: MY-EXIT
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
exclude-filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 300
|
||||
lazy: false
|
||||
|
||||
# service claude (SERVICES, SVC_*): its own way, whatever MAIN is
|
||||
- name: CLAUDE
|
||||
type: select
|
||||
proxies: ["ONE ⟶ FOREIGN", ONE, MY, FOREIGN, RU, DIRECT]
|
||||
|
||||
# ONE through FOREIGN (SVC_<NAME>_CHAIN, POOL_<NAME>_UPLINK): its servers and
|
||||
# nodes, each dialing through FOREIGN
|
||||
- name: "ONE ⟶ FOREIGN"
|
||||
type: fallback
|
||||
proxies: ["m1 ⟶ FOREIGN"]
|
||||
use: [example2-my@FOREIGN]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
- name: MAIN
|
||||
type: select
|
||||
proxies: [FOREIGN, MY, RU, DIRECT]
|
||||
|
||||
rules:
|
||||
- IP-CIDR,192.168.0.0/16,DIRECT,no-resolve
|
||||
- IP-CIDR,10.0.0.0/8,DIRECT,no-resolve
|
||||
- IP-CIDR,172.16.0.0/12,DIRECT,no-resolve
|
||||
|
||||
# service claude: above the own lists, below the tunnels, LAN and push
|
||||
- RULE-SET,geosite-anthropic,CLAUDE
|
||||
|
||||
# own lists from the settings: above torrents, ru-inside, .ru and MATCH; below the
|
||||
# tunnels, LAN and push. Domains (DOMAIN-SUFFIX: the domain and all subdomains)
|
||||
# before IPs; first match wins: MY, then FOREIGN, then RU.
|
||||
# RU on main (home, own white IP): reachable directly; whitelist/abroad: through RU
|
||||
- IP-CIDR,194.190.191.112/32,RU
|
||||
|
||||
- RULE-SET,ru-inside,DIRECT
|
||||
# main (home, own white IP): ru-services and .ru/.su/.рф directly; elsewhere through RU
|
||||
- RULE-SET,ru-services,RU
|
||||
- DOMAIN-SUFFIX,ru,RU
|
||||
- DOMAIN-SUFFIX,su,RU
|
||||
- DOMAIN-SUFFIX,xn--p1ai,RU
|
||||
- MATCH,MAIN
|
||||
@ -1,292 +0,0 @@
|
||||
proxies:
|
||||
- name: seed
|
||||
type: vless
|
||||
server: 1.2.3.4
|
||||
port: 443
|
||||
uuid: 11111111-1111-1111-1111-111111111111
|
||||
network: tcp
|
||||
udp: true
|
||||
tls: true
|
||||
flow: xtls-rprx-vision
|
||||
servername: eh.vk.ru
|
||||
client-fingerprint: firefox
|
||||
reality-opts:
|
||||
public-key: Nc9ZSDuQMwHN4M6TeDHjfJhgZ6SBTBbfMwx5iHQZ1ns
|
||||
short-id: a1
|
||||
|
||||
- name: seed2
|
||||
type: vless
|
||||
server: seed2.example.com
|
||||
port: 8443
|
||||
uuid: 22222222-2222-2222-2222-222222222222
|
||||
network: tcp
|
||||
udp: true
|
||||
tls: true
|
||||
flow: xtls-rprx-vision
|
||||
servername: ya.ru
|
||||
client-fingerprint: firefox
|
||||
reality-opts:
|
||||
public-key: ppQ9FwLrLIa0AOrp1WvcyiaQ37vg2WSy_CD4bIdiTUw
|
||||
short-id: b2
|
||||
|
||||
proxy-providers:
|
||||
example:
|
||||
type: http
|
||||
url: "https://sub.example.com/sub/aaa"
|
||||
path: ./providers/example.yaml
|
||||
interval: 3600
|
||||
proxy: BOOT
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
example2:
|
||||
type: http
|
||||
url: "https://sub2.example.com/x?a=1&b=2"
|
||||
path: ./providers/example2.yaml
|
||||
interval: 3600
|
||||
proxy: BOOT-AUTO
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
example-my:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
override:
|
||||
dialer-proxy: MY-EXIT
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
example2-my:
|
||||
type: file
|
||||
path: ./providers/example2.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
override:
|
||||
dialer-proxy: MY-EXIT
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
rule-providers:
|
||||
# Russian services (geosite ru-inside of russia-only, as .mrs): an ordinary
|
||||
# http rule-set, so every client fetches it with the config, no geodata setup
|
||||
ru-inside:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/ru-inside.mrs"
|
||||
path: ./ruleset/ru-inside.mrs
|
||||
interval: 86400
|
||||
# Russian services outside ru-inside and outside .ru/.su/.рф (russia-only ru-services):
|
||||
# not on the whitelist, so through RU everywhere but main
|
||||
ru-services:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/ru-services.mrs"
|
||||
path: ./ruleset/ru-services.mrs
|
||||
interval: 86400
|
||||
|
||||
sniffer:
|
||||
enable: true
|
||||
force-dns-mapping: true
|
||||
parse-pure-ip: true
|
||||
override-destination: false
|
||||
# ECH: browsers show the outer name cloudflare-ech.com instead of the site behind
|
||||
# Cloudflare; the sniffed name wins in the rules, so .ru / own lists would miss the
|
||||
# site. Skipped: the rules see the name from mihomo's DNS (fake-ip / DNS mapping).
|
||||
skip-domain:
|
||||
- "+.cloudflare-ech.com"
|
||||
sniff:
|
||||
HTTP:
|
||||
ports: [80, 8080-8880]
|
||||
TLS:
|
||||
ports: [443, 8443]
|
||||
# lite: no QUIC (fake-ip already gives the domain; pure-IP QUIC goes by IP)
|
||||
QUIC:
|
||||
ports: [443, 8443]
|
||||
|
||||
dns:
|
||||
enable: true
|
||||
ipv6: false
|
||||
respect-rules: true
|
||||
enhanced-mode: fake-ip
|
||||
fake-ip-range: 198.18.0.1/16
|
||||
fake-ip-filter:
|
||||
- '*.lan'
|
||||
- '*.local'
|
||||
- '+.ru'
|
||||
- '+.xn--p1ai'
|
||||
- rule-set:ru-inside
|
||||
|
||||
default-nameserver:
|
||||
- 77.88.8.8
|
||||
- 1.1.1.1
|
||||
|
||||
proxy-server-nameserver:
|
||||
- https://77.88.8.8/dns-query
|
||||
|
||||
direct-nameserver:
|
||||
- 77.88.8.8
|
||||
- 77.88.8.1
|
||||
|
||||
nameserver:
|
||||
- https://1.1.1.1/dns-query
|
||||
- https://dns.google/dns-query
|
||||
|
||||
proxy-groups:
|
||||
# BOOT: whitelisted entry nodes (BOOT_LINKS), the first alive one
|
||||
- name: BOOT
|
||||
type: fallback
|
||||
proxies: [seed, seed2]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
# default for downloading subscriptions: BOOT (if set), else the nodes of the
|
||||
# saved subscriptions (providers are cached on disk), else direct. FOREIGN goes
|
||||
# before DIRECT: the health check of DIRECT (gstatic) passes in Russia even when
|
||||
# the subscription site itself is blocked.
|
||||
- name: BOOT-AUTO
|
||||
type: fallback
|
||||
proxies: [BOOT, FOREIGN, DIRECT]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
- name: RU
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
# lite: the provider's URL, so RU nodes are not tested a second time
|
||||
url: "https://ya.ru"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
- name: FOREIGN
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
exclude-filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
- name: TORRENT
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
filter: "(?i)torrent|\\[tor\\]"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 6000
|
||||
tolerance: 500
|
||||
max-failed-times: 5
|
||||
lazy: false
|
||||
|
||||
# own servers: those of the settings (proxies/30-own_srv) and the "[MY] ..." nodes of
|
||||
# the subscriptions (providers <id>-my); the fastest alive one; pin one in the dashboard if needed
|
||||
- name: MY
|
||||
type: url-test
|
||||
use: [example-my, example2-my]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
# whitelist and mobile (my_exit): what own servers are reached through; switches only when the node is
|
||||
# clearly worse or dead (each switch breaks everything going through MY)
|
||||
- name: MY-EXIT
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
exclude-filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 300
|
||||
lazy: false
|
||||
|
||||
- name: MAIN
|
||||
type: select
|
||||
proxies: [FOREIGN, MY, RU, DIRECT]
|
||||
|
||||
- name: TORRENT-SEL
|
||||
type: select
|
||||
proxies: [TORRENT, FOREIGN, DIRECT]
|
||||
|
||||
- name: PUSH
|
||||
type: select
|
||||
# no own servers in the settings: MY may be empty (no [MY] nodes in the subscriptions)
|
||||
proxies: [FOREIGN, MY, DIRECT]
|
||||
|
||||
rules:
|
||||
- IP-CIDR,192.168.0.0/16,DIRECT,no-resolve
|
||||
- IP-CIDR,10.0.0.0/8,DIRECT,no-resolve
|
||||
- IP-CIDR,172.16.0.0/12,DIRECT,no-resolve
|
||||
|
||||
# push notifications (Apple APNs, Google FCM): long-lived connections on a
|
||||
# stable path - group PUSH (main/foreign: DIRECT, whitelist: MY)
|
||||
- DOMAIN-SUFFIX,push.apple.com,PUSH
|
||||
- IP-CIDR,17.249.0.0/16,PUSH,no-resolve
|
||||
- IP-CIDR,17.252.0.0/16,PUSH,no-resolve
|
||||
- IP-CIDR,17.57.144.0/22,PUSH,no-resolve
|
||||
- IP-CIDR,17.188.128.0/18,PUSH,no-resolve
|
||||
- IP-CIDR,17.188.20.0/23,PUSH,no-resolve
|
||||
- DOMAIN-REGEX,^(alt[0-9]+-)?mtalk[0-9]*\.google\.com$,PUSH
|
||||
- DST-PORT,5228-5230,PUSH
|
||||
|
||||
# own lists from the settings: above torrents, ru-inside, .ru and MATCH; below the
|
||||
# tunnels, LAN and push. Domains (DOMAIN-SUFFIX: the domain and all subdomains)
|
||||
# before IPs; first match wins: MY, then FOREIGN, then RU.
|
||||
# RU on main (home, own white IP): reachable directly; whitelist/abroad: through RU
|
||||
- IP-CIDR,194.190.191.112/32,RU
|
||||
|
||||
- SRC-PORT,20000-20199,TORRENT-SEL
|
||||
|
||||
- RULE-SET,ru-inside,DIRECT
|
||||
# main (home, own white IP): ru-services and .ru/.su/.рф directly; elsewhere through RU
|
||||
- RULE-SET,ru-services,RU
|
||||
- DOMAIN-SUFFIX,ru,RU
|
||||
- DOMAIN-SUFFIX,su,RU
|
||||
- DOMAIN-SUFFIX,xn--p1ai,RU
|
||||
- MATCH,MAIN
|
||||
@ -1,303 +0,0 @@
|
||||
proxies:
|
||||
- name: seed
|
||||
type: vless
|
||||
server: 1.2.3.4
|
||||
port: 443
|
||||
uuid: 00000000-0000-0000-0000-000000000000
|
||||
network: tcp
|
||||
udp: true
|
||||
tls: true
|
||||
flow: xtls-rprx-vision
|
||||
servername: eh.vk.ru
|
||||
client-fingerprint: firefox
|
||||
reality-opts:
|
||||
public-key: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
short-id: a1b2
|
||||
dialer-proxy: UPLINK
|
||||
|
||||
# own servers of the settings (LuCI "Свои серверы", /etc/nikki/my-servers): one JSON
|
||||
# proxy per line, as mihomo's own config would have it; the kit puts dialer-proxy in
|
||||
# front: whitelist and the phone through MY-EXIT, else with UPLINK (CSQTT, pools) through it.
|
||||
# A server with an entry of its own (LuCI "Вход") keeps it in every profile
|
||||
- {"dialer-proxy": "UPLINK", "name":"🇩🇪 de 1","type":"vless","server":"x.example.com","port":"443","uuid":"00000000-0000-0000-0000-000000000001","udp":true,"tls":true,"client-fingerprint":"chrome","servername":"www.example.com","reality-opts":{"public-key":"Nc9ZSDuQMwHN4M6TeDHjfJhgZ6SBTBbfMwx5iHQZ1ns","short-id":"ab"},"xudp":true,"network":"xhttp","xhttp-opts":{"path":"/x"}}
|
||||
- {"dialer-proxy": "UPLINK", "name":"tr \"q\"","type":"trojan","server":"t.example.org","port":"443","password":"p\u0024w","udp":true,"skip-cert-verify":false,"sni":"t.example.org","network":"grpc","grpc-opts":{"grpc-service-name":"g"},"client-fingerprint":"chrome"}
|
||||
- {"dialer-proxy": "UPLINK", "name":"hy-own","type":"hysteria2","server":"h.example.net","port":8443,"password":"a\u0024b","obfs":"salamander","obfs-password":"o","up":"50 mbps"}
|
||||
- {"dialer-proxy": "UPLINK", "name":"awg-own","type":"wireguard","server":"203.0.113.10","port":47613,"ip":"10.8.1.2","private-key":"fTo2df+b5vCuulh7pOXMWiWJY2VwSe2Kuup2nA34tfI=","public-key":"vGYpG72gCXPNfYzr/0iNfSoL83vbrVSGUC+v+MKRVyE=","pre-shared-key":"6ut/J6EuaJ97RMFcZuiJkzIo7a5uxR98htK5NdWJW6E=","persistent-keepalive":25,"udp":true,"amnezia-wg-option":{"jc":4,"jmin":10,"jmax":50,"s1":98,"s2":32,"s3":19,"s4":7,"h1":"1458367412-1593426716","h2":"1863071624-1902347825","h3":"2091548318-2097143921","h4":"2112573893-2147191025","i1":"<r 2><b 0x858000010001000000000669636c6f756403636f6d0000010001c00c000100010000105a00044d583737>"}}
|
||||
- {"dialer-proxy": "UPLINK", "name":"nl-1","type":"hysteria2","server":"vpn.example.com","port":443,"password":"p","udp":true}
|
||||
- {"name":"via-foreign","type":"ss","server":"f.example.com","port":8388,"cipher":"aes-256-gcm","password":"x","dialer-proxy":"FOREIGN"}
|
||||
|
||||
# CSQTT (star-panel-csqtt): tunnel interface csqtt0 on the router, mihomo
|
||||
# just sends the connection out of it (the interface does not change routes)
|
||||
- name: CSQTT
|
||||
type: direct
|
||||
interface-name: csqtt0
|
||||
udp: true
|
||||
|
||||
proxy-providers:
|
||||
example:
|
||||
type: http
|
||||
url: "https://sub.example.com/sub/aaa"
|
||||
path: ./providers/example.yaml
|
||||
interval: 3600
|
||||
proxy: BOOT-AUTO
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
override:
|
||||
dialer-proxy: UPLINK
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
example2:
|
||||
type: http
|
||||
url: "https://sub2.example.com/x?a=1&b=2"
|
||||
path: ./providers/example2.yaml
|
||||
interval: 3600
|
||||
proxy: BOOT-AUTO
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
override:
|
||||
dialer-proxy: UPLINK
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
example-my:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
override:
|
||||
dialer-proxy: UPLINK
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
example2-my:
|
||||
type: file
|
||||
path: ./providers/example2.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
override:
|
||||
dialer-proxy: UPLINK
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
rule-providers:
|
||||
# Russian services (geosite ru-inside of russia-only, as .mrs): an ordinary
|
||||
# http rule-set, so every client fetches it with the config, no geodata setup
|
||||
ru-inside:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/ru-inside.mrs"
|
||||
path: ./ruleset/ru-inside.mrs
|
||||
interval: 86400
|
||||
# Russian services outside ru-inside and outside .ru/.su/.рф (russia-only ru-services):
|
||||
# not on the whitelist, so through RU everywhere but main
|
||||
ru-services:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/ru-services.mrs"
|
||||
path: ./ruleset/ru-services.mrs
|
||||
interval: 86400
|
||||
|
||||
sniffer:
|
||||
enable: true
|
||||
force-dns-mapping: true
|
||||
parse-pure-ip: true
|
||||
override-destination: false
|
||||
# ECH: browsers show the outer name cloudflare-ech.com instead of the site behind
|
||||
# Cloudflare; the sniffed name wins in the rules, so .ru / own lists would miss the
|
||||
# site. Skipped: the rules see the name from mihomo's DNS (fake-ip / DNS mapping).
|
||||
skip-domain:
|
||||
- "+.cloudflare-ech.com"
|
||||
sniff:
|
||||
HTTP:
|
||||
ports: [80, 8080-8880]
|
||||
TLS:
|
||||
ports: [443, 8443]
|
||||
# lite: no QUIC (fake-ip already gives the domain; pure-IP QUIC goes by IP)
|
||||
QUIC:
|
||||
ports: [443, 8443]
|
||||
|
||||
dns:
|
||||
enable: true
|
||||
ipv6: false
|
||||
respect-rules: true
|
||||
enhanced-mode: fake-ip
|
||||
fake-ip-range: 198.18.0.1/16
|
||||
fake-ip-filter:
|
||||
- '*.lan'
|
||||
- '*.local'
|
||||
|
||||
default-nameserver:
|
||||
- 77.88.8.8
|
||||
- 1.1.1.1
|
||||
|
||||
proxy-server-nameserver:
|
||||
- https://77.88.8.8/dns-query
|
||||
|
||||
direct-nameserver:
|
||||
- 1.1.1.1
|
||||
- 8.8.8.8
|
||||
|
||||
nameserver:
|
||||
- https://1.1.1.1/dns-query
|
||||
- https://dns.google/dns-query
|
||||
|
||||
proxy-groups:
|
||||
# BOOT: whitelisted entry nodes (BOOT_LINKS), the first alive one
|
||||
- name: BOOT
|
||||
type: fallback
|
||||
proxies: [seed]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
# default for downloading subscriptions: BOOT (if set), else the nodes of the
|
||||
# saved subscriptions (providers are cached on disk), else direct. FOREIGN goes
|
||||
# before DIRECT: the health check of DIRECT (gstatic) passes in Russia even when
|
||||
# the subscription site itself is blocked.
|
||||
- name: BOOT-AUTO
|
||||
type: fallback
|
||||
proxies: [BOOT, FOREIGN, DIRECT]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
- name: RU
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
# lite: the provider's URL, so RU nodes are not tested a second time
|
||||
url: "https://ya.ru"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
- name: FOREIGN
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
exclude-filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
- name: TORRENT
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
filter: "(?i)torrent|\\[tor\\]"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 6000
|
||||
tolerance: 500
|
||||
max-failed-times: 5
|
||||
lazy: false
|
||||
|
||||
# own servers: those of the settings (proxies/30-own_srv) and the "[MY] ..." nodes of
|
||||
# the subscriptions (providers <id>-my); the fastest alive one; pin one in the dashboard if needed
|
||||
- name: MY
|
||||
type: url-test
|
||||
proxies: ["🇩🇪 de 1", "tr \"q\"", "hy-own", "awg-own", "via-foreign", "nl-1"]
|
||||
use: [example-my, example2-my]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
# whitelist and mobile (my_exit): what own servers are reached through; switches only when the node is
|
||||
# clearly worse or dead (each switch breaks everything going through MY)
|
||||
|
||||
# UPLINK: what the subscription nodes, BOOT seeds and own servers connect
|
||||
# through. DIRECT - as before; CSQTT - through csqtt0 first (out of the
|
||||
# whitelist); a pool (POOL_<NAME>_UPLINK=1) - through its servers, they themselves
|
||||
# direct; then FOREIGN / MY / RU work on top of it as usual.
|
||||
# On whitelist own servers go MY-EXIT -> node -> UPLINK.
|
||||
- name: UPLINK
|
||||
type: select
|
||||
proxies: [DIRECT, CSQTT]
|
||||
|
||||
- name: MAIN
|
||||
type: select
|
||||
# abroad: direct by default, own servers / pools by hand
|
||||
proxies: [DIRECT, MY, FOREIGN, RU, CSQTT]
|
||||
|
||||
- name: TORRENT-SEL
|
||||
type: select
|
||||
proxies: [TORRENT, FOREIGN, DIRECT]
|
||||
|
||||
- name: PUSH
|
||||
type: select
|
||||
proxies: [DIRECT, MY, FOREIGN]
|
||||
|
||||
rules:
|
||||
# the CSQTT client's own connections (peer, VK TURN) must not go into its tunnel
|
||||
- PROCESS-NAME,csqtt,DIRECT
|
||||
|
||||
- IP-CIDR,192.168.0.0/16,DIRECT,no-resolve
|
||||
- IP-CIDR,10.0.0.0/8,DIRECT,no-resolve
|
||||
- IP-CIDR,172.16.0.0/12,DIRECT,no-resolve
|
||||
|
||||
# push notifications (Apple APNs, Google FCM): long-lived connections on a
|
||||
# stable path - group PUSH (main/foreign: DIRECT, whitelist: MY)
|
||||
- DOMAIN-SUFFIX,push.apple.com,PUSH
|
||||
- IP-CIDR,17.249.0.0/16,PUSH,no-resolve
|
||||
- IP-CIDR,17.252.0.0/16,PUSH,no-resolve
|
||||
- IP-CIDR,17.57.144.0/22,PUSH,no-resolve
|
||||
- IP-CIDR,17.188.128.0/18,PUSH,no-resolve
|
||||
- IP-CIDR,17.188.20.0/23,PUSH,no-resolve
|
||||
- DOMAIN-REGEX,^(alt[0-9]+-)?mtalk[0-9]*\.google\.com$,PUSH
|
||||
- DST-PORT,5228-5230,PUSH
|
||||
|
||||
# own lists from the settings: above torrents, ru-inside, .ru and MATCH; below the
|
||||
# tunnels, LAN and push. Domains (DOMAIN-SUFFIX: the domain and all subdomains)
|
||||
# before IPs; first match wins: MY, then FOREIGN, then RU.
|
||||
# RU on main (home, own white IP): reachable directly; whitelist/abroad: through RU
|
||||
- IP-CIDR,194.190.191.112/32,RU
|
||||
|
||||
- SRC-PORT,20000-20199,TORRENT-SEL
|
||||
|
||||
# abroad: Russian services through the RU pool too
|
||||
- RULE-SET,ru-inside,RU
|
||||
# main (home, own white IP): ru-services and .ru/.su/.рф directly; elsewhere through RU
|
||||
- RULE-SET,ru-services,RU
|
||||
- DOMAIN-SUFFIX,ru,RU
|
||||
- DOMAIN-SUFFIX,su,RU
|
||||
- DOMAIN-SUFFIX,xn--p1ai,RU
|
||||
- MATCH,MAIN
|
||||
@ -1,311 +0,0 @@
|
||||
proxies:
|
||||
- name: seed
|
||||
type: vless
|
||||
server: 1.2.3.4
|
||||
port: 443
|
||||
uuid: 00000000-0000-0000-0000-000000000000
|
||||
network: tcp
|
||||
udp: true
|
||||
tls: true
|
||||
flow: xtls-rprx-vision
|
||||
servername: eh.vk.ru
|
||||
client-fingerprint: firefox
|
||||
reality-opts:
|
||||
public-key: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
short-id: a1b2
|
||||
dialer-proxy: UPLINK
|
||||
|
||||
# own servers of the settings (LuCI "Свои серверы", /etc/nikki/my-servers): one JSON
|
||||
# proxy per line, as mihomo's own config would have it; the kit puts dialer-proxy in
|
||||
# front: whitelist and the phone through MY-EXIT, else with UPLINK (CSQTT, pools) through it.
|
||||
# A server with an entry of its own (LuCI "Вход") keeps it in every profile
|
||||
- {"dialer-proxy": "MY-EXIT", "name":"🇩🇪 de 1","type":"vless","server":"x.example.com","port":"443","uuid":"00000000-0000-0000-0000-000000000001","udp":true,"tls":true,"client-fingerprint":"chrome","servername":"www.example.com","reality-opts":{"public-key":"Nc9ZSDuQMwHN4M6TeDHjfJhgZ6SBTBbfMwx5iHQZ1ns","short-id":"ab"},"xudp":true,"network":"xhttp","xhttp-opts":{"path":"/x"}}
|
||||
- {"dialer-proxy": "MY-EXIT", "name":"tr \"q\"","type":"trojan","server":"t.example.org","port":"443","password":"p\u0024w","udp":true,"skip-cert-verify":false,"sni":"t.example.org","network":"grpc","grpc-opts":{"grpc-service-name":"g"},"client-fingerprint":"chrome"}
|
||||
- {"dialer-proxy": "MY-EXIT", "name":"hy-own","type":"hysteria2","server":"h.example.net","port":8443,"password":"a\u0024b","obfs":"salamander","obfs-password":"o","up":"50 mbps"}
|
||||
- {"dialer-proxy": "MY-EXIT", "name":"awg-own","type":"wireguard","server":"203.0.113.10","port":47613,"ip":"10.8.1.2","private-key":"fTo2df+b5vCuulh7pOXMWiWJY2VwSe2Kuup2nA34tfI=","public-key":"vGYpG72gCXPNfYzr/0iNfSoL83vbrVSGUC+v+MKRVyE=","pre-shared-key":"6ut/J6EuaJ97RMFcZuiJkzIo7a5uxR98htK5NdWJW6E=","persistent-keepalive":25,"udp":true,"amnezia-wg-option":{"jc":4,"jmin":10,"jmax":50,"s1":98,"s2":32,"s3":19,"s4":7,"h1":"1458367412-1593426716","h2":"1863071624-1902347825","h3":"2091548318-2097143921","h4":"2112573893-2147191025","i1":"<r 2><b 0x858000010001000000000669636c6f756403636f6d0000010001c00c000100010000105a00044d583737>"}}
|
||||
- {"name":"via-foreign","type":"ss","server":"f.example.com","port":8388,"cipher":"aes-256-gcm","password":"x","dialer-proxy":"FOREIGN"}
|
||||
|
||||
# CSQTT (star-panel-csqtt): tunnel interface csqtt0 on the router, mihomo
|
||||
# just sends the connection out of it (the interface does not change routes)
|
||||
- name: CSQTT
|
||||
type: direct
|
||||
interface-name: csqtt0
|
||||
udp: true
|
||||
|
||||
proxy-providers:
|
||||
example:
|
||||
type: http
|
||||
url: "https://sub.example.com/sub/aaa"
|
||||
path: ./providers/example.yaml
|
||||
interval: 3600
|
||||
proxy: BOOT-AUTO
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
override:
|
||||
dialer-proxy: UPLINK
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
example2:
|
||||
type: http
|
||||
url: "https://sub2.example.com/x?a=1&b=2"
|
||||
path: ./providers/example2.yaml
|
||||
interval: 3600
|
||||
proxy: BOOT-AUTO
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
override:
|
||||
dialer-proxy: UPLINK
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
example-my:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
override:
|
||||
dialer-proxy: MY-EXIT
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
example2-my:
|
||||
type: file
|
||||
path: ./providers/example2.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
override:
|
||||
dialer-proxy: MY-EXIT
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
rule-providers:
|
||||
# Russian services (geosite ru-inside of russia-only, as .mrs): an ordinary
|
||||
# http rule-set, so every client fetches it with the config, no geodata setup
|
||||
ru-inside:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/ru-inside.mrs"
|
||||
path: ./ruleset/ru-inside.mrs
|
||||
interval: 86400
|
||||
# Russian services outside ru-inside and outside .ru/.su/.рф (russia-only ru-services):
|
||||
# not on the whitelist, so through RU everywhere but main
|
||||
ru-services:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/ru-services.mrs"
|
||||
path: ./ruleset/ru-services.mrs
|
||||
interval: 86400
|
||||
|
||||
sniffer:
|
||||
enable: true
|
||||
force-dns-mapping: true
|
||||
parse-pure-ip: true
|
||||
override-destination: false
|
||||
# ECH: browsers show the outer name cloudflare-ech.com instead of the site behind
|
||||
# Cloudflare; the sniffed name wins in the rules, so .ru / own lists would miss the
|
||||
# site. Skipped: the rules see the name from mihomo's DNS (fake-ip / DNS mapping).
|
||||
skip-domain:
|
||||
- "+.cloudflare-ech.com"
|
||||
sniff:
|
||||
HTTP:
|
||||
ports: [80, 8080-8880]
|
||||
TLS:
|
||||
ports: [443, 8443]
|
||||
# lite: no QUIC (fake-ip already gives the domain; pure-IP QUIC goes by IP)
|
||||
QUIC:
|
||||
ports: [443, 8443]
|
||||
|
||||
dns:
|
||||
enable: true
|
||||
ipv6: false
|
||||
respect-rules: true
|
||||
enhanced-mode: fake-ip
|
||||
fake-ip-range: 198.18.0.1/16
|
||||
fake-ip-filter:
|
||||
- '*.lan'
|
||||
- '*.local'
|
||||
- '+.ru'
|
||||
- '+.xn--p1ai'
|
||||
- rule-set:ru-inside
|
||||
|
||||
default-nameserver:
|
||||
- 77.88.8.8
|
||||
- 1.1.1.1
|
||||
|
||||
proxy-server-nameserver:
|
||||
- https://77.88.8.8/dns-query
|
||||
|
||||
direct-nameserver:
|
||||
- 77.88.8.8
|
||||
- 77.88.8.1
|
||||
|
||||
nameserver:
|
||||
- https://1.1.1.1/dns-query
|
||||
- https://dns.google/dns-query
|
||||
|
||||
proxy-groups:
|
||||
# BOOT: whitelisted entry nodes (BOOT_LINKS), the first alive one
|
||||
- name: BOOT
|
||||
type: fallback
|
||||
proxies: [seed]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
# default for downloading subscriptions: BOOT (if set), else the nodes of the
|
||||
# saved subscriptions (providers are cached on disk), else direct. FOREIGN goes
|
||||
# before DIRECT: the health check of DIRECT (gstatic) passes in Russia even when
|
||||
# the subscription site itself is blocked.
|
||||
- name: BOOT-AUTO
|
||||
type: fallback
|
||||
proxies: [BOOT, FOREIGN, DIRECT]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
- name: RU
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
# lite: the provider's URL, so RU nodes are not tested a second time
|
||||
url: "https://ya.ru"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
- name: FOREIGN
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
exclude-filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
- name: TORRENT
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
filter: "(?i)torrent|\\[tor\\]"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 6000
|
||||
tolerance: 500
|
||||
max-failed-times: 5
|
||||
lazy: false
|
||||
|
||||
# own servers: those of the settings (proxies/30-own_srv) and the "[MY] ..." nodes of
|
||||
# the subscriptions (providers <id>-my); the fastest alive one; pin one in the dashboard if needed
|
||||
- name: MY
|
||||
type: url-test
|
||||
proxies: ["🇩🇪 de 1", "tr \"q\"", "hy-own", "awg-own", "via-foreign"]
|
||||
use: [example-my, example2-my]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
# whitelist and mobile (my_exit): what own servers are reached through; switches only when the node is
|
||||
# clearly worse or dead (each switch breaks everything going through MY)
|
||||
- name: MY-EXIT
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
exclude-filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 300
|
||||
lazy: false
|
||||
|
||||
# UPLINK: what the subscription nodes, BOOT seeds and own servers connect
|
||||
# through. DIRECT - as before; CSQTT - through csqtt0 first (out of the
|
||||
# whitelist); a pool (POOL_<NAME>_UPLINK=1) - through its servers, they themselves
|
||||
# direct; then FOREIGN / MY / RU work on top of it as usual.
|
||||
# On whitelist own servers go MY-EXIT -> node -> UPLINK.
|
||||
- name: UPLINK
|
||||
type: select
|
||||
proxies: [DIRECT, CSQTT]
|
||||
|
||||
- name: MAIN
|
||||
type: select
|
||||
proxies: [FOREIGN, MY, RU, DIRECT, CSQTT]
|
||||
|
||||
- name: TORRENT-SEL
|
||||
type: select
|
||||
proxies: [TORRENT, FOREIGN, DIRECT]
|
||||
|
||||
- name: PUSH
|
||||
type: select
|
||||
proxies: [MY, FOREIGN, DIRECT]
|
||||
|
||||
rules:
|
||||
# the CSQTT client's own connections (peer, VK TURN) must not go into its tunnel
|
||||
- PROCESS-NAME,csqtt,DIRECT
|
||||
|
||||
- IP-CIDR,192.168.0.0/16,DIRECT,no-resolve
|
||||
- IP-CIDR,10.0.0.0/8,DIRECT,no-resolve
|
||||
- IP-CIDR,172.16.0.0/12,DIRECT,no-resolve
|
||||
|
||||
# push notifications (Apple APNs, Google FCM): long-lived connections on a
|
||||
# stable path - group PUSH (main/foreign: DIRECT, whitelist: MY)
|
||||
- DOMAIN-SUFFIX,push.apple.com,PUSH
|
||||
- IP-CIDR,17.249.0.0/16,PUSH,no-resolve
|
||||
- IP-CIDR,17.252.0.0/16,PUSH,no-resolve
|
||||
- IP-CIDR,17.57.144.0/22,PUSH,no-resolve
|
||||
- IP-CIDR,17.188.128.0/18,PUSH,no-resolve
|
||||
- IP-CIDR,17.188.20.0/23,PUSH,no-resolve
|
||||
- DOMAIN-REGEX,^(alt[0-9]+-)?mtalk[0-9]*\.google\.com$,PUSH
|
||||
- DST-PORT,5228-5230,PUSH
|
||||
|
||||
# own lists from the settings: above torrents, ru-inside, .ru and MATCH; below the
|
||||
# tunnels, LAN and push. Domains (DOMAIN-SUFFIX: the domain and all subdomains)
|
||||
# before IPs; first match wins: MY, then FOREIGN, then RU.
|
||||
# RU on main (home, own white IP): reachable directly; whitelist/abroad: through RU
|
||||
- IP-CIDR,194.190.191.112/32,RU
|
||||
|
||||
- SRC-PORT,20000-20199,TORRENT-SEL
|
||||
|
||||
- RULE-SET,ru-inside,DIRECT
|
||||
# main (home, own white IP): ru-services and .ru/.su/.рф directly; elsewhere through RU
|
||||
- RULE-SET,ru-services,RU
|
||||
- DOMAIN-SUFFIX,ru,RU
|
||||
- DOMAIN-SUFFIX,su,RU
|
||||
- DOMAIN-SUFFIX,xn--p1ai,RU
|
||||
- MATCH,MAIN
|
||||
@ -1,339 +0,0 @@
|
||||
proxies:
|
||||
- name: seed
|
||||
type: vless
|
||||
server: 1.2.3.4
|
||||
port: 443
|
||||
uuid: 00000000-0000-0000-0000-000000000000
|
||||
network: tcp
|
||||
udp: true
|
||||
tls: true
|
||||
flow: xtls-rprx-vision
|
||||
servername: eh.vk.ru
|
||||
client-fingerprint: firefox
|
||||
reality-opts:
|
||||
public-key: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
short-id: a1b2
|
||||
|
||||
# Tailscale: userspace node, starts on first use. First login: open the URL
|
||||
# from the nikki log ("To start this tsnet server ... go to: ..."), then
|
||||
# disable key expiry for this node. Needs TS_FORCE_NOISE_443=true in the
|
||||
# mihomo environment (mihomo-kit.sh fix).
|
||||
- name: tailscale
|
||||
type: tailscale
|
||||
hostname: test-mihomo
|
||||
state-dir: ./tailscale
|
||||
udp: true
|
||||
accept-routes: true
|
||||
|
||||
# own servers of the settings (LuCI "Свои серверы", /etc/nikki/my-servers): one JSON
|
||||
# proxy per line, as mihomo's own config would have it; the kit puts dialer-proxy in
|
||||
# front: whitelist and the phone through MY-EXIT, else with UPLINK (CSQTT, pools) through it.
|
||||
# A server with an entry of its own (LuCI "Вход") keeps it in every profile
|
||||
- {"name":"nl-1","type":"hysteria2","server":"vpn.example.com","port":443,"password":"p","udp":true}
|
||||
|
||||
proxy-providers:
|
||||
example:
|
||||
type: http
|
||||
url: "https://sub.example.com/sub/aaa"
|
||||
path: ./providers/example.yaml
|
||||
interval: 3600
|
||||
proxy: BOOT-AUTO
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
example2:
|
||||
type: http
|
||||
url: "https://sub2.example.com/x?a=1&b=2"
|
||||
path: ./providers/example2.yaml
|
||||
interval: 3600
|
||||
proxy: BOOT-AUTO
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
example-my:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
example2-my:
|
||||
type: file
|
||||
path: ./providers/example2.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# OpenVPN: file written on the router by ovpn.sh (with TOTP: a fresh code in the
|
||||
# password). No health-check here: a dead tunnel would be redialed with a
|
||||
# stale code; the cron watchdog (ovpn.sh check) handles it.
|
||||
openvpn:
|
||||
type: file
|
||||
path: ./providers/openvpn.yaml
|
||||
health-check:
|
||||
enable: false
|
||||
override:
|
||||
dialer-proxy: OVPN-EXIT
|
||||
|
||||
rule-providers:
|
||||
# Russian services (geosite ru-inside of russia-only, as .mrs): an ordinary
|
||||
# http rule-set, so every client fetches it with the config, no geodata setup
|
||||
ru-inside:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/ru-inside.mrs"
|
||||
path: ./ruleset/ru-inside.mrs
|
||||
interval: 86400
|
||||
# Russian services outside ru-inside and outside .ru/.su/.рф (russia-only ru-services):
|
||||
# not on the whitelist, so through RU everywhere but main
|
||||
ru-services:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/ru-services.mrs"
|
||||
path: ./ruleset/ru-services.mrs
|
||||
interval: 86400
|
||||
|
||||
# OpenVPN routes (OVPN_ROUTES): the file is written by mihomo-kit.sh build and
|
||||
# emptied by ovpn.sh off, so with the tunnel off these addresses follow
|
||||
# the normal rules instead of a dead OpenVPN group
|
||||
openvpn-routes:
|
||||
type: file
|
||||
behavior: ipcidr
|
||||
path: ./providers/openvpn-routes.yaml
|
||||
|
||||
sniffer:
|
||||
enable: true
|
||||
force-dns-mapping: true
|
||||
parse-pure-ip: true
|
||||
override-destination: false
|
||||
# ECH: browsers show the outer name cloudflare-ech.com instead of the site behind
|
||||
# Cloudflare; the sniffed name wins in the rules, so .ru / own lists would miss the
|
||||
# site. Skipped: the rules see the name from mihomo's DNS (fake-ip / DNS mapping).
|
||||
skip-domain:
|
||||
- "+.cloudflare-ech.com"
|
||||
sniff:
|
||||
HTTP:
|
||||
ports: [80, 8080-8880]
|
||||
TLS:
|
||||
ports: [443, 8443]
|
||||
# lite: no QUIC (fake-ip already gives the domain; pure-IP QUIC goes by IP)
|
||||
QUIC:
|
||||
ports: [443, 8443]
|
||||
|
||||
dns:
|
||||
enable: true
|
||||
ipv6: false
|
||||
respect-rules: true
|
||||
enhanced-mode: fake-ip
|
||||
fake-ip-range: 198.18.0.1/16
|
||||
fake-ip-filter:
|
||||
- '*.lan'
|
||||
- '*.local'
|
||||
# tailnet names: real 100.x addresses from MagicDNS (nameserver-policy below)
|
||||
- '+.ts.net'
|
||||
|
||||
default-nameserver:
|
||||
- 77.88.8.8
|
||||
- 1.1.1.1
|
||||
|
||||
proxy-server-nameserver:
|
||||
- https://77.88.8.8/dns-query
|
||||
|
||||
direct-nameserver:
|
||||
- 1.1.1.1
|
||||
- 8.8.8.8
|
||||
|
||||
nameserver:
|
||||
- https://1.1.1.1/dns-query
|
||||
- https://dns.google/dns-query
|
||||
|
||||
# MagicDNS of the embedded Tailscale (the proxy named "tailscale")
|
||||
nameserver-policy:
|
||||
'+.ts.net': tailscale://tailscale
|
||||
|
||||
proxy-groups:
|
||||
# BOOT: whitelisted entry nodes (BOOT_LINKS), the first alive one
|
||||
- name: BOOT
|
||||
type: fallback
|
||||
proxies: [seed]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
# default for downloading subscriptions: BOOT (if set), else the nodes of the
|
||||
# saved subscriptions (providers are cached on disk), else direct. FOREIGN goes
|
||||
# before DIRECT: the health check of DIRECT (gstatic) passes in Russia even when
|
||||
# the subscription site itself is blocked.
|
||||
- name: BOOT-AUTO
|
||||
type: fallback
|
||||
proxies: [BOOT, FOREIGN, DIRECT]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
- name: RU
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
# lite: the provider's URL, so RU nodes are not tested a second time
|
||||
url: "https://ya.ru"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
- name: FOREIGN
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
exclude-filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
- name: TORRENT
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
filter: "(?i)torrent|\\[tor\\]"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 6000
|
||||
tolerance: 500
|
||||
max-failed-times: 5
|
||||
lazy: false
|
||||
|
||||
# url: what the dashboard's delay test opens through the tunnel;
|
||||
# interval 0: no background checks (they would redial with a stale code)
|
||||
- name: OPENVPN
|
||||
type: select
|
||||
use: [openvpn]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 0
|
||||
|
||||
# what the OpenVPN tunnel itself goes through on whitelist and foreign (ovpn_exit):
|
||||
# a RU node, for a VPN server in Russia. select, not url-test: switching nodes
|
||||
# would break the tunnel. Pick one in the dashboard, the choice is remembered.
|
||||
- name: OVPN-EXIT
|
||||
type: select
|
||||
use: [example, example2]
|
||||
filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
|
||||
# own servers: those of the settings (proxies/30-own_srv) and the "[MY] ..." nodes of
|
||||
# the subscriptions (providers <id>-my); the fastest alive one; pin one in the dashboard if needed
|
||||
- name: MY
|
||||
type: url-test
|
||||
proxies: ["nl-1"]
|
||||
use: [example-my, example2-my]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
# whitelist and mobile (my_exit): what own servers are reached through; switches only when the node is
|
||||
# clearly worse or dead (each switch breaks everything going through MY)
|
||||
|
||||
# url (TS_CHECK_URL, optional): a tailnet service for the dashboard's delay test
|
||||
- name: TAILSCALE
|
||||
type: select
|
||||
proxies: [tailscale]
|
||||
url: "http://100.69.216.50:8080"
|
||||
interval: 0
|
||||
|
||||
- name: MAIN
|
||||
type: select
|
||||
# abroad: direct by default, own servers / pools by hand
|
||||
proxies: [DIRECT, MY, FOREIGN, RU]
|
||||
|
||||
- name: TORRENT-SEL
|
||||
type: select
|
||||
proxies: [TORRENT, FOREIGN, DIRECT]
|
||||
|
||||
- name: PUSH
|
||||
type: select
|
||||
proxies: [DIRECT, MY, FOREIGN]
|
||||
|
||||
rules:
|
||||
# Tailscale: tailnet IPs and MagicDNS names (resolved by tailscale itself)
|
||||
- IP-CIDR,100.64.0.0/10,TAILSCALE,no-resolve
|
||||
- DOMAIN-SUFFIX,ts.net,TAILSCALE
|
||||
|
||||
# the OpenVPN server itself (remote lines of the .ovpn) must not go into its own tunnel
|
||||
- IP-CIDR,198.51.100.4/32,OVPN-EXIT,no-resolve
|
||||
# the networks that go through the VPN (OVPN_ROUTES; before the private-range DIRECT
|
||||
# rules); a rule-provider so that ovpn.sh off can drop them without a restart
|
||||
- RULE-SET,openvpn-routes,OPENVPN,no-resolve
|
||||
|
||||
- IP-CIDR,192.168.0.0/16,DIRECT,no-resolve
|
||||
- IP-CIDR,10.0.0.0/8,DIRECT,no-resolve
|
||||
- IP-CIDR,172.16.0.0/12,DIRECT,no-resolve
|
||||
|
||||
# push notifications (Apple APNs, Google FCM): long-lived connections on a
|
||||
# stable path - group PUSH (main/foreign: DIRECT, whitelist: MY)
|
||||
- DOMAIN-SUFFIX,push.apple.com,PUSH
|
||||
- IP-CIDR,17.249.0.0/16,PUSH,no-resolve
|
||||
- IP-CIDR,17.252.0.0/16,PUSH,no-resolve
|
||||
- IP-CIDR,17.57.144.0/22,PUSH,no-resolve
|
||||
- IP-CIDR,17.188.128.0/18,PUSH,no-resolve
|
||||
- IP-CIDR,17.188.20.0/23,PUSH,no-resolve
|
||||
- DOMAIN-REGEX,^(alt[0-9]+-)?mtalk[0-9]*\.google\.com$,PUSH
|
||||
- DST-PORT,5228-5230,PUSH
|
||||
|
||||
# own lists from the settings: above torrents, ru-inside, .ru and MATCH; below the
|
||||
# tunnels, LAN and push. Domains (DOMAIN-SUFFIX: the domain and all subdomains)
|
||||
# before IPs; first match wins: MY, then FOREIGN, then RU.
|
||||
# RU on main (home, own white IP): reachable directly; whitelist/abroad: through RU
|
||||
- IP-CIDR,194.190.191.112/32,RU
|
||||
|
||||
- SRC-PORT,20000-20199,TORRENT-SEL
|
||||
|
||||
# abroad: Russian services through the RU pool too
|
||||
- RULE-SET,ru-inside,RU
|
||||
# main (home, own white IP): ru-services and .ru/.su/.рф directly; elsewhere through RU
|
||||
- RULE-SET,ru-services,RU
|
||||
- DOMAIN-SUFFIX,ru,RU
|
||||
- DOMAIN-SUFFIX,su,RU
|
||||
- DOMAIN-SUFFIX,xn--p1ai,RU
|
||||
- MATCH,MAIN
|
||||
@ -1,270 +0,0 @@
|
||||
proxies:
|
||||
- name: seed
|
||||
type: vless
|
||||
server: 1.2.3.4
|
||||
port: 443
|
||||
uuid: 00000000-0000-0000-0000-000000000000
|
||||
network: tcp
|
||||
udp: true
|
||||
tls: true
|
||||
flow: xtls-rprx-vision
|
||||
servername: eh.vk.ru
|
||||
client-fingerprint: firefox
|
||||
reality-opts:
|
||||
public-key: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
short-id: a1b2
|
||||
|
||||
proxy-providers:
|
||||
example:
|
||||
type: http
|
||||
url: "https://sub.example.com/sub/aaa"
|
||||
path: ./providers/example.yaml
|
||||
interval: 3600
|
||||
proxy: BOOT-AUTO
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
header:
|
||||
User-Agent: ["my \"ua\" \\x"]
|
||||
x-a: ["1"]
|
||||
x-b: ["two words"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
example2:
|
||||
type: http
|
||||
url: "https://sub2.example.com/x?a=1&b=2"
|
||||
path: ./providers/example2.yaml
|
||||
interval: 3600
|
||||
proxy: DIRECT
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
header:
|
||||
User-Agent: ["v2rayN/9.99"]
|
||||
x-device-os: ["OpenWrt"]
|
||||
x-ver-os: ["24.10.3"]
|
||||
x-device-model: ["Huasifei WH3000 Pro"]
|
||||
x-hwid: ["123"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
example-my:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
example2-my:
|
||||
type: file
|
||||
path: ./providers/example2.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
rule-providers:
|
||||
# Russian services (geosite ru-inside of russia-only, as .mrs): an ordinary
|
||||
# http rule-set, so every client fetches it with the config, no geodata setup
|
||||
ru-inside:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/ru-inside.mrs"
|
||||
path: ./ruleset/ru-inside.mrs
|
||||
interval: 86400
|
||||
# Russian services outside ru-inside and outside .ru/.su/.рф (russia-only ru-services):
|
||||
# not on the whitelist, so through RU everywhere but main
|
||||
ru-services:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/ru-services.mrs"
|
||||
path: ./ruleset/ru-services.mrs
|
||||
interval: 86400
|
||||
|
||||
sniffer:
|
||||
enable: true
|
||||
force-dns-mapping: true
|
||||
parse-pure-ip: true
|
||||
override-destination: false
|
||||
# ECH: browsers show the outer name cloudflare-ech.com instead of the site behind
|
||||
# Cloudflare; the sniffed name wins in the rules, so .ru / own lists would miss the
|
||||
# site. Skipped: the rules see the name from mihomo's DNS (fake-ip / DNS mapping).
|
||||
skip-domain:
|
||||
- "+.cloudflare-ech.com"
|
||||
sniff:
|
||||
HTTP:
|
||||
ports: [80, 8080-8880]
|
||||
TLS:
|
||||
ports: [443, 8443]
|
||||
# lite: no QUIC (fake-ip already gives the domain; pure-IP QUIC goes by IP)
|
||||
QUIC:
|
||||
ports: [443, 8443]
|
||||
|
||||
dns:
|
||||
enable: true
|
||||
ipv6: false
|
||||
respect-rules: true
|
||||
enhanced-mode: fake-ip
|
||||
fake-ip-range: 198.18.0.1/16
|
||||
fake-ip-filter:
|
||||
- '*.lan'
|
||||
- '*.local'
|
||||
- '+.ru'
|
||||
- '+.xn--p1ai'
|
||||
- rule-set:ru-inside
|
||||
|
||||
default-nameserver:
|
||||
- 77.88.8.8
|
||||
- 1.1.1.1
|
||||
|
||||
proxy-server-nameserver:
|
||||
- https://77.88.8.8/dns-query
|
||||
|
||||
direct-nameserver:
|
||||
- 77.88.8.8
|
||||
- 77.88.8.1
|
||||
|
||||
nameserver:
|
||||
- https://1.1.1.1/dns-query
|
||||
- https://dns.google/dns-query
|
||||
|
||||
proxy-groups:
|
||||
# BOOT: whitelisted entry nodes (BOOT_LINKS), the first alive one
|
||||
- name: BOOT
|
||||
type: fallback
|
||||
proxies: [seed]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
# default for downloading subscriptions: BOOT (if set), else the nodes of the
|
||||
# saved subscriptions (providers are cached on disk), else direct. FOREIGN goes
|
||||
# before DIRECT: the health check of DIRECT (gstatic) passes in Russia even when
|
||||
# the subscription site itself is blocked.
|
||||
- name: BOOT-AUTO
|
||||
type: fallback
|
||||
proxies: [BOOT, FOREIGN, DIRECT]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
- name: RU
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
# lite: the provider's URL, so RU nodes are not tested a second time
|
||||
url: "https://ya.ru"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
- name: FOREIGN
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
exclude-filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
- name: TORRENT
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
filter: "(?i)torrent|\\[tor\\]"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 6000
|
||||
tolerance: 500
|
||||
max-failed-times: 5
|
||||
lazy: false
|
||||
|
||||
# own servers: those of the settings (proxies/30-own_srv) and the "[MY] ..." nodes of
|
||||
# the subscriptions (providers <id>-my); the fastest alive one; pin one in the dashboard if needed
|
||||
- name: MY
|
||||
type: url-test
|
||||
use: [example-my, example2-my]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
# whitelist and mobile (my_exit): what own servers are reached through; switches only when the node is
|
||||
# clearly worse or dead (each switch breaks everything going through MY)
|
||||
|
||||
- name: MAIN
|
||||
type: select
|
||||
proxies: [FOREIGN, MY, RU, DIRECT]
|
||||
|
||||
- name: TORRENT-SEL
|
||||
type: select
|
||||
proxies: [TORRENT, FOREIGN, DIRECT]
|
||||
|
||||
- name: PUSH
|
||||
type: select
|
||||
proxies: [DIRECT, MY, FOREIGN]
|
||||
|
||||
rules:
|
||||
- IP-CIDR,192.168.0.0/16,DIRECT,no-resolve
|
||||
- IP-CIDR,10.0.0.0/8,DIRECT,no-resolve
|
||||
- IP-CIDR,172.16.0.0/12,DIRECT,no-resolve
|
||||
|
||||
# push notifications (Apple APNs, Google FCM): long-lived connections on a
|
||||
# stable path - group PUSH (main/foreign: DIRECT, whitelist: MY)
|
||||
- DOMAIN-SUFFIX,push.apple.com,PUSH
|
||||
- IP-CIDR,17.249.0.0/16,PUSH,no-resolve
|
||||
- IP-CIDR,17.252.0.0/16,PUSH,no-resolve
|
||||
- IP-CIDR,17.57.144.0/22,PUSH,no-resolve
|
||||
- IP-CIDR,17.188.128.0/18,PUSH,no-resolve
|
||||
- IP-CIDR,17.188.20.0/23,PUSH,no-resolve
|
||||
- DOMAIN-REGEX,^(alt[0-9]+-)?mtalk[0-9]*\.google\.com$,PUSH
|
||||
- DST-PORT,5228-5230,PUSH
|
||||
|
||||
# own lists from the settings: above torrents, ru-inside, .ru and MATCH; below the
|
||||
# tunnels, LAN and push. Domains (DOMAIN-SUFFIX: the domain and all subdomains)
|
||||
# before IPs; first match wins: MY, then FOREIGN, then RU.
|
||||
# RU on main (home, own white IP): reachable directly; whitelist/abroad: through RU
|
||||
- IP-CIDR,194.190.191.112/32,DIRECT
|
||||
|
||||
- SRC-PORT,20000-20199,TORRENT-SEL
|
||||
|
||||
- RULE-SET,ru-inside,DIRECT
|
||||
# main (home, own white IP): ru-services and .ru/.su/.рф directly; elsewhere through RU
|
||||
- RULE-SET,ru-services,DIRECT
|
||||
- DOMAIN-SUFFIX,ru,DIRECT
|
||||
- DOMAIN-SUFFIX,su,DIRECT
|
||||
- DOMAIN-SUFFIX,xn--p1ai,DIRECT
|
||||
- MATCH,MAIN
|
||||
@ -1,306 +0,0 @@
|
||||
proxies:
|
||||
- name: seed
|
||||
type: vless
|
||||
server: 1.2.3.4
|
||||
port: 443
|
||||
uuid: 00000000-0000-0000-0000-000000000000
|
||||
network: tcp
|
||||
udp: true
|
||||
tls: true
|
||||
flow: xtls-rprx-vision
|
||||
servername: eh.vk.ru
|
||||
client-fingerprint: firefox
|
||||
reality-opts:
|
||||
public-key: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
short-id: a1b2
|
||||
|
||||
proxy-providers:
|
||||
kitty:
|
||||
type: http
|
||||
url: "https://a.example.com/x"
|
||||
path: ./providers/kitty.yaml
|
||||
interval: 3600
|
||||
proxy: BOOT-AUTO
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
header:
|
||||
User-Agent: ["v2rayN/9.99"]
|
||||
x-device-os: ["OpenWrt"]
|
||||
x-ver-os: ["24.10.3"]
|
||||
x-device-model: ["Huasifei WH3000 Pro"]
|
||||
x-hwid: ["123"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
vpn_host:
|
||||
type: http
|
||||
url: "https://sub.vpn-host.co.uk/y?t=1"
|
||||
path: ./providers/vpn_host.yaml
|
||||
interval: 3600
|
||||
proxy: DIRECT
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
sub3:
|
||||
type: http
|
||||
url: "https://1.2.3.4:8443/s"
|
||||
path: ./providers/sub3.yaml
|
||||
interval: 3600
|
||||
proxy: FOREIGN
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
x-a: ["1"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
kitty-my:
|
||||
type: file
|
||||
path: ./providers/kitty.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
vpn_host-my:
|
||||
type: file
|
||||
path: ./providers/vpn_host.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
sub3-my:
|
||||
type: file
|
||||
path: ./providers/sub3.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
rule-providers:
|
||||
# Russian services (geosite ru-inside of russia-only, as .mrs): an ordinary
|
||||
# http rule-set, so every client fetches it with the config, no geodata setup
|
||||
ru-inside:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/ru-inside.mrs"
|
||||
path: ./ruleset/ru-inside.mrs
|
||||
interval: 86400
|
||||
# Russian services outside ru-inside and outside .ru/.su/.рф (russia-only ru-services):
|
||||
# not on the whitelist, so through RU everywhere but main
|
||||
ru-services:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/ru-services.mrs"
|
||||
path: ./ruleset/ru-services.mrs
|
||||
interval: 86400
|
||||
|
||||
sniffer:
|
||||
enable: true
|
||||
force-dns-mapping: true
|
||||
parse-pure-ip: true
|
||||
override-destination: false
|
||||
# ECH: browsers show the outer name cloudflare-ech.com instead of the site behind
|
||||
# Cloudflare; the sniffed name wins in the rules, so .ru / own lists would miss the
|
||||
# site. Skipped: the rules see the name from mihomo's DNS (fake-ip / DNS mapping).
|
||||
skip-domain:
|
||||
- "+.cloudflare-ech.com"
|
||||
sniff:
|
||||
HTTP:
|
||||
ports: [80, 8080-8880]
|
||||
TLS:
|
||||
ports: [443, 8443]
|
||||
# lite: no QUIC (fake-ip already gives the domain; pure-IP QUIC goes by IP)
|
||||
QUIC:
|
||||
ports: [443, 8443]
|
||||
|
||||
dns:
|
||||
enable: true
|
||||
ipv6: false
|
||||
respect-rules: true
|
||||
enhanced-mode: fake-ip
|
||||
fake-ip-range: 198.18.0.1/16
|
||||
fake-ip-filter:
|
||||
- '*.lan'
|
||||
- '*.local'
|
||||
- '+.ru'
|
||||
- '+.xn--p1ai'
|
||||
- rule-set:ru-inside
|
||||
|
||||
default-nameserver:
|
||||
- 77.88.8.8
|
||||
- 1.1.1.1
|
||||
|
||||
proxy-server-nameserver:
|
||||
- https://77.88.8.8/dns-query
|
||||
|
||||
direct-nameserver:
|
||||
- 77.88.8.8
|
||||
- 77.88.8.1
|
||||
|
||||
nameserver:
|
||||
- https://1.1.1.1/dns-query
|
||||
- https://dns.google/dns-query
|
||||
|
||||
proxy-groups:
|
||||
# BOOT: whitelisted entry nodes (BOOT_LINKS), the first alive one
|
||||
- name: BOOT
|
||||
type: fallback
|
||||
proxies: [seed]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
# default for downloading subscriptions: BOOT (if set), else the nodes of the
|
||||
# saved subscriptions (providers are cached on disk), else direct. FOREIGN goes
|
||||
# before DIRECT: the health check of DIRECT (gstatic) passes in Russia even when
|
||||
# the subscription site itself is blocked.
|
||||
- name: BOOT-AUTO
|
||||
type: fallback
|
||||
proxies: [BOOT, FOREIGN, DIRECT]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
- name: RU
|
||||
type: url-test
|
||||
use: [kitty, vpn_host, sub3]
|
||||
filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
# lite: the provider's URL, so RU nodes are not tested a second time
|
||||
url: "https://ya.ru"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
- name: FOREIGN
|
||||
type: url-test
|
||||
use: [kitty, vpn_host, sub3]
|
||||
exclude-filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
- name: TORRENT
|
||||
type: url-test
|
||||
use: [kitty, vpn_host, sub3]
|
||||
filter: "(?i)torrent|\\[tor\\]"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 6000
|
||||
tolerance: 500
|
||||
max-failed-times: 5
|
||||
lazy: false
|
||||
|
||||
# own servers: those of the settings (proxies/30-own_srv) and the "[MY] ..." nodes of
|
||||
# the subscriptions (providers <id>-my); the fastest alive one; pin one in the dashboard if needed
|
||||
- name: MY
|
||||
type: url-test
|
||||
use: [kitty-my, vpn_host-my, sub3-my]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
# whitelist and mobile (my_exit): what own servers are reached through; switches only when the node is
|
||||
# clearly worse or dead (each switch breaks everything going through MY)
|
||||
|
||||
- name: MAIN
|
||||
type: select
|
||||
proxies: [FOREIGN, MY, RU, DIRECT]
|
||||
|
||||
- name: TORRENT-SEL
|
||||
type: select
|
||||
proxies: [TORRENT, FOREIGN, DIRECT]
|
||||
|
||||
- name: PUSH
|
||||
type: select
|
||||
proxies: [DIRECT, MY, FOREIGN]
|
||||
|
||||
rules:
|
||||
- IP-CIDR,192.168.0.0/16,DIRECT,no-resolve
|
||||
- IP-CIDR,10.0.0.0/8,DIRECT,no-resolve
|
||||
- IP-CIDR,172.16.0.0/12,DIRECT,no-resolve
|
||||
|
||||
# push notifications (Apple APNs, Google FCM): long-lived connections on a
|
||||
# stable path - group PUSH (main/foreign: DIRECT, whitelist: MY)
|
||||
- DOMAIN-SUFFIX,push.apple.com,PUSH
|
||||
- IP-CIDR,17.249.0.0/16,PUSH,no-resolve
|
||||
- IP-CIDR,17.252.0.0/16,PUSH,no-resolve
|
||||
- IP-CIDR,17.57.144.0/22,PUSH,no-resolve
|
||||
- IP-CIDR,17.188.128.0/18,PUSH,no-resolve
|
||||
- IP-CIDR,17.188.20.0/23,PUSH,no-resolve
|
||||
- DOMAIN-REGEX,^(alt[0-9]+-)?mtalk[0-9]*\.google\.com$,PUSH
|
||||
- DST-PORT,5228-5230,PUSH
|
||||
|
||||
# own lists from the settings: above torrents, ru-inside, .ru and MATCH; below the
|
||||
# tunnels, LAN and push. Domains (DOMAIN-SUFFIX: the domain and all subdomains)
|
||||
# before IPs; first match wins: MY, then FOREIGN, then RU.
|
||||
# RU on main (home, own white IP): reachable directly; whitelist/abroad: through RU
|
||||
- IP-CIDR,194.190.191.112/32,DIRECT
|
||||
|
||||
- SRC-PORT,20000-20199,TORRENT-SEL
|
||||
|
||||
- RULE-SET,ru-inside,DIRECT
|
||||
# main (home, own white IP): ru-services and .ru/.su/.рф directly; elsewhere through RU
|
||||
- RULE-SET,ru-services,DIRECT
|
||||
- DOMAIN-SUFFIX,ru,DIRECT
|
||||
- DOMAIN-SUFFIX,su,DIRECT
|
||||
- DOMAIN-SUFFIX,xn--p1ai,DIRECT
|
||||
- MATCH,MAIN
|
||||
@ -1,297 +0,0 @@
|
||||
# LITE=1 (weak routers). nikki's mixin overrides keys whose uci options are set
|
||||
# (mihomo-kit.sh puts log_level / match_process there); these cover the rest
|
||||
log-level: warning
|
||||
tcp-concurrent: false
|
||||
unified-delay: false
|
||||
geo-auto-update: false
|
||||
|
||||
proxies:
|
||||
- name: seed
|
||||
type: vless
|
||||
server: 1.2.3.4
|
||||
port: 443
|
||||
uuid: 00000000-0000-0000-0000-000000000000
|
||||
network: tcp
|
||||
udp: true
|
||||
tls: true
|
||||
flow: xtls-rprx-vision
|
||||
servername: eh.vk.ru
|
||||
client-fingerprint: firefox
|
||||
reality-opts:
|
||||
public-key: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
short-id: a1b2
|
||||
dialer-proxy: UPLINK
|
||||
|
||||
# CSQTT (star-panel-csqtt): tunnel interface csqtt0 on the router, mihomo
|
||||
# just sends the connection out of it (the interface does not change routes)
|
||||
- name: CSQTT
|
||||
type: direct
|
||||
interface-name: csqtt0
|
||||
udp: true
|
||||
|
||||
proxy-providers:
|
||||
example:
|
||||
type: http
|
||||
url: "https://sub.example.com/sub/aaa"
|
||||
path: ./providers/example.yaml
|
||||
interval: 3600
|
||||
proxy: BOOT-AUTO
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
override:
|
||||
dialer-proxy: UPLINK
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 600
|
||||
timeout: 3000
|
||||
lazy: true
|
||||
|
||||
example2:
|
||||
type: http
|
||||
url: "https://sub2.example.com/x?a=1&b=2"
|
||||
path: ./providers/example2.yaml
|
||||
interval: 3600
|
||||
proxy: BOOT-AUTO
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
override:
|
||||
dialer-proxy: UPLINK
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 600
|
||||
timeout: 3000
|
||||
lazy: true
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
example-my:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
override:
|
||||
dialer-proxy: UPLINK
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 600
|
||||
timeout: 3000
|
||||
lazy: true
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
example2-my:
|
||||
type: file
|
||||
path: ./providers/example2.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
override:
|
||||
dialer-proxy: UPLINK
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 600
|
||||
timeout: 3000
|
||||
lazy: true
|
||||
|
||||
rule-providers:
|
||||
# Russian services (geosite ru-inside of russia-only, as .mrs): an ordinary
|
||||
# http rule-set, so every client fetches it with the config, no geodata setup
|
||||
ru-inside:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/ru-inside.mrs"
|
||||
path: ./ruleset/ru-inside.mrs
|
||||
interval: 86400
|
||||
# Russian services outside ru-inside and outside .ru/.su/.рф (russia-only ru-services):
|
||||
# not on the whitelist, so through RU everywhere but main
|
||||
ru-services:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/ru-services.mrs"
|
||||
path: ./ruleset/ru-services.mrs
|
||||
interval: 86400
|
||||
|
||||
sniffer:
|
||||
enable: true
|
||||
force-dns-mapping: true
|
||||
parse-pure-ip: true
|
||||
override-destination: false
|
||||
# ECH: browsers show the outer name cloudflare-ech.com instead of the site behind
|
||||
# Cloudflare; the sniffed name wins in the rules, so .ru / own lists would miss the
|
||||
# site. Skipped: the rules see the name from mihomo's DNS (fake-ip / DNS mapping).
|
||||
skip-domain:
|
||||
- "+.cloudflare-ech.com"
|
||||
sniff:
|
||||
HTTP:
|
||||
ports: [80, 8080]
|
||||
TLS:
|
||||
ports: [443, 8443]
|
||||
# lite: no QUIC (fake-ip already gives the domain; pure-IP QUIC goes by IP)
|
||||
|
||||
dns:
|
||||
enable: true
|
||||
ipv6: false
|
||||
respect-rules: true
|
||||
enhanced-mode: fake-ip
|
||||
fake-ip-range: 198.18.0.1/16
|
||||
fake-ip-filter:
|
||||
- '*.lan'
|
||||
- '*.local'
|
||||
- '+.ru'
|
||||
- '+.xn--p1ai'
|
||||
- rule-set:ru-inside
|
||||
|
||||
default-nameserver:
|
||||
- 77.88.8.8
|
||||
- 1.1.1.1
|
||||
|
||||
proxy-server-nameserver:
|
||||
- https://77.88.8.8/dns-query
|
||||
|
||||
direct-nameserver:
|
||||
- 77.88.8.8
|
||||
- 77.88.8.1
|
||||
|
||||
nameserver:
|
||||
- https://1.1.1.1/dns-query
|
||||
- https://dns.google/dns-query
|
||||
|
||||
proxy-groups:
|
||||
# BOOT: whitelisted entry nodes (BOOT_LINKS), the first alive one
|
||||
- name: BOOT
|
||||
type: fallback
|
||||
proxies: [seed]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
# default for downloading subscriptions: BOOT (if set), else the nodes of the
|
||||
# saved subscriptions (providers are cached on disk), else direct. FOREIGN goes
|
||||
# before DIRECT: the health check of DIRECT (gstatic) passes in Russia even when
|
||||
# the subscription site itself is blocked.
|
||||
- name: BOOT-AUTO
|
||||
type: fallback
|
||||
proxies: [BOOT, FOREIGN, DIRECT]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
- name: RU
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
# lite: the provider's URL, so RU nodes are not tested a second time
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
- name: FOREIGN
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
exclude-filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
- name: TORRENT
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
filter: "(?i)torrent|\\[tor\\]"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 6000
|
||||
tolerance: 500
|
||||
max-failed-times: 5
|
||||
lazy: false
|
||||
|
||||
# own servers: those of the settings (proxies/30-own_srv) and the "[MY] ..." nodes of
|
||||
# the subscriptions (providers <id>-my); the fastest alive one; pin one in the dashboard if needed
|
||||
- name: MY
|
||||
type: url-test
|
||||
use: [example-my, example2-my]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 600
|
||||
tolerance: 50
|
||||
lazy: true
|
||||
|
||||
# whitelist and mobile (my_exit): what own servers are reached through; switches only when the node is
|
||||
# clearly worse or dead (each switch breaks everything going through MY)
|
||||
|
||||
# UPLINK: what the subscription nodes, BOOT seeds and own servers connect
|
||||
# through. DIRECT - as before; CSQTT - through csqtt0 first (out of the
|
||||
# whitelist); a pool (POOL_<NAME>_UPLINK=1) - through its servers, they themselves
|
||||
# direct; then FOREIGN / MY / RU work on top of it as usual.
|
||||
# On whitelist own servers go MY-EXIT -> node -> UPLINK.
|
||||
- name: UPLINK
|
||||
type: select
|
||||
proxies: [DIRECT, CSQTT]
|
||||
|
||||
- name: MAIN
|
||||
type: select
|
||||
proxies: [FOREIGN, MY, RU, DIRECT, CSQTT]
|
||||
|
||||
- name: TORRENT-SEL
|
||||
type: select
|
||||
proxies: [TORRENT, FOREIGN, DIRECT]
|
||||
|
||||
- name: PUSH
|
||||
type: select
|
||||
proxies: [DIRECT, MY, FOREIGN]
|
||||
|
||||
rules:
|
||||
# the CSQTT client's own connections (peer, VK TURN) must not go into its tunnel
|
||||
- PROCESS-NAME,csqtt,DIRECT
|
||||
|
||||
- IP-CIDR,192.168.0.0/16,DIRECT,no-resolve
|
||||
- IP-CIDR,10.0.0.0/8,DIRECT,no-resolve
|
||||
- IP-CIDR,172.16.0.0/12,DIRECT,no-resolve
|
||||
|
||||
# push notifications (Apple APNs, Google FCM): long-lived connections on a
|
||||
# stable path - group PUSH (main/foreign: DIRECT, whitelist: MY)
|
||||
- DOMAIN-SUFFIX,push.apple.com,PUSH
|
||||
- IP-CIDR,17.249.0.0/16,PUSH,no-resolve
|
||||
- IP-CIDR,17.252.0.0/16,PUSH,no-resolve
|
||||
- IP-CIDR,17.57.144.0/22,PUSH,no-resolve
|
||||
- IP-CIDR,17.188.128.0/18,PUSH,no-resolve
|
||||
- IP-CIDR,17.188.20.0/23,PUSH,no-resolve
|
||||
- DOMAIN-REGEX,^(alt[0-9]+-)?mtalk[0-9]*\.google\.com$,PUSH
|
||||
- DST-PORT,5228-5230,PUSH
|
||||
|
||||
# own lists from the settings: above torrents, ru-inside, .ru and MATCH; below the
|
||||
# tunnels, LAN and push. Domains (DOMAIN-SUFFIX: the domain and all subdomains)
|
||||
# before IPs; first match wins: MY, then FOREIGN, then RU.
|
||||
# RU on main (home, own white IP): reachable directly; whitelist/abroad: through RU
|
||||
- IP-CIDR,194.190.191.112/32,DIRECT
|
||||
|
||||
- SRC-PORT,20000-20199,TORRENT-SEL
|
||||
|
||||
- RULE-SET,ru-inside,DIRECT
|
||||
# main (home, own white IP): ru-services and .ru/.su/.рф directly; elsewhere through RU
|
||||
- RULE-SET,ru-services,DIRECT
|
||||
- DOMAIN-SUFFIX,ru,DIRECT
|
||||
- DOMAIN-SUFFIX,su,DIRECT
|
||||
- DOMAIN-SUFFIX,xn--p1ai,DIRECT
|
||||
- MATCH,MAIN
|
||||
@ -1,289 +0,0 @@
|
||||
# LITE=1 (weak routers). nikki's mixin overrides keys whose uci options are set
|
||||
# (mihomo-kit.sh puts log_level / match_process there); these cover the rest
|
||||
log-level: warning
|
||||
find-process-mode: off
|
||||
tcp-concurrent: false
|
||||
unified-delay: false
|
||||
geo-auto-update: false
|
||||
|
||||
proxies:
|
||||
- name: seed
|
||||
type: vless
|
||||
server: 1.2.3.4
|
||||
port: 443
|
||||
uuid: 00000000-0000-0000-0000-000000000000
|
||||
network: tcp
|
||||
udp: true
|
||||
tls: true
|
||||
flow: xtls-rprx-vision
|
||||
servername: eh.vk.ru
|
||||
client-fingerprint: firefox
|
||||
reality-opts:
|
||||
public-key: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
short-id: a1b2
|
||||
|
||||
# own servers of the settings (LuCI "Свои серверы", /etc/nikki/my-servers): one JSON
|
||||
# proxy per line, as mihomo's own config would have it; the kit puts dialer-proxy in
|
||||
# front: whitelist and the phone through MY-EXIT, else with UPLINK (CSQTT, pools) through it.
|
||||
# A server with an entry of its own (LuCI "Вход") keeps it in every profile
|
||||
- {"dialer-proxy": "MY-EXIT", "name":"nl-1","type":"hysteria2","server":"vpn.example.com","port":443,"password":"p","udp":true}
|
||||
|
||||
proxy-providers:
|
||||
example:
|
||||
type: http
|
||||
url: "https://sub.example.com/sub/aaa"
|
||||
path: ./providers/example.yaml
|
||||
interval: 3600
|
||||
proxy: BOOT-AUTO
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 600
|
||||
timeout: 3000
|
||||
lazy: true
|
||||
|
||||
example2:
|
||||
type: http
|
||||
url: "https://sub2.example.com/x?a=1&b=2"
|
||||
path: ./providers/example2.yaml
|
||||
interval: 3600
|
||||
proxy: BOOT-AUTO
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 600
|
||||
timeout: 3000
|
||||
lazy: true
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
example-my:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
override:
|
||||
dialer-proxy: MY-EXIT
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 600
|
||||
timeout: 3000
|
||||
lazy: true
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
example2-my:
|
||||
type: file
|
||||
path: ./providers/example2.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
override:
|
||||
dialer-proxy: MY-EXIT
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 600
|
||||
timeout: 3000
|
||||
lazy: true
|
||||
|
||||
rule-providers:
|
||||
# Russian services (geosite ru-inside of russia-only, as .mrs): an ordinary
|
||||
# http rule-set, so every client fetches it with the config, no geodata setup
|
||||
ru-inside:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/ru-inside.mrs"
|
||||
path: ./ruleset/ru-inside.mrs
|
||||
interval: 86400
|
||||
# Russian services outside ru-inside and outside .ru/.su/.рф (russia-only ru-services):
|
||||
# not on the whitelist, so through RU everywhere but main
|
||||
ru-services:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/ru-services.mrs"
|
||||
path: ./ruleset/ru-services.mrs
|
||||
interval: 86400
|
||||
|
||||
sniffer:
|
||||
enable: true
|
||||
force-dns-mapping: true
|
||||
parse-pure-ip: true
|
||||
override-destination: false
|
||||
# ECH: browsers show the outer name cloudflare-ech.com instead of the site behind
|
||||
# Cloudflare; the sniffed name wins in the rules, so .ru / own lists would miss the
|
||||
# site. Skipped: the rules see the name from mihomo's DNS (fake-ip / DNS mapping).
|
||||
skip-domain:
|
||||
- "+.cloudflare-ech.com"
|
||||
sniff:
|
||||
HTTP:
|
||||
ports: [80, 8080]
|
||||
TLS:
|
||||
ports: [443, 8443]
|
||||
# lite: no QUIC (fake-ip already gives the domain; pure-IP QUIC goes by IP)
|
||||
|
||||
dns:
|
||||
enable: true
|
||||
ipv6: false
|
||||
respect-rules: true
|
||||
enhanced-mode: fake-ip
|
||||
fake-ip-range: 198.18.0.1/16
|
||||
fake-ip-filter:
|
||||
- '*.lan'
|
||||
- '*.local'
|
||||
- '+.ru'
|
||||
- '+.xn--p1ai'
|
||||
- rule-set:ru-inside
|
||||
|
||||
default-nameserver:
|
||||
- 77.88.8.8
|
||||
- 1.1.1.1
|
||||
|
||||
proxy-server-nameserver:
|
||||
- https://77.88.8.8/dns-query
|
||||
|
||||
direct-nameserver:
|
||||
- 77.88.8.8
|
||||
- 77.88.8.1
|
||||
|
||||
nameserver:
|
||||
- https://1.1.1.1/dns-query
|
||||
- https://dns.google/dns-query
|
||||
|
||||
proxy-groups:
|
||||
# BOOT: whitelisted entry nodes (BOOT_LINKS), the first alive one
|
||||
- name: BOOT
|
||||
type: fallback
|
||||
proxies: [seed]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
# default for downloading subscriptions: BOOT (if set), else the nodes of the
|
||||
# saved subscriptions (providers are cached on disk), else direct. FOREIGN goes
|
||||
# before DIRECT: the health check of DIRECT (gstatic) passes in Russia even when
|
||||
# the subscription site itself is blocked.
|
||||
- name: BOOT-AUTO
|
||||
type: fallback
|
||||
proxies: [BOOT, FOREIGN, DIRECT]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
- name: RU
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
# lite: the provider's URL, so RU nodes are not tested a second time
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
- name: FOREIGN
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
exclude-filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
- name: TORRENT
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
filter: "(?i)torrent|\\[tor\\]"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 6000
|
||||
tolerance: 500
|
||||
max-failed-times: 5
|
||||
lazy: false
|
||||
|
||||
# own servers: those of the settings (proxies/30-own_srv) and the "[MY] ..." nodes of
|
||||
# the subscriptions (providers <id>-my); the fastest alive one; pin one in the dashboard if needed
|
||||
- name: MY
|
||||
type: url-test
|
||||
proxies: ["nl-1"]
|
||||
use: [example-my, example2-my]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 600
|
||||
tolerance: 50
|
||||
lazy: true
|
||||
|
||||
# whitelist and mobile (my_exit): what own servers are reached through; switches only when the node is
|
||||
# clearly worse or dead (each switch breaks everything going through MY)
|
||||
- name: MY-EXIT
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
exclude-filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 300
|
||||
lazy: false
|
||||
|
||||
- name: MAIN
|
||||
type: select
|
||||
proxies: [FOREIGN, MY, RU, DIRECT]
|
||||
|
||||
- name: TORRENT-SEL
|
||||
type: select
|
||||
proxies: [TORRENT, FOREIGN, DIRECT]
|
||||
|
||||
- name: PUSH
|
||||
type: select
|
||||
proxies: [MY, FOREIGN, DIRECT]
|
||||
|
||||
rules:
|
||||
- IP-CIDR,192.168.0.0/16,DIRECT,no-resolve
|
||||
- IP-CIDR,10.0.0.0/8,DIRECT,no-resolve
|
||||
- IP-CIDR,172.16.0.0/12,DIRECT,no-resolve
|
||||
|
||||
# push notifications (Apple APNs, Google FCM): long-lived connections on a
|
||||
# stable path - group PUSH (main/foreign: DIRECT, whitelist: MY)
|
||||
- DOMAIN-SUFFIX,push.apple.com,PUSH
|
||||
- IP-CIDR,17.249.0.0/16,PUSH,no-resolve
|
||||
- IP-CIDR,17.252.0.0/16,PUSH,no-resolve
|
||||
- IP-CIDR,17.57.144.0/22,PUSH,no-resolve
|
||||
- IP-CIDR,17.188.128.0/18,PUSH,no-resolve
|
||||
- IP-CIDR,17.188.20.0/23,PUSH,no-resolve
|
||||
- DOMAIN-REGEX,^(alt[0-9]+-)?mtalk[0-9]*\.google\.com$,PUSH
|
||||
- DST-PORT,5228-5230,PUSH
|
||||
|
||||
# own lists from the settings: above torrents, ru-inside, .ru and MATCH; below the
|
||||
# tunnels, LAN and push. Domains (DOMAIN-SUFFIX: the domain and all subdomains)
|
||||
# before IPs; first match wins: MY, then FOREIGN, then RU.
|
||||
# RU on main (home, own white IP): reachable directly; whitelist/abroad: through RU
|
||||
- IP-CIDR,194.190.191.112/32,RU
|
||||
|
||||
- SRC-PORT,20000-20199,TORRENT-SEL
|
||||
|
||||
- RULE-SET,ru-inside,DIRECT
|
||||
# main (home, own white IP): ru-services and .ru/.su/.рф directly; elsewhere through RU
|
||||
- RULE-SET,ru-services,RU
|
||||
- DOMAIN-SUFFIX,ru,RU
|
||||
- DOMAIN-SUFFIX,su,RU
|
||||
- DOMAIN-SUFFIX,xn--p1ai,RU
|
||||
- MATCH,MAIN
|
||||
@ -1,358 +0,0 @@
|
||||
proxies:
|
||||
- name: seed
|
||||
type: vless
|
||||
server: 1.2.3.4
|
||||
port: 443
|
||||
uuid: 00000000-0000-0000-0000-000000000000
|
||||
network: tcp
|
||||
udp: true
|
||||
tls: true
|
||||
flow: xtls-rprx-vision
|
||||
servername: eh.vk.ru
|
||||
client-fingerprint: firefox
|
||||
reality-opts:
|
||||
public-key: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
short-id: a1b2
|
||||
|
||||
# Tailscale: userspace node, starts on first use. First login: open the URL
|
||||
# from the nikki log ("To start this tsnet server ... go to: ..."), then
|
||||
# disable key expiry for this node. Needs TS_FORCE_NOISE_443=true in the
|
||||
# mihomo environment (mihomo-kit.sh fix).
|
||||
- name: tailscale
|
||||
type: tailscale
|
||||
hostname: test-mihomo
|
||||
state-dir: ./tailscale
|
||||
udp: true
|
||||
accept-routes: true
|
||||
|
||||
# own servers of the settings (LuCI "Свои серверы", /etc/nikki/my-servers): one JSON
|
||||
# proxy per line, as mihomo's own config would have it; the kit puts dialer-proxy in
|
||||
# front: whitelist and the phone through MY-EXIT, else with UPLINK (CSQTT, pools) through it.
|
||||
# A server with an entry of its own (LuCI "Вход") keeps it in every profile
|
||||
- {"name":"🇩🇪 de 1","type":"vless","server":"x.example.com","port":"443","uuid":"00000000-0000-0000-0000-000000000001","udp":true,"tls":true,"client-fingerprint":"chrome","servername":"www.example.com","reality-opts":{"public-key":"Nc9ZSDuQMwHN4M6TeDHjfJhgZ6SBTBbfMwx5iHQZ1ns","short-id":"ab"},"xudp":true,"network":"xhttp","xhttp-opts":{"path":"/x"}}
|
||||
- {"name":"tr \"q\"","type":"trojan","server":"t.example.org","port":"443","password":"p\u0024w","udp":true,"skip-cert-verify":false,"sni":"t.example.org","network":"grpc","grpc-opts":{"grpc-service-name":"g"},"client-fingerprint":"chrome"}
|
||||
- {"name":"hy-own","type":"hysteria2","server":"h.example.net","port":8443,"password":"a\u0024b","obfs":"salamander","obfs-password":"o","up":"50 mbps"}
|
||||
- {"name":"awg-own","type":"wireguard","server":"203.0.113.10","port":47613,"ip":"10.8.1.2","private-key":"fTo2df+b5vCuulh7pOXMWiWJY2VwSe2Kuup2nA34tfI=","public-key":"vGYpG72gCXPNfYzr/0iNfSoL83vbrVSGUC+v+MKRVyE=","pre-shared-key":"6ut/J6EuaJ97RMFcZuiJkzIo7a5uxR98htK5NdWJW6E=","persistent-keepalive":25,"udp":true,"amnezia-wg-option":{"jc":4,"jmin":10,"jmax":50,"s1":98,"s2":32,"s3":19,"s4":7,"h1":"1458367412-1593426716","h2":"1863071624-1902347825","h3":"2091548318-2097143921","h4":"2112573893-2147191025","i1":"<r 2><b 0x858000010001000000000669636c6f756403636f6d0000010001c00c000100010000105a00044d583737>"}}
|
||||
- {"name":"home-hy","type":"hysteria2","server":"1.1.1.1","port":443,"password":"x","udp":true}
|
||||
- {"name":"via-foreign","type":"ss","server":"f.example.com","port":8388,"cipher":"aes-256-gcm","password":"x","dialer-proxy":"FOREIGN"}
|
||||
|
||||
proxy-providers:
|
||||
example:
|
||||
type: http
|
||||
url: "https://sub.example.com/sub/aaa"
|
||||
path: ./providers/example.yaml
|
||||
interval: 3600
|
||||
proxy: BOOT-AUTO
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
example2:
|
||||
type: http
|
||||
url: "https://sub2.example.com/x?a=1&b=2"
|
||||
path: ./providers/example2.yaml
|
||||
interval: 3600
|
||||
proxy: DIRECT
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
example-my:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
example2-my:
|
||||
type: file
|
||||
path: ./providers/example2.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# OpenVPN: file written on the router by ovpn.sh (with TOTP: a fresh code in the
|
||||
# password). No health-check here: a dead tunnel would be redialed with a
|
||||
# stale code; the cron watchdog (ovpn.sh check) handles it.
|
||||
openvpn:
|
||||
type: file
|
||||
path: ./providers/openvpn.yaml
|
||||
health-check:
|
||||
enable: false
|
||||
|
||||
rule-providers:
|
||||
# Russian services (geosite ru-inside of russia-only, as .mrs): an ordinary
|
||||
# http rule-set, so every client fetches it with the config, no geodata setup
|
||||
ru-inside:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/ru-inside.mrs"
|
||||
path: ./ruleset/ru-inside.mrs
|
||||
interval: 86400
|
||||
# Russian services outside ru-inside and outside .ru/.su/.рф (russia-only ru-services):
|
||||
# not on the whitelist, so through RU everywhere but main
|
||||
ru-services:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/ru-services.mrs"
|
||||
path: ./ruleset/ru-services.mrs
|
||||
interval: 86400
|
||||
|
||||
# OpenVPN routes (OVPN_ROUTES): the file is written by mihomo-kit.sh build and
|
||||
# emptied by ovpn.sh off, so with the tunnel off these addresses follow
|
||||
# the normal rules instead of a dead OpenVPN group
|
||||
openvpn-routes:
|
||||
type: file
|
||||
behavior: ipcidr
|
||||
path: ./providers/openvpn-routes.yaml
|
||||
|
||||
sniffer:
|
||||
enable: true
|
||||
force-dns-mapping: true
|
||||
parse-pure-ip: true
|
||||
override-destination: false
|
||||
# ECH: browsers show the outer name cloudflare-ech.com instead of the site behind
|
||||
# Cloudflare; the sniffed name wins in the rules, so .ru / own lists would miss the
|
||||
# site. Skipped: the rules see the name from mihomo's DNS (fake-ip / DNS mapping).
|
||||
skip-domain:
|
||||
- "+.cloudflare-ech.com"
|
||||
sniff:
|
||||
HTTP:
|
||||
ports: [80, 8080-8880]
|
||||
TLS:
|
||||
ports: [443, 8443]
|
||||
# lite: no QUIC (fake-ip already gives the domain; pure-IP QUIC goes by IP)
|
||||
QUIC:
|
||||
ports: [443, 8443]
|
||||
|
||||
dns:
|
||||
enable: true
|
||||
ipv6: false
|
||||
respect-rules: true
|
||||
enhanced-mode: fake-ip
|
||||
fake-ip-range: 198.18.0.1/16
|
||||
fake-ip-filter:
|
||||
- '*.lan'
|
||||
- '*.local'
|
||||
- '+.ru'
|
||||
- '+.xn--p1ai'
|
||||
- rule-set:ru-inside
|
||||
# tailnet names: real 100.x addresses from MagicDNS (nameserver-policy below)
|
||||
- '+.ts.net'
|
||||
# own servers in the LAN (LOCAL_HOSTS): clients get the real LAN address
|
||||
- '+.sub2.example.com'
|
||||
- '+.lan-srv.example'
|
||||
|
||||
default-nameserver:
|
||||
- 77.88.8.8
|
||||
- 1.1.1.1
|
||||
|
||||
proxy-server-nameserver:
|
||||
- https://77.88.8.8/dns-query
|
||||
|
||||
direct-nameserver:
|
||||
- 77.88.8.8
|
||||
- 77.88.8.1
|
||||
|
||||
nameserver:
|
||||
- https://1.1.1.1/dns-query
|
||||
- https://dns.google/dns-query
|
||||
|
||||
# MagicDNS of the embedded Tailscale (the proxy named "tailscale")
|
||||
nameserver-policy:
|
||||
'+.ts.net': tailscale://tailscale
|
||||
|
||||
# LOCAL_HOSTS: own domains -> LAN addresses (dns.use-hosts is on by default), so neither
|
||||
# the core nor the clients go out to the white IP and back into the router itself
|
||||
hosts:
|
||||
'+.sub2.example.com': 192.168.64.20
|
||||
'+.lan-srv.example': 10.0.0.5
|
||||
|
||||
proxy-groups:
|
||||
# BOOT: whitelisted entry nodes (BOOT_LINKS), the first alive one
|
||||
- name: BOOT
|
||||
type: fallback
|
||||
proxies: [seed]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
# default for downloading subscriptions: BOOT (if set), else the nodes of the
|
||||
# saved subscriptions (providers are cached on disk), else direct. FOREIGN goes
|
||||
# before DIRECT: the health check of DIRECT (gstatic) passes in Russia even when
|
||||
# the subscription site itself is blocked.
|
||||
- name: BOOT-AUTO
|
||||
type: fallback
|
||||
proxies: [BOOT, FOREIGN, DIRECT]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
- name: RU
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
# lite: the provider's URL, so RU nodes are not tested a second time
|
||||
url: "https://ya.ru"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
- name: FOREIGN
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
exclude-filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
- name: TORRENT
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
filter: "(?i)torrent|\\[tor\\]"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 6000
|
||||
tolerance: 500
|
||||
max-failed-times: 5
|
||||
lazy: false
|
||||
|
||||
# url: what the dashboard's delay test opens through the tunnel;
|
||||
# interval 0: no background checks (they would redial with a stale code)
|
||||
- name: OPENVPN
|
||||
type: select
|
||||
use: [openvpn]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 0
|
||||
|
||||
# own servers: those of the settings (proxies/30-own_srv) and the "[MY] ..." nodes of
|
||||
# the subscriptions (providers <id>-my); the fastest alive one; pin one in the dashboard if needed
|
||||
- name: MY
|
||||
type: url-test
|
||||
proxies: ["🇩🇪 de 1", "tr \"q\"", "hy-own", "awg-own", "via-foreign", "home-hy"]
|
||||
use: [example-my, example2-my]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
# whitelist and mobile (my_exit): what own servers are reached through; switches only when the node is
|
||||
# clearly worse or dead (each switch breaks everything going through MY)
|
||||
|
||||
# url (TS_CHECK_URL, optional): a tailnet service for the dashboard's delay test
|
||||
- name: TAILSCALE
|
||||
type: select
|
||||
proxies: [tailscale]
|
||||
url: "http://100.69.216.50:8080"
|
||||
interval: 0
|
||||
|
||||
- name: MAIN
|
||||
type: select
|
||||
proxies: [FOREIGN, MY, RU, DIRECT]
|
||||
|
||||
- name: TORRENT-SEL
|
||||
type: select
|
||||
proxies: [TORRENT, FOREIGN, DIRECT]
|
||||
|
||||
- name: PUSH
|
||||
type: select
|
||||
proxies: [DIRECT, MY, FOREIGN]
|
||||
|
||||
rules:
|
||||
# Tailscale: tailnet IPs and MagicDNS names (resolved by tailscale itself)
|
||||
- IP-CIDR,100.64.0.0/10,TAILSCALE,no-resolve
|
||||
- DOMAIN-SUFFIX,ts.net,TAILSCALE
|
||||
|
||||
# the OpenVPN server itself (remote lines of the .ovpn) must not go into its own tunnel
|
||||
- IP-CIDR,203.0.113.10/32,DIRECT,no-resolve
|
||||
- DOMAIN,vpn.corp.example,DIRECT
|
||||
# the networks that go through the VPN (OVPN_ROUTES; before the private-range DIRECT
|
||||
# rules); a rule-provider so that ovpn.sh off can drop them without a restart
|
||||
- RULE-SET,openvpn-routes,OPENVPN,no-resolve
|
||||
|
||||
- IP-CIDR,192.168.0.0/16,DIRECT,no-resolve
|
||||
- IP-CIDR,10.0.0.0/8,DIRECT,no-resolve
|
||||
- IP-CIDR,172.16.0.0/12,DIRECT,no-resolve
|
||||
|
||||
# push notifications (Apple APNs, Google FCM): long-lived connections on a
|
||||
# stable path - group PUSH (main/foreign: DIRECT, whitelist: MY)
|
||||
- DOMAIN-SUFFIX,push.apple.com,PUSH
|
||||
- IP-CIDR,17.249.0.0/16,PUSH,no-resolve
|
||||
- IP-CIDR,17.252.0.0/16,PUSH,no-resolve
|
||||
- IP-CIDR,17.57.144.0/22,PUSH,no-resolve
|
||||
- IP-CIDR,17.188.128.0/18,PUSH,no-resolve
|
||||
- IP-CIDR,17.188.20.0/23,PUSH,no-resolve
|
||||
- DOMAIN-REGEX,^(alt[0-9]+-)?mtalk[0-9]*\.google\.com$,PUSH
|
||||
- DST-PORT,5228-5230,PUSH
|
||||
|
||||
# own lists from the settings: above torrents, ru-inside, .ru and MATCH; below the
|
||||
# tunnels, LAN and push. Domains (DOMAIN-SUFFIX: the domain and all subdomains)
|
||||
# before IPs; first match wins: MY, then FOREIGN, then RU.
|
||||
# RU on main (home, own white IP): reachable directly; whitelist/abroad: through RU
|
||||
# LOCAL_HOSTS: own servers in the LAN, before everything else
|
||||
- DOMAIN-SUFFIX,sub2.example.com,DIRECT
|
||||
- DOMAIN-SUFFIX,lan-srv.example,DIRECT
|
||||
- DOMAIN-SUFFIX,home.example,MY
|
||||
- DOMAIN-SUFFIX,api.example.com,FOREIGN
|
||||
- DOMAIN-SUFFIX,example.com,DIRECT
|
||||
- DOMAIN-SUFFIX,gosuslugi.example,DIRECT
|
||||
- DOMAIN-SUFFIX,bank.example,DIRECT
|
||||
- DOMAIN-SUFFIX,plain.example,DIRECT
|
||||
- IP-CIDR,10.8.0.0/24,MY
|
||||
- IP-CIDR,9.9.9.0/24,FOREIGN
|
||||
- IP-CIDR,2001:db8::1/128,FOREIGN
|
||||
- IP-CIDR,194.190.191.112/32,DIRECT
|
||||
- IP-CIDR,5.6.7.8/32,DIRECT
|
||||
|
||||
- SRC-PORT,20000-20199,TORRENT-SEL
|
||||
|
||||
- RULE-SET,ru-inside,DIRECT
|
||||
# main (home, own white IP): ru-services and .ru/.su/.рф directly; elsewhere through RU
|
||||
- RULE-SET,ru-services,DIRECT
|
||||
- DOMAIN-SUFFIX,ru,DIRECT
|
||||
- DOMAIN-SUFFIX,su,DIRECT
|
||||
- DOMAIN-SUFFIX,xn--p1ai,DIRECT
|
||||
- MATCH,MAIN
|
||||
@ -1,209 +0,0 @@
|
||||
proxy-providers:
|
||||
example:
|
||||
type: http
|
||||
url: "https://sub.example.com/sub/aaa"
|
||||
path: ./providers/example.yaml
|
||||
interval: 3600
|
||||
proxy: BOOT-AUTO
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
example2:
|
||||
type: http
|
||||
url: "https://sub2.example.com/x?a=1&b=2"
|
||||
path: ./providers/example2.yaml
|
||||
interval: 3600
|
||||
proxy: BOOT-AUTO
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
example-my:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
example2-my:
|
||||
type: file
|
||||
path: ./providers/example2.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
rule-providers:
|
||||
# Russian services (geosite ru-inside of russia-only, as .mrs): an ordinary
|
||||
# http rule-set, so every client fetches it with the config, no geodata setup
|
||||
ru-inside:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/ru-inside.mrs"
|
||||
path: ./ruleset/ru-inside.mrs
|
||||
interval: 86400
|
||||
# Russian services outside ru-inside and outside .ru/.su/.рф (russia-only ru-services):
|
||||
# not on the whitelist, so through RU everywhere but main
|
||||
ru-services:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/ru-services.mrs"
|
||||
path: ./ruleset/ru-services.mrs
|
||||
interval: 86400
|
||||
|
||||
sniffer:
|
||||
enable: true
|
||||
force-dns-mapping: true
|
||||
parse-pure-ip: true
|
||||
override-destination: false
|
||||
# ECH: browsers show the outer name cloudflare-ech.com instead of the site behind
|
||||
# Cloudflare; the sniffed name wins in the rules, so .ru / own lists would miss the
|
||||
# site. Skipped: the rules see the name from mihomo's DNS (fake-ip / DNS mapping).
|
||||
skip-domain:
|
||||
- "+.cloudflare-ech.com"
|
||||
sniff:
|
||||
HTTP:
|
||||
ports: [80, 8080-8880]
|
||||
TLS:
|
||||
ports: [443, 8443]
|
||||
# lite: no QUIC (fake-ip already gives the domain; pure-IP QUIC goes by IP)
|
||||
QUIC:
|
||||
ports: [443, 8443]
|
||||
|
||||
dns:
|
||||
enable: true
|
||||
ipv6: false
|
||||
respect-rules: true
|
||||
enhanced-mode: fake-ip
|
||||
fake-ip-range: 198.18.0.1/16
|
||||
fake-ip-filter:
|
||||
- '*.lan'
|
||||
- '*.local'
|
||||
- '+.ru'
|
||||
- '+.xn--p1ai'
|
||||
- rule-set:ru-inside
|
||||
|
||||
default-nameserver:
|
||||
- 77.88.8.8
|
||||
- 1.1.1.1
|
||||
|
||||
proxy-server-nameserver:
|
||||
- https://77.88.8.8/dns-query
|
||||
|
||||
direct-nameserver:
|
||||
- 77.88.8.8
|
||||
- 77.88.8.1
|
||||
|
||||
nameserver:
|
||||
- https://1.1.1.1/dns-query
|
||||
- https://dns.google/dns-query
|
||||
|
||||
proxy-groups:
|
||||
# default for downloading subscriptions: BOOT (if set), else the nodes of the
|
||||
# saved subscriptions (providers are cached on disk), else direct. FOREIGN goes
|
||||
# before DIRECT: the health check of DIRECT (gstatic) passes in Russia even when
|
||||
# the subscription site itself is blocked.
|
||||
- name: BOOT-AUTO
|
||||
type: fallback
|
||||
proxies: [FOREIGN, DIRECT]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
- name: RU
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
# lite: the provider's URL, so RU nodes are not tested a second time
|
||||
url: "https://ya.ru"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
- name: FOREIGN
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
exclude-filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
# own servers: those of the settings (proxies/30-own_srv) and the "[MY] ..." nodes of
|
||||
# the subscriptions (providers <id>-my); the fastest alive one; pin one in the dashboard if needed
|
||||
- name: MY
|
||||
type: url-test
|
||||
use: [example-my, example2-my]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
# whitelist and mobile (my_exit): what own servers are reached through; switches only when the node is
|
||||
# clearly worse or dead (each switch breaks everything going through MY)
|
||||
|
||||
- name: MAIN
|
||||
type: select
|
||||
proxies: [FOREIGN, MY, RU, DIRECT]
|
||||
|
||||
rules:
|
||||
- IP-CIDR,192.168.0.0/16,DIRECT,no-resolve
|
||||
- IP-CIDR,10.0.0.0/8,DIRECT,no-resolve
|
||||
- IP-CIDR,172.16.0.0/12,DIRECT,no-resolve
|
||||
|
||||
# own lists from the settings: above torrents, ru-inside, .ru and MATCH; below the
|
||||
# tunnels, LAN and push. Domains (DOMAIN-SUFFIX: the domain and all subdomains)
|
||||
# before IPs; first match wins: MY, then FOREIGN, then RU.
|
||||
# RU on main (home, own white IP): reachable directly; whitelist/abroad: through RU
|
||||
- DOMAIN-SUFFIX,home.example,MY
|
||||
- IP-CIDR,9.9.9.9/32,FOREIGN
|
||||
|
||||
- RULE-SET,ru-inside,DIRECT
|
||||
# main (home, own white IP): ru-services and .ru/.su/.рф directly; elsewhere through RU
|
||||
- RULE-SET,ru-services,DIRECT
|
||||
- DOMAIN-SUFFIX,ru,DIRECT
|
||||
- DOMAIN-SUFFIX,su,DIRECT
|
||||
- DOMAIN-SUFFIX,xn--p1ai,DIRECT
|
||||
- MATCH,MAIN
|
||||
@ -1,366 +0,0 @@
|
||||
proxies:
|
||||
- name: seed
|
||||
type: vless
|
||||
server: 1.2.3.4
|
||||
port: 443
|
||||
uuid: 00000000-0000-0000-0000-000000000000
|
||||
network: tcp
|
||||
udp: true
|
||||
tls: true
|
||||
flow: xtls-rprx-vision
|
||||
servername: eh.vk.ru
|
||||
client-fingerprint: firefox
|
||||
reality-opts:
|
||||
public-key: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
short-id: a1b2
|
||||
|
||||
proxy-providers:
|
||||
example:
|
||||
type: http
|
||||
url: "https://sub.example.com/sub/aaa"
|
||||
path: ./providers/example.yaml
|
||||
interval: 3600
|
||||
proxy: BOOT-AUTO
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
example2:
|
||||
type: http
|
||||
url: "https://sub2.example.com/x?a=1&b=2"
|
||||
path: ./providers/example2.yaml
|
||||
interval: 3600
|
||||
proxy: BOOT-AUTO
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
example-my:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
exclude-filter: "^(\\[MY\\] 🇩🇪 de-1 \\(a\\)|\\[MY\\] nl\\.2)$"
|
||||
override:
|
||||
dialer-proxy: MY-EXIT
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
example2-my:
|
||||
type: file
|
||||
path: ./providers/example2.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
exclude-filter: "^(\\[MY\\] fi\\x603)$"
|
||||
override:
|
||||
dialer-proxy: MY-EXIT
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# [MY] nodes of example with an entry of their own (LuCI «Свои серверы» → «Вход»):
|
||||
# out of example-my, dialing through FOREIGN in every profile
|
||||
example-my-via-FOREIGN:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
filter: "^(\\[MY\\] 🇩🇪 de-1 \\(a\\)|\\[MY\\] nl\\.2)$"
|
||||
override:
|
||||
dialer-proxy: FOREIGN
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# [MY] nodes of example2 with an entry of their own (LuCI «Свои серверы» → «Вход»):
|
||||
# out of example2-my, dialing through DE in every profile
|
||||
example2-my-via-DE:
|
||||
type: file
|
||||
path: ./providers/example2.yaml
|
||||
filter: "^(\\[MY\\] fi\\x603)$"
|
||||
override:
|
||||
dialer-proxy: DE
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# example-my for the chains through RU: the same nodes, named "... ⟶ RU"
|
||||
example-my@RU:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
override:
|
||||
additional-suffix: " ⟶ RU"
|
||||
dialer-proxy: RU
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
rule-providers:
|
||||
# Russian services (geosite ru-inside of russia-only, as .mrs): an ordinary
|
||||
# http rule-set, so every client fetches it with the config, no geodata setup
|
||||
ru-inside:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/ru-inside.mrs"
|
||||
path: ./ruleset/ru-inside.mrs
|
||||
interval: 86400
|
||||
# Russian services outside ru-inside and outside .ru/.su/.рф (russia-only ru-services):
|
||||
# not on the whitelist, so through RU everywhere but main
|
||||
ru-services:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/ru-services.mrs"
|
||||
path: ./ruleset/ru-services.mrs
|
||||
interval: 86400
|
||||
|
||||
sniffer:
|
||||
enable: true
|
||||
force-dns-mapping: true
|
||||
parse-pure-ip: true
|
||||
override-destination: false
|
||||
# ECH: browsers show the outer name cloudflare-ech.com instead of the site behind
|
||||
# Cloudflare; the sniffed name wins in the rules, so .ru / own lists would miss the
|
||||
# site. Skipped: the rules see the name from mihomo's DNS (fake-ip / DNS mapping).
|
||||
skip-domain:
|
||||
- "+.cloudflare-ech.com"
|
||||
sniff:
|
||||
HTTP:
|
||||
ports: [80, 8080-8880]
|
||||
TLS:
|
||||
ports: [443, 8443]
|
||||
# lite: no QUIC (fake-ip already gives the domain; pure-IP QUIC goes by IP)
|
||||
QUIC:
|
||||
ports: [443, 8443]
|
||||
|
||||
dns:
|
||||
enable: true
|
||||
ipv6: false
|
||||
respect-rules: true
|
||||
enhanced-mode: fake-ip
|
||||
fake-ip-range: 198.18.0.1/16
|
||||
fake-ip-filter:
|
||||
- '*.lan'
|
||||
- '*.local'
|
||||
- '+.ru'
|
||||
- '+.xn--p1ai'
|
||||
- rule-set:ru-inside
|
||||
|
||||
default-nameserver:
|
||||
- 77.88.8.8
|
||||
- 1.1.1.1
|
||||
|
||||
proxy-server-nameserver:
|
||||
- https://77.88.8.8/dns-query
|
||||
|
||||
direct-nameserver:
|
||||
- 77.88.8.8
|
||||
- 77.88.8.1
|
||||
|
||||
nameserver:
|
||||
- https://1.1.1.1/dns-query
|
||||
- https://dns.google/dns-query
|
||||
|
||||
proxy-groups:
|
||||
# BOOT: whitelisted entry nodes (BOOT_LINKS), the first alive one
|
||||
- name: BOOT
|
||||
type: fallback
|
||||
proxies: [seed]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
# default for downloading subscriptions: BOOT (if set), else the nodes of the
|
||||
# saved subscriptions (providers are cached on disk), else direct. FOREIGN goes
|
||||
# before DIRECT: the health check of DIRECT (gstatic) passes in Russia even when
|
||||
# the subscription site itself is blocked.
|
||||
- name: BOOT-AUTO
|
||||
type: fallback
|
||||
proxies: [BOOT, FOREIGN, DIRECT]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
- name: RU
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
# lite: the provider's URL, so RU nodes are not tested a second time
|
||||
url: "https://ya.ru"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
- name: FOREIGN
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
exclude-filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
- name: TORRENT
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
filter: "(?i)torrent|\\[tor\\]"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 6000
|
||||
tolerance: 500
|
||||
max-failed-times: 5
|
||||
lazy: false
|
||||
|
||||
# pool de (POOLS, POOL_*): own servers and subscription nodes picked in the settings;
|
||||
# filter / exclude-filter apply to the subscriptions' nodes only
|
||||
- name: DE
|
||||
type: fallback
|
||||
use: [example]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
# pool mix (POOLS, POOL_*): own servers and subscription nodes picked in the settings;
|
||||
# filter / exclude-filter apply to the subscriptions' nodes only
|
||||
- name: MIX
|
||||
type: fallback
|
||||
use: [example-my, example-my-via-FOREIGN]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
# pool svc-fixed-claude (POOLS, POOL_*): own servers and subscription nodes picked in the settings;
|
||||
# filter / exclude-filter apply to the subscriptions' nodes only
|
||||
- name: SVC-FIXED-CLAUDE
|
||||
type: select
|
||||
empty-fallback: REJECT
|
||||
use: [example-my, example-my-via-FOREIGN]
|
||||
filter: "^\\[MY\\] nl\\.2$"
|
||||
|
||||
# own servers: those of the settings (proxies/30-own_srv) and the "[MY] ..." nodes of
|
||||
# the subscriptions (providers <id>-my); the fastest alive one; pin one in the dashboard if needed
|
||||
- name: MY
|
||||
type: url-test
|
||||
use: [example-my, example-my-via-FOREIGN, example2-my, example2-my-via-DE]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
# whitelist and mobile (my_exit): what own servers are reached through; switches only when the node is
|
||||
# clearly worse or dead (each switch breaks everything going through MY)
|
||||
- name: MY-EXIT
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
exclude-filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 300
|
||||
lazy: false
|
||||
|
||||
# service claude (SERVICES, SVC_*): its own way, whatever MAIN is
|
||||
- name: CLAUDE
|
||||
type: select
|
||||
proxies: ["SVC-FIXED-CLAUDE ⟶ RU"]
|
||||
|
||||
# SVC-FIXED-CLAUDE through RU (SVC_<NAME>_CHAIN, POOL_<NAME>_UPLINK): its servers and
|
||||
# nodes, each dialing through RU
|
||||
- name: "SVC-FIXED-CLAUDE ⟶ RU"
|
||||
type: select
|
||||
empty-fallback: REJECT
|
||||
use: [example-my@RU]
|
||||
filter: "^\\[MY\\] nl\\.2 ⟶ RU$"
|
||||
|
||||
- name: MAIN
|
||||
type: select
|
||||
proxies: [FOREIGN, MY, RU, DIRECT]
|
||||
|
||||
- name: TORRENT-SEL
|
||||
type: select
|
||||
proxies: [TORRENT, FOREIGN, DIRECT]
|
||||
|
||||
- name: PUSH
|
||||
type: select
|
||||
# no own servers in the settings: MY may be empty (no [MY] nodes in the subscriptions)
|
||||
proxies: [FOREIGN, MY, DIRECT]
|
||||
|
||||
rules:
|
||||
- IP-CIDR,192.168.0.0/16,DIRECT,no-resolve
|
||||
- IP-CIDR,10.0.0.0/8,DIRECT,no-resolve
|
||||
- IP-CIDR,172.16.0.0/12,DIRECT,no-resolve
|
||||
|
||||
# push notifications (Apple APNs, Google FCM): long-lived connections on a
|
||||
# stable path - group PUSH (main/foreign: DIRECT, whitelist: MY)
|
||||
- DOMAIN-SUFFIX,push.apple.com,PUSH
|
||||
- IP-CIDR,17.249.0.0/16,PUSH,no-resolve
|
||||
- IP-CIDR,17.252.0.0/16,PUSH,no-resolve
|
||||
- IP-CIDR,17.57.144.0/22,PUSH,no-resolve
|
||||
- IP-CIDR,17.188.128.0/18,PUSH,no-resolve
|
||||
- IP-CIDR,17.188.20.0/23,PUSH,no-resolve
|
||||
- DOMAIN-REGEX,^(alt[0-9]+-)?mtalk[0-9]*\.google\.com$,PUSH
|
||||
- DST-PORT,5228-5230,PUSH
|
||||
|
||||
# service claude: above the own lists, below the tunnels, LAN and push
|
||||
- DOMAIN-SUFFIX,claude.ai,CLAUDE
|
||||
|
||||
# own lists from the settings: above torrents, ru-inside, .ru and MATCH; below the
|
||||
# tunnels, LAN and push. Domains (DOMAIN-SUFFIX: the domain and all subdomains)
|
||||
# before IPs; first match wins: MY, then FOREIGN, then RU.
|
||||
# RU on main (home, own white IP): reachable directly; whitelist/abroad: through RU
|
||||
- IP-CIDR,194.190.191.112/32,RU
|
||||
|
||||
- SRC-PORT,20000-20199,TORRENT-SEL
|
||||
|
||||
- RULE-SET,ru-inside,DIRECT
|
||||
# main (home, own white IP): ru-services and .ru/.su/.рф directly; elsewhere through RU
|
||||
- RULE-SET,ru-services,RU
|
||||
- DOMAIN-SUFFIX,ru,RU
|
||||
- DOMAIN-SUFFIX,su,RU
|
||||
- DOMAIN-SUFFIX,xn--p1ai,RU
|
||||
- MATCH,MAIN
|
||||
@ -1,569 +0,0 @@
|
||||
proxies:
|
||||
- name: seed
|
||||
type: vless
|
||||
server: 1.2.3.4
|
||||
port: 443
|
||||
uuid: 00000000-0000-0000-0000-000000000000
|
||||
network: tcp
|
||||
udp: true
|
||||
tls: true
|
||||
flow: xtls-rprx-vision
|
||||
servername: eh.vk.ru
|
||||
client-fingerprint: firefox
|
||||
reality-opts:
|
||||
public-key: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
short-id: a1b2
|
||||
dialer-proxy: UPLINK
|
||||
|
||||
# Tailscale: userspace node, starts on first use. First login: open the URL
|
||||
# from the nikki log ("To start this tsnet server ... go to: ..."), then
|
||||
# disable key expiry for this node. Needs TS_FORCE_NOISE_443=true in the
|
||||
# mihomo environment (mihomo-kit.sh fix).
|
||||
- name: tailscale
|
||||
type: tailscale
|
||||
hostname: test-mihomo
|
||||
state-dir: ./tailscale
|
||||
udp: true
|
||||
accept-routes: true
|
||||
# whitelist: control and DERP over TCP through own servers (MY -> own node -> MY-EXIT);
|
||||
# MY holds hysteria2 from the settings and "[MY]" nodes of the subscriptions; empty MY is direct
|
||||
# needs the kit's core (v1.19.32-ts1, tools/core/*.patch, MetaCubeX/mihomo#3142)
|
||||
dialer-proxy: MY
|
||||
|
||||
# own servers of the settings (LuCI "Свои серверы", /etc/nikki/my-servers): one JSON
|
||||
# proxy per line, as mihomo's own config would have it; the kit puts dialer-proxy in
|
||||
# front: whitelist and the phone through MY-EXIT, else with UPLINK (CSQTT, pools) through it.
|
||||
# A server with an entry of its own (LuCI "Вход") keeps it in every profile
|
||||
- {"dialer-proxy": "MY-EXIT", "name":"🇩🇪 de 1","type":"vless","server":"x.example.com","port":"443","uuid":"00000000-0000-0000-0000-000000000001","udp":true,"tls":true,"client-fingerprint":"chrome","servername":"www.example.com","reality-opts":{"public-key":"Nc9ZSDuQMwHN4M6TeDHjfJhgZ6SBTBbfMwx5iHQZ1ns","short-id":"ab"},"xudp":true,"network":"xhttp","xhttp-opts":{"path":"/x"}}
|
||||
- {"dialer-proxy": "MY-EXIT", "name":"tr \"q\"","type":"trojan","server":"t.example.org","port":"443","password":"p\u0024w","udp":true,"skip-cert-verify":false,"sni":"t.example.org","network":"grpc","grpc-opts":{"grpc-service-name":"g"},"client-fingerprint":"chrome"}
|
||||
- {"dialer-proxy": "MY-EXIT", "name":"hy-own","type":"hysteria2","server":"h.example.net","port":8443,"password":"a\u0024b","obfs":"salamander","obfs-password":"o","up":"50 mbps"}
|
||||
- {"dialer-proxy": "MY-EXIT", "name":"awg-own","type":"wireguard","server":"203.0.113.10","port":47613,"ip":"10.8.1.2","private-key":"fTo2df+b5vCuulh7pOXMWiWJY2VwSe2Kuup2nA34tfI=","public-key":"vGYpG72gCXPNfYzr/0iNfSoL83vbrVSGUC+v+MKRVyE=","pre-shared-key":"6ut/J6EuaJ97RMFcZuiJkzIo7a5uxR98htK5NdWJW6E=","persistent-keepalive":25,"udp":true,"amnezia-wg-option":{"jc":4,"jmin":10,"jmax":50,"s1":98,"s2":32,"s3":19,"s4":7,"h1":"1458367412-1593426716","h2":"1863071624-1902347825","h3":"2091548318-2097143921","h4":"2112573893-2147191025","i1":"<r 2><b 0x858000010001000000000669636c6f756403636f6d0000010001c00c000100010000105a00044d583737>"}}
|
||||
- {"name":"via-foreign","type":"ss","server":"f.example.com","port":8388,"cipher":"aes-256-gcm","password":"x","dialer-proxy":"FOREIGN"}
|
||||
|
||||
# copies of own servers for the chains (SVC_<NAME>_CHAIN, POOL_<NAME>_UPLINK): the same
|
||||
# server dialing through another entry, named "<server> ⟶ <entry>" (group "<pool> ⟶ <entry>")
|
||||
- {"dialer-proxy": "WL", "name":"🇩🇪 de 1 ⟶ WL","type":"vless","server":"x.example.com","port":"443","uuid":"00000000-0000-0000-0000-000000000001","udp":true,"tls":true,"client-fingerprint":"chrome","servername":"www.example.com","reality-opts":{"public-key":"Nc9ZSDuQMwHN4M6TeDHjfJhgZ6SBTBbfMwx5iHQZ1ns","short-id":"ab"},"xudp":true,"network":"xhttp","xhttp-opts":{"path":"/x"}}
|
||||
- {"dialer-proxy": "WL", "name":"hy-own ⟶ WL","type":"hysteria2","server":"h.example.net","port":8443,"password":"a\u0024b","obfs":"salamander","obfs-password":"o","up":"50 mbps"}
|
||||
- {"dialer-proxy": "FOREIGN", "name":"🇩🇪 de 1 ⟶ FOREIGN","type":"vless","server":"x.example.com","port":"443","uuid":"00000000-0000-0000-0000-000000000001","udp":true,"tls":true,"client-fingerprint":"chrome","servername":"www.example.com","reality-opts":{"public-key":"Nc9ZSDuQMwHN4M6TeDHjfJhgZ6SBTBbfMwx5iHQZ1ns","short-id":"ab"},"xudp":true,"network":"xhttp","xhttp-opts":{"path":"/x"}}
|
||||
- {"dialer-proxy": "FOREIGN", "name":"tr \"q\" ⟶ FOREIGN","type":"trojan","server":"t.example.org","port":"443","password":"p\u0024w","udp":true,"skip-cert-verify":false,"sni":"t.example.org","network":"grpc","grpc-opts":{"grpc-service-name":"g"},"client-fingerprint":"chrome"}
|
||||
- {"dialer-proxy": "FOREIGN", "name":"hy-own ⟶ FOREIGN","type":"hysteria2","server":"h.example.net","port":8443,"password":"a\u0024b","obfs":"salamander","obfs-password":"o","up":"50 mbps"}
|
||||
- {"dialer-proxy": "FOREIGN", "name":"awg-own ⟶ FOREIGN","type":"wireguard","server":"203.0.113.10","port":47613,"ip":"10.8.1.2","private-key":"fTo2df+b5vCuulh7pOXMWiWJY2VwSe2Kuup2nA34tfI=","public-key":"vGYpG72gCXPNfYzr/0iNfSoL83vbrVSGUC+v+MKRVyE=","pre-shared-key":"6ut/J6EuaJ97RMFcZuiJkzIo7a5uxR98htK5NdWJW6E=","persistent-keepalive":25,"udp":true,"amnezia-wg-option":{"jc":4,"jmin":10,"jmax":50,"s1":98,"s2":32,"s3":19,"s4":7,"h1":"1458367412-1593426716","h2":"1863071624-1902347825","h3":"2091548318-2097143921","h4":"2112573893-2147191025","i1":"<r 2><b 0x858000010001000000000669636c6f756403636f6d0000010001c00c000100010000105a00044d583737>"}}
|
||||
- {"dialer-proxy": "FOREIGN", "name":"via-foreign ⟶ FOREIGN","type":"ss","server":"f.example.com","port":8388,"cipher":"aes-256-gcm","password":"x"}
|
||||
|
||||
proxy-providers:
|
||||
example:
|
||||
type: http
|
||||
url: "https://sub.example.com/sub/aaa"
|
||||
path: ./providers/example.yaml
|
||||
interval: 3600
|
||||
proxy: BOOT-AUTO
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
override:
|
||||
dialer-proxy: UPLINK
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
example2:
|
||||
type: http
|
||||
url: "https://sub2.example.com/x?a=1&b=2"
|
||||
path: ./providers/example2.yaml
|
||||
interval: 3600
|
||||
proxy: BOOT-AUTO
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
override:
|
||||
dialer-proxy: UPLINK
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
example-my:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
override:
|
||||
dialer-proxy: MY-EXIT
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
example2-my:
|
||||
type: file
|
||||
path: ./providers/example2.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
override:
|
||||
dialer-proxy: MY-EXIT
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# own servers as links (MY_LINKS, LuCI "Свои серверы (ссылки)"): kit writes them to
|
||||
# this file on build, mihomo parses vless/vmess/trojan/ss/hysteria2/tuic/anytls links
|
||||
# like a subscription; group MY, named "[MY] ..." like the [MY] nodes of the subscriptions
|
||||
my-links:
|
||||
type: file
|
||||
path: ./providers/my-links.txt
|
||||
override:
|
||||
additional-prefix: "[MY] "
|
||||
dialer-proxy: MY-EXIT
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# example for the chains through DIRECT: the same nodes, named "... ⟶ DIRECT"
|
||||
example@DIRECT:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
override:
|
||||
additional-suffix: " ⟶ DIRECT"
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# example for the chains through WL: the same nodes, named "... ⟶ WL"
|
||||
example@WL:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
override:
|
||||
additional-suffix: " ⟶ WL"
|
||||
dialer-proxy: WL
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# example2-my for the chains through WL: the same nodes, named "... ⟶ WL"
|
||||
example2-my@WL:
|
||||
type: file
|
||||
path: ./providers/example2.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
override:
|
||||
additional-suffix: " ⟶ WL"
|
||||
dialer-proxy: WL
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# example-my for the chains through FOREIGN: the same nodes, named "... ⟶ FOREIGN"
|
||||
example-my@FOREIGN:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
override:
|
||||
additional-suffix: " ⟶ FOREIGN"
|
||||
dialer-proxy: FOREIGN
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# example2-my for the chains through FOREIGN: the same nodes, named "... ⟶ FOREIGN"
|
||||
example2-my@FOREIGN:
|
||||
type: file
|
||||
path: ./providers/example2.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
override:
|
||||
additional-suffix: " ⟶ FOREIGN"
|
||||
dialer-proxy: FOREIGN
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# my-links for the chains through FOREIGN: the same nodes, named "... ⟶ FOREIGN"
|
||||
my-links@FOREIGN:
|
||||
type: file
|
||||
path: ./providers/my-links.txt
|
||||
override:
|
||||
additional-prefix: "[MY] "
|
||||
additional-suffix: " ⟶ FOREIGN"
|
||||
dialer-proxy: FOREIGN
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
rule-providers:
|
||||
# Russian services (geosite ru-inside of russia-only, as .mrs): an ordinary
|
||||
# http rule-set, so every client fetches it with the config, no geodata setup
|
||||
ru-inside:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/ru-inside.mrs"
|
||||
path: ./ruleset/ru-inside.mrs
|
||||
interval: 86400
|
||||
# Russian services outside ru-inside and outside .ru/.su/.рф (russia-only ru-services):
|
||||
# not on the whitelist, so through RU everywhere but main
|
||||
ru-services:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/ru-services.mrs"
|
||||
path: ./ruleset/ru-services.mrs
|
||||
interval: 86400
|
||||
|
||||
# services (SERVICES): geosite list anthropic of MetaCubeX/meta-rules-dat
|
||||
geosite-anthropic:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@meta/geo/geosite/anthropic.mrs"
|
||||
path: ./ruleset/geosite-anthropic.mrs
|
||||
interval: 86400
|
||||
|
||||
# services (SERVICES): geosite list openai of MetaCubeX/meta-rules-dat
|
||||
geosite-openai:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@meta/geo/geosite/openai.mrs"
|
||||
path: ./ruleset/geosite-openai.mrs
|
||||
interval: 86400
|
||||
|
||||
# service yt: domains of its hostlists (SVC_<NAME>_HOSTLIST, e.g. zapret's
|
||||
# /opt/zapret2/ipset/*.txt), read when the profile is built: rebuild to pick up changes
|
||||
hostlist-yt:
|
||||
type: inline
|
||||
behavior: domain
|
||||
payload:
|
||||
- "+.youtube.com"
|
||||
- "+.youtu.be"
|
||||
- "+.googlevideo.com"
|
||||
- "exact.example"
|
||||
- "+.wild.example"
|
||||
- "+.dot.example"
|
||||
- "+.ggpht.com"
|
||||
|
||||
sniffer:
|
||||
enable: true
|
||||
force-dns-mapping: true
|
||||
parse-pure-ip: true
|
||||
override-destination: false
|
||||
# ECH: browsers show the outer name cloudflare-ech.com instead of the site behind
|
||||
# Cloudflare; the sniffed name wins in the rules, so .ru / own lists would miss the
|
||||
# site. Skipped: the rules see the name from mihomo's DNS (fake-ip / DNS mapping).
|
||||
skip-domain:
|
||||
- "+.cloudflare-ech.com"
|
||||
sniff:
|
||||
HTTP:
|
||||
ports: [80, 8080-8880]
|
||||
TLS:
|
||||
ports: [443, 8443]
|
||||
# lite: no QUIC (fake-ip already gives the domain; pure-IP QUIC goes by IP)
|
||||
QUIC:
|
||||
ports: [443, 8443]
|
||||
|
||||
dns:
|
||||
enable: true
|
||||
ipv6: false
|
||||
respect-rules: true
|
||||
enhanced-mode: fake-ip
|
||||
fake-ip-range: 198.18.0.1/16
|
||||
fake-ip-filter:
|
||||
- '*.lan'
|
||||
- '*.local'
|
||||
- '+.ru'
|
||||
- '+.xn--p1ai'
|
||||
- rule-set:ru-inside
|
||||
# tailnet names: real 100.x addresses from MagicDNS (nameserver-policy below)
|
||||
- '+.ts.net'
|
||||
|
||||
default-nameserver:
|
||||
- 77.88.8.8
|
||||
- 1.1.1.1
|
||||
|
||||
proxy-server-nameserver:
|
||||
- https://77.88.8.8/dns-query
|
||||
|
||||
direct-nameserver:
|
||||
- 77.88.8.8
|
||||
- 77.88.8.1
|
||||
|
||||
nameserver:
|
||||
- https://1.1.1.1/dns-query
|
||||
- https://dns.google/dns-query
|
||||
|
||||
# MagicDNS of the embedded Tailscale (the proxy named "tailscale")
|
||||
nameserver-policy:
|
||||
'+.ts.net': tailscale://tailscale
|
||||
|
||||
proxy-groups:
|
||||
# BOOT: whitelisted entry nodes (BOOT_LINKS), the first alive one
|
||||
- name: BOOT
|
||||
type: fallback
|
||||
proxies: [seed]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
# default for downloading subscriptions: BOOT (if set), else the nodes of the
|
||||
# saved subscriptions (providers are cached on disk), else direct. FOREIGN goes
|
||||
# before DIRECT: the health check of DIRECT (gstatic) passes in Russia even when
|
||||
# the subscription site itself is blocked.
|
||||
- name: BOOT-AUTO
|
||||
type: fallback
|
||||
proxies: [BOOT, FOREIGN, DIRECT]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
- name: RU
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
# lite: the provider's URL, so RU nodes are not tested a second time
|
||||
url: "https://ya.ru"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
- name: FOREIGN
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
exclude-filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
- name: TORRENT
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
filter: "(?i)torrent|\\[tor\\]"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 6000
|
||||
tolerance: 500
|
||||
max-failed-times: 5
|
||||
lazy: false
|
||||
|
||||
# pool de (POOLS, POOL_*): own servers and subscription nodes picked in the settings;
|
||||
# filter / exclude-filter apply to the subscriptions' nodes only
|
||||
- name: DE
|
||||
type: url-test
|
||||
proxies: ["🇩🇪 de 1", "hy-own"]
|
||||
use: [example, example2-my]
|
||||
filter: "(?i)🇩🇪|\\bde\\b"
|
||||
exclude-filter: "(?i)tor"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
# pool gone (POOLS, POOL_*): own servers and subscription nodes picked in the settings;
|
||||
# filter / exclude-filter apply to the subscriptions' nodes only
|
||||
- name: GONE
|
||||
type: select
|
||||
proxies: [REJECT]
|
||||
|
||||
# pool wl (POOLS, POOL_*): own servers and subscription nodes picked in the settings;
|
||||
# filter / exclude-filter apply to the subscriptions' nodes only
|
||||
- name: WL
|
||||
type: fallback
|
||||
use: [example]
|
||||
filter: "\\[WL\\]"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
# own servers: those of the settings (proxies/30-own_srv) and the "[MY] ..." nodes of
|
||||
# the subscriptions (providers <id>-my); the fastest alive one; pin one in the dashboard if needed
|
||||
- name: MY
|
||||
type: url-test
|
||||
proxies: ["🇩🇪 de 1", "tr \"q\"", "hy-own", "awg-own", "via-foreign"]
|
||||
use: [example-my, example2-my, my-links]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
# whitelist and mobile (my_exit): what own servers are reached through; switches only when the node is
|
||||
# clearly worse or dead (each switch breaks everything going through MY)
|
||||
- name: MY-EXIT
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
exclude-filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 300
|
||||
lazy: false
|
||||
|
||||
# service claude (SERVICES, SVC_*): its own way, whatever MAIN is
|
||||
- name: CLAUDE
|
||||
type: select
|
||||
proxies: ["DE ⟶ WL", DE, MY, FOREIGN, RU, DIRECT]
|
||||
|
||||
# service chat (SERVICES, SVC_*): its own way, whatever MAIN is
|
||||
- name: CHAT
|
||||
type: select
|
||||
proxies: ["MY ⟶ FOREIGN", MY, FOREIGN, RU, DIRECT]
|
||||
|
||||
# service yt (SERVICES, SVC_*): its own way, whatever MAIN is
|
||||
- name: YT
|
||||
type: select
|
||||
proxies: [RU, MY, FOREIGN, DIRECT]
|
||||
|
||||
# WL through DIRECT (SVC_<NAME>_CHAIN, POOL_<NAME>_UPLINK): its servers and
|
||||
# nodes, each dialing through DIRECT
|
||||
- name: "WL ⟶ DIRECT"
|
||||
type: fallback
|
||||
use: [example@DIRECT]
|
||||
filter: "\\[WL\\]"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
# DE through WL (SVC_<NAME>_CHAIN, POOL_<NAME>_UPLINK): its servers and
|
||||
# nodes, each dialing through WL
|
||||
- name: "DE ⟶ WL"
|
||||
type: url-test
|
||||
proxies: ["🇩🇪 de 1 ⟶ WL", "hy-own ⟶ WL"]
|
||||
use: [example@WL, example2-my@WL]
|
||||
filter: "(?i)🇩🇪|\\bde\\b"
|
||||
exclude-filter: "(?i)tor"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
# MY through FOREIGN (SVC_<NAME>_CHAIN, POOL_<NAME>_UPLINK): its servers and
|
||||
# nodes, each dialing through FOREIGN
|
||||
- name: "MY ⟶ FOREIGN"
|
||||
type: fallback
|
||||
proxies: ["🇩🇪 de 1 ⟶ FOREIGN", "tr \"q\" ⟶ FOREIGN", "hy-own ⟶ FOREIGN", "awg-own ⟶ FOREIGN", "via-foreign ⟶ FOREIGN"]
|
||||
use: [example-my@FOREIGN, example2-my@FOREIGN, my-links@FOREIGN]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
# url (TS_CHECK_URL, optional): a tailnet service for the dashboard's delay test
|
||||
- name: TAILSCALE
|
||||
type: select
|
||||
proxies: [tailscale]
|
||||
url: "http://100.69.216.50:8080"
|
||||
interval: 0
|
||||
|
||||
# UPLINK: what the subscription nodes, BOOT seeds and own servers connect
|
||||
# through. DIRECT - as before; CSQTT - through csqtt0 first (out of the
|
||||
# whitelist); a pool (POOL_<NAME>_UPLINK=1) - through its servers, they themselves
|
||||
# direct; then FOREIGN / MY / RU work on top of it as usual.
|
||||
# On whitelist own servers go MY-EXIT -> node -> UPLINK.
|
||||
- name: UPLINK
|
||||
type: select
|
||||
proxies: [DIRECT, "WL ⟶ DIRECT"]
|
||||
|
||||
- name: MAIN
|
||||
type: select
|
||||
proxies: [FOREIGN, MY, RU, DIRECT]
|
||||
|
||||
- name: TORRENT-SEL
|
||||
type: select
|
||||
proxies: [TORRENT, FOREIGN, DIRECT]
|
||||
|
||||
- name: PUSH
|
||||
type: select
|
||||
proxies: [MY, FOREIGN, DIRECT]
|
||||
|
||||
rules:
|
||||
# Tailscale: tailnet IPs and MagicDNS names (resolved by tailscale itself)
|
||||
- IP-CIDR,100.64.0.0/10,TAILSCALE,no-resolve
|
||||
- DOMAIN-SUFFIX,ts.net,TAILSCALE
|
||||
|
||||
- IP-CIDR,192.168.0.0/16,DIRECT,no-resolve
|
||||
- IP-CIDR,10.0.0.0/8,DIRECT,no-resolve
|
||||
- IP-CIDR,172.16.0.0/12,DIRECT,no-resolve
|
||||
|
||||
# push notifications (Apple APNs, Google FCM): long-lived connections on a
|
||||
# stable path - group PUSH (main/foreign: DIRECT, whitelist: MY)
|
||||
- DOMAIN-SUFFIX,push.apple.com,PUSH
|
||||
- IP-CIDR,17.249.0.0/16,PUSH,no-resolve
|
||||
- IP-CIDR,17.252.0.0/16,PUSH,no-resolve
|
||||
- IP-CIDR,17.57.144.0/22,PUSH,no-resolve
|
||||
- IP-CIDR,17.188.128.0/18,PUSH,no-resolve
|
||||
- IP-CIDR,17.188.20.0/23,PUSH,no-resolve
|
||||
- DOMAIN-REGEX,^(alt[0-9]+-)?mtalk[0-9]*\.google\.com$,PUSH
|
||||
- DST-PORT,5228-5230,PUSH
|
||||
|
||||
# service claude: above the own lists, below the tunnels, LAN and push
|
||||
- RULE-SET,geosite-anthropic,CLAUDE
|
||||
- DOMAIN-SUFFIX,claude.example,CLAUDE
|
||||
|
||||
# service chat: above the own lists, below the tunnels, LAN and push
|
||||
- RULE-SET,geosite-openai,CHAT
|
||||
- RULE-SET,geosite-anthropic,CHAT
|
||||
- IP-CIDR,1.2.3.4/32,CHAT
|
||||
|
||||
# service yt: above the own lists, below the tunnels, LAN and push
|
||||
- RULE-SET,hostlist-yt,YT
|
||||
|
||||
# own lists from the settings: above torrents, ru-inside, .ru and MATCH; below the
|
||||
# tunnels, LAN and push. Domains (DOMAIN-SUFFIX: the domain and all subdomains)
|
||||
# before IPs; first match wins: MY, then FOREIGN, then RU.
|
||||
# RU on main (home, own white IP): reachable directly; whitelist/abroad: through RU
|
||||
- IP-CIDR,194.190.191.112/32,RU
|
||||
|
||||
- SRC-PORT,20000-20199,TORRENT-SEL
|
||||
|
||||
- RULE-SET,ru-inside,DIRECT
|
||||
# main (home, own white IP): ru-services and .ru/.su/.рф directly; elsewhere through RU
|
||||
- RULE-SET,ru-services,RU
|
||||
- DOMAIN-SUFFIX,ru,RU
|
||||
- DOMAIN-SUFFIX,su,RU
|
||||
- DOMAIN-SUFFIX,xn--p1ai,RU
|
||||
- MATCH,MAIN
|
||||
@ -1,316 +0,0 @@
|
||||
proxies:
|
||||
- name: seed
|
||||
type: vless
|
||||
server: 1.2.3.4
|
||||
port: 443
|
||||
uuid: 00000000-0000-0000-0000-000000000000
|
||||
network: tcp
|
||||
udp: true
|
||||
tls: true
|
||||
flow: xtls-rprx-vision
|
||||
servername: eh.vk.ru
|
||||
client-fingerprint: firefox
|
||||
reality-opts:
|
||||
public-key: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
short-id: a1b2
|
||||
|
||||
# Tailscale: userspace node, starts on first use. First login: open the URL
|
||||
# from the nikki log ("To start this tsnet server ... go to: ..."), then
|
||||
# disable key expiry for this node. Needs TS_FORCE_NOISE_443=true in the
|
||||
# mihomo environment (mihomo-kit.sh fix).
|
||||
- name: tailscale
|
||||
type: tailscale
|
||||
hostname: test-mihomo
|
||||
state-dir: ./tailscale
|
||||
udp: true
|
||||
accept-routes: true
|
||||
# whitelist: control and DERP over TCP through own servers (MY -> own node -> MY-EXIT);
|
||||
# MY holds hysteria2 from the settings and "[MY]" nodes of the subscriptions; empty MY is direct
|
||||
# needs the kit's core (v1.19.32-ts1, tools/core/*.patch, MetaCubeX/mihomo#3142)
|
||||
dialer-proxy: MY
|
||||
|
||||
# own servers of the settings (LuCI "Свои серверы", /etc/nikki/my-servers): one JSON
|
||||
# proxy per line, as mihomo's own config would have it; the kit puts dialer-proxy in
|
||||
# front: whitelist and the phone through MY-EXIT, else with UPLINK (CSQTT, pools) through it.
|
||||
# A server with an entry of its own (LuCI "Вход") keeps it in every profile
|
||||
- {"dialer-proxy": "MY-EXIT", "name":"nl-1","type":"hysteria2","server":"vpn.example.com","port":443,"password":"p","udp":true}
|
||||
- {"dialer-proxy": "MY-EXIT", "name":"de-2","type":"hysteria2","server":"5.6.7.8","port":443,"password":"q","udp":true}
|
||||
|
||||
proxy-providers:
|
||||
example:
|
||||
type: http
|
||||
url: "https://sub.example.com/sub/aaa"
|
||||
path: ./providers/example.yaml
|
||||
interval: 3600
|
||||
proxy: BOOT-AUTO
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
example2:
|
||||
type: http
|
||||
url: "https://sub2.example.com/x?a=1&b=2"
|
||||
path: ./providers/example2.yaml
|
||||
interval: 3600
|
||||
proxy: BOOT-AUTO
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
example-my:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
override:
|
||||
dialer-proxy: MY-EXIT
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
example2-my:
|
||||
type: file
|
||||
path: ./providers/example2.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
override:
|
||||
dialer-proxy: MY-EXIT
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
rule-providers:
|
||||
# Russian services (geosite ru-inside of russia-only, as .mrs): an ordinary
|
||||
# http rule-set, so every client fetches it with the config, no geodata setup
|
||||
ru-inside:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/ru-inside.mrs"
|
||||
path: ./ruleset/ru-inside.mrs
|
||||
interval: 86400
|
||||
# Russian services outside ru-inside and outside .ru/.su/.рф (russia-only ru-services):
|
||||
# not on the whitelist, so through RU everywhere but main
|
||||
ru-services:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/ru-services.mrs"
|
||||
path: ./ruleset/ru-services.mrs
|
||||
interval: 86400
|
||||
|
||||
sniffer:
|
||||
enable: true
|
||||
force-dns-mapping: true
|
||||
parse-pure-ip: true
|
||||
override-destination: false
|
||||
# ECH: browsers show the outer name cloudflare-ech.com instead of the site behind
|
||||
# Cloudflare; the sniffed name wins in the rules, so .ru / own lists would miss the
|
||||
# site. Skipped: the rules see the name from mihomo's DNS (fake-ip / DNS mapping).
|
||||
skip-domain:
|
||||
- "+.cloudflare-ech.com"
|
||||
sniff:
|
||||
HTTP:
|
||||
ports: [80, 8080-8880]
|
||||
TLS:
|
||||
ports: [443, 8443]
|
||||
# lite: no QUIC (fake-ip already gives the domain; pure-IP QUIC goes by IP)
|
||||
QUIC:
|
||||
ports: [443, 8443]
|
||||
|
||||
dns:
|
||||
enable: true
|
||||
ipv6: false
|
||||
respect-rules: true
|
||||
enhanced-mode: fake-ip
|
||||
fake-ip-range: 198.18.0.1/16
|
||||
fake-ip-filter:
|
||||
- '*.lan'
|
||||
- '*.local'
|
||||
- '+.ru'
|
||||
- '+.xn--p1ai'
|
||||
- rule-set:ru-inside
|
||||
# tailnet names: real 100.x addresses from MagicDNS (nameserver-policy below)
|
||||
- '+.ts.net'
|
||||
|
||||
default-nameserver:
|
||||
- 77.88.8.8
|
||||
- 1.1.1.1
|
||||
|
||||
proxy-server-nameserver:
|
||||
- https://77.88.8.8/dns-query
|
||||
|
||||
direct-nameserver:
|
||||
- 77.88.8.8
|
||||
- 77.88.8.1
|
||||
|
||||
nameserver:
|
||||
- https://1.1.1.1/dns-query
|
||||
- https://dns.google/dns-query
|
||||
|
||||
# MagicDNS of the embedded Tailscale (the proxy named "tailscale")
|
||||
nameserver-policy:
|
||||
'+.ts.net': tailscale://tailscale
|
||||
|
||||
proxy-groups:
|
||||
# BOOT: whitelisted entry nodes (BOOT_LINKS), the first alive one
|
||||
- name: BOOT
|
||||
type: fallback
|
||||
proxies: [seed]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
# default for downloading subscriptions: BOOT (if set), else the nodes of the
|
||||
# saved subscriptions (providers are cached on disk), else direct. FOREIGN goes
|
||||
# before DIRECT: the health check of DIRECT (gstatic) passes in Russia even when
|
||||
# the subscription site itself is blocked.
|
||||
- name: BOOT-AUTO
|
||||
type: fallback
|
||||
proxies: [BOOT, FOREIGN, DIRECT]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
- name: RU
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
# lite: the provider's URL, so RU nodes are not tested a second time
|
||||
url: "https://ya.ru"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
- name: FOREIGN
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
exclude-filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
- name: TORRENT
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
filter: "(?i)torrent|\\[tor\\]"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 6000
|
||||
tolerance: 500
|
||||
max-failed-times: 5
|
||||
lazy: false
|
||||
|
||||
# own servers: those of the settings (proxies/30-own_srv) and the "[MY] ..." nodes of
|
||||
# the subscriptions (providers <id>-my); the fastest alive one; pin one in the dashboard if needed
|
||||
- name: MY
|
||||
type: url-test
|
||||
proxies: ["nl-1", "de-2"]
|
||||
use: [example-my, example2-my]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
# whitelist and mobile (my_exit): what own servers are reached through; switches only when the node is
|
||||
# clearly worse or dead (each switch breaks everything going through MY)
|
||||
- name: MY-EXIT
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
exclude-filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 300
|
||||
lazy: false
|
||||
|
||||
# url (TS_CHECK_URL, optional): a tailnet service for the dashboard's delay test
|
||||
- name: TAILSCALE
|
||||
type: select
|
||||
proxies: [tailscale]
|
||||
url: "http://100.69.216.50:8080"
|
||||
interval: 0
|
||||
|
||||
- name: MAIN
|
||||
type: select
|
||||
proxies: [FOREIGN, MY, RU, DIRECT]
|
||||
|
||||
- name: TORRENT-SEL
|
||||
type: select
|
||||
proxies: [TORRENT, FOREIGN, DIRECT]
|
||||
|
||||
- name: PUSH
|
||||
type: select
|
||||
proxies: [MY, FOREIGN, DIRECT]
|
||||
|
||||
rules:
|
||||
# Tailscale: tailnet IPs and MagicDNS names (resolved by tailscale itself)
|
||||
- IP-CIDR,100.64.0.0/10,TAILSCALE,no-resolve
|
||||
- DOMAIN-SUFFIX,ts.net,TAILSCALE
|
||||
|
||||
- IP-CIDR,192.168.0.0/16,DIRECT,no-resolve
|
||||
- IP-CIDR,10.0.0.0/8,DIRECT,no-resolve
|
||||
- IP-CIDR,172.16.0.0/12,DIRECT,no-resolve
|
||||
|
||||
# push notifications (Apple APNs, Google FCM): long-lived connections on a
|
||||
# stable path - group PUSH (main/foreign: DIRECT, whitelist: MY)
|
||||
- DOMAIN-SUFFIX,push.apple.com,PUSH
|
||||
- IP-CIDR,17.249.0.0/16,PUSH,no-resolve
|
||||
- IP-CIDR,17.252.0.0/16,PUSH,no-resolve
|
||||
- IP-CIDR,17.57.144.0/22,PUSH,no-resolve
|
||||
- IP-CIDR,17.188.128.0/18,PUSH,no-resolve
|
||||
- IP-CIDR,17.188.20.0/23,PUSH,no-resolve
|
||||
- DOMAIN-REGEX,^(alt[0-9]+-)?mtalk[0-9]*\.google\.com$,PUSH
|
||||
- DST-PORT,5228-5230,PUSH
|
||||
|
||||
# own lists from the settings: above torrents, ru-inside, .ru and MATCH; below the
|
||||
# tunnels, LAN and push. Domains (DOMAIN-SUFFIX: the domain and all subdomains)
|
||||
# before IPs; first match wins: MY, then FOREIGN, then RU.
|
||||
# RU on main (home, own white IP): reachable directly; whitelist/abroad: through RU
|
||||
- IP-CIDR,194.190.191.112/32,RU
|
||||
|
||||
- SRC-PORT,20000-20199,TORRENT-SEL
|
||||
|
||||
- RULE-SET,ru-inside,DIRECT
|
||||
# main (home, own white IP): ru-services and .ru/.su/.рф directly; elsewhere through RU
|
||||
- RULE-SET,ru-services,RU
|
||||
- DOMAIN-SUFFIX,ru,RU
|
||||
- DOMAIN-SUFFIX,su,RU
|
||||
- DOMAIN-SUFFIX,xn--p1ai,RU
|
||||
- MATCH,MAIN
|
||||
@ -1,371 +0,0 @@
|
||||
proxies:
|
||||
- name: seed
|
||||
type: vless
|
||||
server: 1.2.3.4
|
||||
port: 443
|
||||
uuid: 00000000-0000-0000-0000-000000000000
|
||||
network: tcp
|
||||
udp: true
|
||||
tls: true
|
||||
flow: xtls-rprx-vision
|
||||
servername: eh.vk.ru
|
||||
client-fingerprint: firefox
|
||||
reality-opts:
|
||||
public-key: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
short-id: a1b2
|
||||
|
||||
# Tailscale: userspace node, starts on first use. First login: open the URL
|
||||
# from the nikki log ("To start this tsnet server ... go to: ..."), then
|
||||
# disable key expiry for this node. Needs TS_FORCE_NOISE_443=true in the
|
||||
# mihomo environment (mihomo-kit.sh fix).
|
||||
- name: tailscale
|
||||
type: tailscale
|
||||
hostname: test-mihomo
|
||||
state-dir: ./tailscale
|
||||
udp: true
|
||||
accept-routes: true
|
||||
dialer-proxy: TS-EXIT
|
||||
|
||||
# own servers of the settings (LuCI "Свои серверы", /etc/nikki/my-servers): one JSON
|
||||
# proxy per line, as mihomo's own config would have it; the kit puts dialer-proxy in
|
||||
# front: whitelist and the phone through MY-EXIT, else with UPLINK (CSQTT, pools) through it.
|
||||
# A server with an entry of its own (LuCI "Вход") keeps it in every profile
|
||||
- {"dialer-proxy": "MY-EXIT", "name":"nl-1","type":"hysteria2","server":"vpn.example.com","port":443,"password":"p\"w\\1","obfs":"salamander","obfs-password":"obfs","sni":"vpn.example.com","up":"50 mbps","down":"100 mbps","udp":true}
|
||||
- {"dialer-proxy": "MY-EXIT", "name":"de_2","type":"hysteria2","server":"5.6.7.8","port":8443,"password":"x","sni":"www.bing.com","skip-cert-verify":true,"udp":true}
|
||||
|
||||
proxy-providers:
|
||||
example:
|
||||
type: http
|
||||
url: "https://sub.example.com/sub/aaa"
|
||||
path: ./providers/example.yaml
|
||||
interval: 3600
|
||||
proxy: BOOT-AUTO
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
example2:
|
||||
type: http
|
||||
url: "https://sub2.example.com/x?a=1&b=2"
|
||||
path: ./providers/example2.yaml
|
||||
interval: 3600
|
||||
proxy: BOOT-AUTO
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
example-my:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
override:
|
||||
dialer-proxy: MY-EXIT
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
example2-my:
|
||||
type: file
|
||||
path: ./providers/example2.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
override:
|
||||
dialer-proxy: MY-EXIT
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# OpenVPN: file written on the router by ovpn.sh (with TOTP: a fresh code in the
|
||||
# password). No health-check here: a dead tunnel would be redialed with a
|
||||
# stale code; the cron watchdog (ovpn.sh check) handles it.
|
||||
openvpn:
|
||||
type: file
|
||||
path: ./providers/openvpn.yaml
|
||||
health-check:
|
||||
enable: false
|
||||
override:
|
||||
dialer-proxy: OVPN-EXIT
|
||||
|
||||
rule-providers:
|
||||
# Russian services (geosite ru-inside of russia-only, as .mrs): an ordinary
|
||||
# http rule-set, so every client fetches it with the config, no geodata setup
|
||||
ru-inside:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/ru-inside.mrs"
|
||||
path: ./ruleset/ru-inside.mrs
|
||||
interval: 86400
|
||||
# Russian services outside ru-inside and outside .ru/.su/.рф (russia-only ru-services):
|
||||
# not on the whitelist, so through RU everywhere but main
|
||||
ru-services:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/ru-services.mrs"
|
||||
path: ./ruleset/ru-services.mrs
|
||||
interval: 86400
|
||||
|
||||
# OpenVPN routes (OVPN_ROUTES): the file is written by mihomo-kit.sh build and
|
||||
# emptied by ovpn.sh off, so with the tunnel off these addresses follow
|
||||
# the normal rules instead of a dead OpenVPN group
|
||||
openvpn-routes:
|
||||
type: file
|
||||
behavior: ipcidr
|
||||
path: ./providers/openvpn-routes.yaml
|
||||
|
||||
sniffer:
|
||||
enable: true
|
||||
force-dns-mapping: true
|
||||
parse-pure-ip: true
|
||||
override-destination: false
|
||||
# ECH: browsers show the outer name cloudflare-ech.com instead of the site behind
|
||||
# Cloudflare; the sniffed name wins in the rules, so .ru / own lists would miss the
|
||||
# site. Skipped: the rules see the name from mihomo's DNS (fake-ip / DNS mapping).
|
||||
skip-domain:
|
||||
- "+.cloudflare-ech.com"
|
||||
sniff:
|
||||
HTTP:
|
||||
ports: [80, 8080-8880]
|
||||
TLS:
|
||||
ports: [443, 8443]
|
||||
# lite: no QUIC (fake-ip already gives the domain; pure-IP QUIC goes by IP)
|
||||
QUIC:
|
||||
ports: [443, 8443]
|
||||
|
||||
dns:
|
||||
enable: true
|
||||
ipv6: false
|
||||
respect-rules: true
|
||||
enhanced-mode: fake-ip
|
||||
fake-ip-range: 198.18.0.1/16
|
||||
fake-ip-filter:
|
||||
- '*.lan'
|
||||
- '*.local'
|
||||
- '+.ru'
|
||||
- '+.xn--p1ai'
|
||||
- rule-set:ru-inside
|
||||
# tailnet names: real 100.x addresses from MagicDNS (nameserver-policy below)
|
||||
- '+.ts.net'
|
||||
- '+.corp.example'
|
||||
- '+.internal.example'
|
||||
|
||||
default-nameserver:
|
||||
- 77.88.8.8
|
||||
- 1.1.1.1
|
||||
|
||||
proxy-server-nameserver:
|
||||
- https://77.88.8.8/dns-query
|
||||
|
||||
direct-nameserver:
|
||||
- 77.88.8.8
|
||||
- 77.88.8.1
|
||||
|
||||
nameserver:
|
||||
- https://1.1.1.1/dns-query
|
||||
- https://dns.google/dns-query
|
||||
|
||||
# MagicDNS of the embedded Tailscale (the proxy named "tailscale")
|
||||
nameserver-policy:
|
||||
'+.ts.net': tailscale://tailscale
|
||||
'+.corp.example': tailscale://tailscale
|
||||
'+.internal.example': tailscale://tailscale
|
||||
|
||||
proxy-groups:
|
||||
# BOOT: whitelisted entry nodes (BOOT_LINKS), the first alive one
|
||||
- name: BOOT
|
||||
type: fallback
|
||||
proxies: [seed]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
# default for downloading subscriptions: BOOT (if set), else the nodes of the
|
||||
# saved subscriptions (providers are cached on disk), else direct. FOREIGN goes
|
||||
# before DIRECT: the health check of DIRECT (gstatic) passes in Russia even when
|
||||
# the subscription site itself is blocked.
|
||||
- name: BOOT-AUTO
|
||||
type: fallback
|
||||
proxies: [BOOT, FOREIGN, DIRECT]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
- name: RU
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
# lite: the provider's URL, so RU nodes are not tested a second time
|
||||
url: "https://ya.ru"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
- name: FOREIGN
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
exclude-filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
- name: TORRENT
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
filter: "(?i)torrent|\\[tor\\]"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 6000
|
||||
tolerance: 500
|
||||
max-failed-times: 5
|
||||
lazy: false
|
||||
|
||||
# url: what the dashboard's delay test opens through the tunnel;
|
||||
# interval 0: no background checks (they would redial with a stale code)
|
||||
- name: OPENVPN
|
||||
type: select
|
||||
use: [openvpn]
|
||||
url: "https://intranet.corp.example/"
|
||||
interval: 0
|
||||
|
||||
# what the OpenVPN tunnel itself goes through on whitelist and foreign (ovpn_exit):
|
||||
# a RU node, for a VPN server in Russia. select, not url-test: switching nodes
|
||||
# would break the tunnel. Pick one in the dashboard, the choice is remembered.
|
||||
- name: OVPN-EXIT
|
||||
type: select
|
||||
use: [example, example2]
|
||||
filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
|
||||
# own servers: those of the settings (proxies/30-own_srv) and the "[MY] ..." nodes of
|
||||
# the subscriptions (providers <id>-my); the fastest alive one; pin one in the dashboard if needed
|
||||
- name: MY
|
||||
type: url-test
|
||||
proxies: ["nl-1", "de_2"]
|
||||
use: [example-my, example2-my]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
# whitelist and mobile (my_exit): what own servers are reached through; switches only when the node is
|
||||
# clearly worse or dead (each switch breaks everything going through MY)
|
||||
- name: MY-EXIT
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
exclude-filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 300
|
||||
lazy: false
|
||||
|
||||
# url (TS_CHECK_URL, optional): a tailnet service for the dashboard's delay test
|
||||
- name: TAILSCALE
|
||||
type: select
|
||||
proxies: [tailscale]
|
||||
url: "http://100.69.216.50:8080/"
|
||||
interval: 0
|
||||
|
||||
# Tailscale needs full-cone UDP from its dialer-proxy: vless/vmess/trojan
|
||||
# cannot do it in mihomo, so only ss / hysteria2 / tuic / socks5 nodes here.
|
||||
- name: TS-EXIT
|
||||
type: select
|
||||
proxies: [MY]
|
||||
use: [example, example2]
|
||||
exclude-type: "vless|vmess|trojan"
|
||||
|
||||
- name: MAIN
|
||||
type: select
|
||||
proxies: [FOREIGN, MY, RU, DIRECT]
|
||||
|
||||
- name: TORRENT-SEL
|
||||
type: select
|
||||
proxies: [TORRENT, FOREIGN, DIRECT]
|
||||
|
||||
- name: PUSH
|
||||
type: select
|
||||
proxies: [MY, FOREIGN, DIRECT]
|
||||
|
||||
rules:
|
||||
# Tailscale: tailnet IPs and MagicDNS names (resolved by tailscale itself)
|
||||
- IP-CIDR,100.64.0.0/10,TAILSCALE,no-resolve
|
||||
- DOMAIN-SUFFIX,ts.net,TAILSCALE
|
||||
- DOMAIN-SUFFIX,corp.example,TAILSCALE
|
||||
- DOMAIN-SUFFIX,internal.example,TAILSCALE
|
||||
|
||||
# the OpenVPN server itself (remote lines of the .ovpn) must not go into its own tunnel
|
||||
- DOMAIN,vpn1.corp.example,OVPN-EXIT
|
||||
- DOMAIN,vpn2.corp.example,OVPN-EXIT
|
||||
# the networks that go through the VPN (OVPN_ROUTES; before the private-range DIRECT
|
||||
# rules); a rule-provider so that ovpn.sh off can drop them without a restart
|
||||
- RULE-SET,openvpn-routes,OPENVPN,no-resolve
|
||||
|
||||
- IP-CIDR,192.168.0.0/16,DIRECT,no-resolve
|
||||
- IP-CIDR,10.0.0.0/8,DIRECT,no-resolve
|
||||
- IP-CIDR,172.16.0.0/12,DIRECT,no-resolve
|
||||
|
||||
# push notifications (Apple APNs, Google FCM): long-lived connections on a
|
||||
# stable path - group PUSH (main/foreign: DIRECT, whitelist: MY)
|
||||
- DOMAIN-SUFFIX,push.apple.com,PUSH
|
||||
- IP-CIDR,17.249.0.0/16,PUSH,no-resolve
|
||||
- IP-CIDR,17.252.0.0/16,PUSH,no-resolve
|
||||
- IP-CIDR,17.57.144.0/22,PUSH,no-resolve
|
||||
- IP-CIDR,17.188.128.0/18,PUSH,no-resolve
|
||||
- IP-CIDR,17.188.20.0/23,PUSH,no-resolve
|
||||
- DOMAIN-REGEX,^(alt[0-9]+-)?mtalk[0-9]*\.google\.com$,PUSH
|
||||
- DST-PORT,5228-5230,PUSH
|
||||
|
||||
# own lists from the settings: above torrents, ru-inside, .ru and MATCH; below the
|
||||
# tunnels, LAN and push. Domains (DOMAIN-SUFFIX: the domain and all subdomains)
|
||||
# before IPs; first match wins: MY, then FOREIGN, then RU.
|
||||
# RU on main (home, own white IP): reachable directly; whitelist/abroad: through RU
|
||||
- DOMAIN-SUFFIX,example.com,RU
|
||||
- IP-CIDR,10.8.0.0/24,MY
|
||||
- IP-CIDR,194.190.191.112/32,RU
|
||||
|
||||
- SRC-PORT,20000-20199,TORRENT-SEL
|
||||
|
||||
- RULE-SET,ru-inside,DIRECT
|
||||
# main (home, own white IP): ru-services and .ru/.su/.рф directly; elsewhere through RU
|
||||
- RULE-SET,ru-services,RU
|
||||
- DOMAIN-SUFFIX,ru,RU
|
||||
- DOMAIN-SUFFIX,su,RU
|
||||
- DOMAIN-SUFFIX,xn--p1ai,RU
|
||||
- MATCH,MAIN
|
||||
10
tests/fixtures/mobile.env
vendored
10
tests/fixtures/mobile.env
vendored
@ -3,13 +3,3 @@ HY2=m1
|
||||
HY2_M1_SERVER=m.example.com
|
||||
HY2_M1_PORT=443
|
||||
HY2_M1_PASSWORD=p
|
||||
LOCAL_HOSTS="sub2.example.com=192.168.64.20"
|
||||
MY_LINKS='ss://YWVzLTI1Ni1nY206cGFzcw@1.2.3.4:8388#ss1'
|
||||
MY_SERVERS_FILE=tests/fixtures/own.servers
|
||||
SERVICES=claude
|
||||
SVC_CLAUDE_GEOSITE=anthropic
|
||||
POOLS=one
|
||||
POOL_ONE_SERVERS='m1'
|
||||
POOL_ONE_SUBS="example2-my"
|
||||
SVC_CLAUDE_VIA=ONE
|
||||
SVC_CLAUDE_CHAIN=FOREIGN
|
||||
|
||||
9
tests/fixtures/openvpn.ovpn
vendored
9
tests/fixtures/openvpn.ovpn
vendored
@ -1,9 +0,0 @@
|
||||
# a client profile as servers hand it out: two remotes, pushed and own routes
|
||||
client
|
||||
dev tun
|
||||
remote vpn.corp.example 1194 udp
|
||||
remote 203.0.113.10 443 tcp
|
||||
data-ciphers AES-256-GCM:CHACHA20-POLY1305
|
||||
route 10.20.0.0 255.255.0.0
|
||||
route 192.0.2.7
|
||||
static-challenge "Code" 1
|
||||
5
tests/fixtures/own.servers
vendored
5
tests/fixtures/own.servers
vendored
@ -1,5 +0,0 @@
|
||||
{"name":"🇩🇪 de 1","type":"vless","server":"x.example.com","port":"443","uuid":"00000000-0000-0000-0000-000000000001","udp":true,"tls":true,"client-fingerprint":"chrome","servername":"www.example.com","reality-opts":{"public-key":"Nc9ZSDuQMwHN4M6TeDHjfJhgZ6SBTBbfMwx5iHQZ1ns","short-id":"ab"},"xudp":true,"network":"xhttp","xhttp-opts":{"path":"/x"}}
|
||||
{"name":"tr \"q\"","type":"trojan","server":"t.example.org","port":"443","password":"p\u0024w","udp":true,"skip-cert-verify":false,"sni":"t.example.org","network":"grpc","grpc-opts":{"grpc-service-name":"g"},"client-fingerprint":"chrome"}
|
||||
{"name":"hy-own","type":"hysteria2","server":"h.example.net","port":8443,"password":"a\u0024b","obfs":"salamander","obfs-password":"o","up":"50 mbps"}
|
||||
{"name":"awg-own","type":"wireguard","server":"203.0.113.10","port":47613,"ip":"10.8.1.2","private-key":"fTo2df+b5vCuulh7pOXMWiWJY2VwSe2Kuup2nA34tfI=","public-key":"vGYpG72gCXPNfYzr/0iNfSoL83vbrVSGUC+v+MKRVyE=","pre-shared-key":"6ut/J6EuaJ97RMFcZuiJkzIo7a5uxR98htK5NdWJW6E=","persistent-keepalive":25,"udp":true,"amnezia-wg-option":{"jc":4,"jmin":10,"jmax":50,"s1":98,"s2":32,"s3":19,"s4":7,"h1":"1458367412-1593426716","h2":"1863071624-1902347825","h3":"2091548318-2097143921","h4":"2112573893-2147191025","i1":"<r 2><b 0x858000010001000000000669636c6f756403636f6d0000010001c00c000100010000105a00044d583737>"}}
|
||||
{"name":"via-foreign","type":"ss","server":"f.example.com","port":8388,"cipher":"aes-256-gcm","password":"x","dialer-proxy":"FOREIGN"}
|
||||
6
tests/fixtures/router-boots.env
vendored
6
tests/fixtures/router-boots.env
vendored
@ -1,5 +1,5 @@
|
||||
TARGET=router
|
||||
LOCATION=whitelist
|
||||
BOOT_LINKS="vless://11111111-1111-1111-1111-111111111111@1.2.3.4:443?type=tcp&security=reality&sni=eh.vk.ru&pbk=Nc9ZSDuQMwHN4M6TeDHjfJhgZ6SBTBbfMwx5iHQZ1ns&sid=a1&flow=xtls-rprx-vision#one
|
||||
vless://22222222-2222-2222-2222-222222222222@seed2.example.com:8443?security=reality&sni=ya.ru&pbk=ppQ9FwLrLIa0AOrp1WvcyiaQ37vg2WSy_CD4bIdiTUw&sid=b2"
|
||||
LOCATION=street
|
||||
BOOT_LINKS="vless://11111111-1111-1111-1111-111111111111@1.2.3.4:443?type=tcp&security=reality&sni=eh.vk.ru&pbk=PBK1&sid=a1&flow=xtls-rprx-vision#one
|
||||
vless://22222222-2222-2222-2222-222222222222@seed2.example.com:8443?security=reality&sni=ya.ru&pbk=PBK2&sid=b2"
|
||||
SUB_EXAMPLE_PROXY=BOOT
|
||||
|
||||
8
tests/fixtures/router-csqtt-foreign.env
vendored
8
tests/fixtures/router-csqtt-foreign.env
vendored
@ -1,8 +0,0 @@
|
||||
TARGET=router
|
||||
LOCATION=foreign
|
||||
CSQTT=1
|
||||
HY2=nl-1
|
||||
HY2_NL_1_SERVER=vpn.example.com
|
||||
HY2_NL_1_PORT=443
|
||||
HY2_NL_1_PASSWORD=p
|
||||
MY_SERVERS_FILE=tests/fixtures/own.servers
|
||||
4
tests/fixtures/router-csqtt.env
vendored
4
tests/fixtures/router-csqtt.env
vendored
@ -1,4 +0,0 @@
|
||||
TARGET=router
|
||||
LOCATION=whitelist
|
||||
CSQTT=1
|
||||
MY_SERVERS_FILE=tests/fixtures/own.servers
|
||||
10
tests/fixtures/router-foreign.env
vendored
10
tests/fixtures/router-foreign.env
vendored
@ -1,10 +0,0 @@
|
||||
TARGET=router
|
||||
LOCATION=foreign
|
||||
OPENVPN=1
|
||||
OVPN_SERVER_IPS="198.51.100.4"
|
||||
OVPN_ROUTES="10.30.0.0/16"
|
||||
TAILSCALE=1
|
||||
HY2=nl-1
|
||||
HY2_NL_1_SERVER=vpn.example.com
|
||||
HY2_NL_1_PORT=443
|
||||
HY2_NL_1_PASSWORD=p
|
||||
7
tests/fixtures/router-home.env
vendored
Normal file
7
tests/fixtures/router-home.env
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
LOCATION=home
|
||||
OPENVPN=1
|
||||
TAILSCALE=1
|
||||
HY2=home-hy
|
||||
HY2_HOME_HY_SERVER=1.1.1.1
|
||||
HY2_HOME_HY_PORT=443
|
||||
HY2_HOME_HY_PASSWORD=x
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user