Compare commits
40 Commits
core-v1.19
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| d531b70db3 | |||
| 249cb21a7f | |||
| edfcb7f82f | |||
| d030d7e23c | |||
| fd2a2dad87 | |||
| aa7810354c | |||
| 2561d0b5d4 | |||
| 180d3a2650 | |||
| 3a3e452d66 | |||
| 854e03fb14 | |||
| 4c6e1e6f7e | |||
| 597b5377f6 | |||
| e6b200b33a | |||
| ef2c150c63 | |||
| 432ec27e68 | |||
| 0f0ab77327 | |||
| b1e34539ab | |||
|
|
2590aea282 | ||
|
|
5c163e4d50 | ||
|
|
749ece5491 | ||
|
|
c4a202d6c6 | ||
|
|
909cfdfedb | ||
|
|
003a8823a7 | ||
|
|
40d9989c98 | ||
|
|
bc84b7a656 | ||
|
|
c2fda5d015 | ||
|
|
bb6391844e | ||
|
|
77707ce582 | ||
|
|
f6ddc8be7c | ||
|
|
83f6f3d38f | ||
|
|
d03040779b | ||
|
|
59f8d43aa0 | ||
|
|
b1b783fd15 | ||
|
|
9743350fa5 | ||
|
|
6723f4e2cb | ||
|
|
21180acbaf | ||
|
|
614f08ba16 | ||
|
|
a3a6449d4e | ||
|
|
d7e277a437 | ||
|
|
8b0076ea15 |
6
.gitignore
vendored
6
.gitignore
vendored
@ -3,6 +3,7 @@
|
|||||||
!tests/fixtures/*.env
|
!tests/fixtures/*.env
|
||||||
!presets/*.env
|
!presets/*.env
|
||||||
*.ovpn
|
*.ovpn
|
||||||
|
!tests/fixtures/*.ovpn
|
||||||
/configs/
|
/configs/
|
||||||
/reference/
|
/reference/
|
||||||
|
|
||||||
@ -10,3 +11,8 @@
|
|||||||
__pycache__/
|
__pycache__/
|
||||||
tools/core/work/
|
tools/core/work/
|
||||||
tools/core/dist/
|
tools/core/dist/
|
||||||
|
tools/nikki-work/
|
||||||
|
|
||||||
|
# Local agent notes
|
||||||
|
/AGENTS.md
|
||||||
|
/PROJECT_NOTES.md
|
||||||
|
|||||||
574
README.md
574
README.md
@ -1,8 +1,9 @@
|
|||||||
# mihomo-kit
|
# mihomo-kit
|
||||||
|
|
||||||
Конфиги mihomo из одного набора шаблонов: роутер под nikki (профили `main` — дома в России, `whitelist` — белые списки, `foreign` — за рубежом)
|
Конфиги mihomo из одного набора шаблонов: роутер под nikki (профили `main` — дома в России, `whitelist` — белые списки, `foreign` — за рубежом)
|
||||||
и телефон (FlClash). Подписки через BOOT-ноду, `ru-inside` напрямую, остальные `.ru`
|
и приложения на телефоне и компьютере (FlClash, Clash Mi и другие на ядре mihomo). Подписки через
|
||||||
через RU, опционально OpenVPN с TOTP и Tailscale.
|
BOOT-ноду, `ru-inside` напрямую, остальные `.ru` через RU, опционально OpenVPN (рабочая или
|
||||||
|
учебная сеть, с одноразовыми кодами TOTP или без) и Tailscale.
|
||||||
|
|
||||||
## Установка на роутер
|
## Установка на роутер
|
||||||
|
|
||||||
@ -20,15 +21,47 @@ ssh root@192.168.32.1 sh /etc/nikki/kit/install.sh
|
|||||||
```
|
```
|
||||||
|
|
||||||
Установщик ставит nikki (если нет), правильное ядро, фиксы и kit со страницей LuCI —
|
Установщик ставит nikki (если нет), правильное ядро, фиксы и kit со страницей LuCI —
|
||||||
ничего не спрашивает. Дальше всё в браузере: LuCI → **Службы → mihomo-kit → Настройка**
|
ничего не спрашивает. Пакеты 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 и войти снова).
|
(адрес установщик печатает в конце; если пункта нет — выйти из LuCI и войти снова).
|
||||||
Там подписки, vless-ссылки BOOT, торренты, OpenVPN (файл `.ovpn`, логин, пароль,
|
Страница разбита на вкладки по темам: «Обзор» (состояние, профиль), «Подписки» (подписки,
|
||||||
TOTP-секрет), Tailscale; «Сохранить и применить» собирает профили `main`, `whitelist` и `foreign`,
|
vless-ссылки BOOT), «Правила» (торренты, пуши, свои домены и IP), «Свои серверы», «Пулы и
|
||||||
|
сервисы», «OpenVPN», «Tailscale», «CSQTT», «Телефон», «Система» (облегчённый режим, ядро,
|
||||||
|
обновления, экспорт). На вкладке сверху её состояние и кнопки, ниже настройки. Одна кнопка
|
||||||
|
«Сохранить и применить» под вкладками сохраняет все вкладки разом: собирает профили `main`, `whitelist` и `foreign`,
|
||||||
включает профиль и, если включён Tailscale, показывает ссылку для входа — открыть её,
|
включает профиль и, если включён Tailscale, показывает ссылку для входа — открыть её,
|
||||||
войти, в админке Tailscale **Disable key expiry** для ноды.
|
войти, в админке Tailscale **Disable key expiry** для ноды.
|
||||||
|
|
||||||
Позже настройки меняются там же — «Изменить настройки»; ключи, добавленные в
|
На новом роутере (ещё без настроек) установщик сразу настраивает nikki: перехват без TUN
|
||||||
`common.env` / `bmstu.env` руками, сохраняются.
|
(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` руками, сохраняются.
|
||||||
|
|
||||||
Роутер без LuCI или вопросы в терминале по-старому:
|
Роутер без LuCI или вопросы в терминале по-старому:
|
||||||
`wget -qO- …/install.sh | sh -s -- --cli` (или `mihomo-kit.sh setup --cli`).
|
`wget -qO- …/install.sh | sh -s -- --cli` (или `mihomo-kit.sh setup --cli`).
|
||||||
@ -41,73 +74,148 @@ TOTP-секрет), Tailscale; «Сохранить и применить» со
|
|||||||
## Каждый день
|
## Каждый день
|
||||||
|
|
||||||
То же самое из веб-интерфейса: LuCI → **Службы → mihomo-kit**. Там переключение
|
То же самое из веб-интерфейса: LuCI → **Службы → mihomo-kit**. Там переключение
|
||||||
профиля, OpenVPN вкл/выкл/переподключить с текущим OTP, ссылка для входа в Tailscale,
|
профиля, OpenVPN вкл/выкл/переподключить (с текущим кодом, если он нужен), ссылка для входа в Tailscale,
|
||||||
пересборка, обновление kit и `fix`; вывод команды показывается внизу страницы.
|
пересборка, обновление kit и `fix`; вывод команды показывается внизу страницы.
|
||||||
|
|
||||||
Перенос настроек на другой роутер — «Экспорт настроек» там же: один файл `.kit` с
|
Перенос настроек на другой роутер — «Экспорт настроек» там же: один файл `.kit` с
|
||||||
профилями, подписками, BOOT, своими серверами и OpenVPN (с паролями и `.ovpn` — хранить
|
профилями, подписками, BOOT, своими серверами и OpenVPN (с паролями и `.ovpn` — хранить
|
||||||
как секрет). На другом роутере «Импорт настроек» заменяет его настройки и перезапускает
|
как секрет). На другом роутере «Импорт настроек» заменяет его настройки и перезапускает
|
||||||
профиль; галка «оставить имя ноды Tailscale и x-hwid» сохраняет `TS_HOSTNAME` и `HWID_ID`
|
профиль; галка «оставить имя ноды Tailscale и x-hwid» сохраняет `TS_HOSTNAME` и `HWID_ID`
|
||||||
этого роутера. Выбор ядра, ключ ноды Tailscale и ссылка для телефона не переносятся.
|
этого роутера, а `LOCAL_HOSTS` всегда остаётся свой. Выбор ядра, ключ ноды Tailscale и ссылка для телефона не переносятся.
|
||||||
Из терминала: `mihomo-kit.sh export > file.kit`, `mihomo-kit.sh import file.kit --keep-local`.
|
Из терминала: `mihomo-kit.sh export > file.kit`, `mihomo-kit.sh import file.kit --keep-local`.
|
||||||
|
|
||||||
Автообновление — «Включить автообновление» там же (или `mihomo-kit.sh auto-update on|off`):
|
Автообновление — «Включить автообновление» там же (или `mihomo-kit.sh auto-update on|off`):
|
||||||
cron каждый день в 4:00 по времени роутера (часовой пояс — Система → Система) проверяет
|
cron каждый день в 4:00 по времени роутера (часовой пояс — Система → Система) проверяет
|
||||||
коммит на сервере; если он новее — скачивает kit, пересобирает профили, при смене версии
|
коммит на сервере; если он новее — скачивает kit, пересобирает профили, при смене версии
|
||||||
ядра делает `fix` и перезапускает текущий профиль. Журнал — `/etc/nikki/kit/auto-update.log`,
|
ядра делает `fix` и перезапускает текущий профиль. Если kit уже свежий, а ядро не то, что он
|
||||||
последняя строка видна на странице.
|
просит (релиз ядра выложен позже кита, скачивание не удалось), автообновление ставит ядро
|
||||||
|
заново — только когда файл ядра доступен, чтобы не перезапускать nikki каждую ночь впустую.
|
||||||
|
Явный `MIHOMO_VERSION=…` в `kit.env` закрепляет ядро, и тогда оно не обновляется. Журнал —
|
||||||
|
`/etc/nikki/kit/auto-update.log`, последняя строка видна на странице.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
mihomo-kit.sh use whitelist # попал на белые списки
|
mihomo-kit.sh use whitelist # попал на белые списки
|
||||||
mihomo-kit.sh use main # обычный интернет в России
|
mihomo-kit.sh use main # обычный интернет в России
|
||||||
mihomo-kit.sh use foreign # за рубежом: российское через RU, остальное напрямую
|
mihomo-kit.sh use foreign # за рубежом: российское через RU, остальное напрямую
|
||||||
|
|
||||||
bmstu-otp.sh off # OpenVPN выключить: освободить сессию для другого устройства
|
ovpn.sh off # OpenVPN выключить: освободить сессию для другого устройства
|
||||||
bmstu-otp.sh on # включить обратно
|
ovpn.sh on # включить постоянно
|
||||||
bmstu-otp.sh for 60 # поднять на 60 минут, потом вернуть как было
|
ovpn.sh sched on # работать по расписанию; sched off — выключить (как off)
|
||||||
bmstu-otp.sh sched 09:00 17:00 # работать только в эти часы (МСК); sched off — отключить
|
ovpn.sh sched 09:00 17:00 # запомнить часы расписания (время роутера), включает их sched on
|
||||||
bmstu-otp.sh sched 09:00 17:00 weekdays # то же, только по будням (дни: 12345, weekend, all)
|
ovpn.sh sched 09:00 17:00 weekdays # то же, только по будням (дни: 12345, weekend, all)
|
||||||
bmstu-otp.sh sched days 12345 # поменять только дни (1 — пн … 7 — вс)
|
ovpn.sh sched days 12345 # поменять только дни (1 — пн … 7 — вс)
|
||||||
bmstu-otp.sh status # что решает сейчас, когда следующее переключение, отвечает ли туннель
|
ovpn.sh for 60 # поднять на 60 минут поверх режима, потом вернуть режим
|
||||||
|
ovpn.sh extend 60 # продлить таймер на 60 минут (не дальше 12 ч от сейчас)
|
||||||
|
ovpn.sh stop # остановить таймер
|
||||||
|
ovpn.sh status # что решает сейчас, когда следующее переключение, отвечает ли туннель
|
||||||
```
|
```
|
||||||
|
|
||||||
Эти же кнопки и поле расписания есть на странице LuCI (Службы → mihomo-kit). Там же видно,
|
Эти же кнопки и часы расписания есть на странице LuCI (Службы → mihomo-kit). Там же видно,
|
||||||
что решает сейчас («включён по расписанию», «выключен вручную», «включён таймером до 15:30»)
|
что решает сейчас («включён по расписанию», «выключен вручную», «включён таймером до 15:30»)
|
||||||
и что будет дальше («выключится сегодня в 17:06», «потом снова действует ручное „Выключить“»).
|
и что будет дальше («выключится сегодня в 17:06», «потом снова действует ручное „Выключить“»).
|
||||||
|
|
||||||
Кто главнее: таймер (`for`) → ручное «Выключить» → расписание.
|
Режим всегда один из трёх, у каждого своя кнопка:
|
||||||
- «Выключить» держится, пока не нажмёшь «Включить»: расписание его не снимает.
|
- «Включить» — туннель включён постоянно;
|
||||||
- Таймер поднимает туннель поверх всего, а когда истекает, возвращает то, что было до него:
|
- «Выключить» — выключен и сам не включится;
|
||||||
ручное выключение или расписание. «Выключить» во время таймера его отменяет.
|
- «Включить расписание» — включён только в часы и дни расписания. «Выключить расписание»
|
||||||
- «Включить» снимает ручное выключение и таймер, дальше решает расписание: вне окна туннель
|
переводит в «Выключено». Выключенное расписание туннель не включает; «Сохранить» у часов
|
||||||
останется выключенным, поднять его там можно таймером. Без расписания туннель включён всегда.
|
только запоминает их.
|
||||||
|
|
||||||
Дни недели — галки Пн…Вс рядом с расписанием (`OVPN_SCHED_DAYS` в `bmstu.env`, по умолчанию
|
«Включить» и «Выключить» снимают расписание и таймер. Таймер («Включить на 1 ч», потом
|
||||||
|
«+1 ч», не дальше 12 ч от текущего момента — `TIMER_MAX`) поднимает туннель поверх любого
|
||||||
|
режима, а когда истекает или по «Остановить таймер», возвращает режим. Так можно держать
|
||||||
|
OpenVPN выключенным и включать его только на время, не трогая расписание.
|
||||||
|
|
||||||
|
Дни недели — галки Пн…Вс рядом с расписанием (`OVPN_SCHED_DAYS` в `openvpn.env`, по умолчанию
|
||||||
все); окно через полночь относится ко дню, в который началось: «22:00–02:00 по будням» работает и
|
все); окно через полночь относится ко дню, в который началось: «22:00–02:00 по будням» работает и
|
||||||
в ночь с пятницы на субботу, но не с воскресенья на понедельник.
|
в ночь с пятницы на субботу, но не с воскресенья на понедельник.
|
||||||
|
|
||||||
Время — локальное на роутере (МСК). Границы окна каждый день сдвигаются на случайные, но
|
Время — локальное на роутере (Система → Система → часовой пояс). Границы окна каждый день сдвигаются на случайные, но
|
||||||
постоянные в течение дня ±10 минут (`OVPN_SCHED_JITTER`), чтобы включение и выключение не
|
постоянные в течение дня ±10 минут (`OVPN_SCHED_JITTER`), чтобы включение и выключение не
|
||||||
приходились каждый раз на одну и ту же секунду. Поэтому окно короче 20 минут (или длиннее
|
приходились каждый раз на одну и ту же секунду. Поэтому окно короче 20 минут (или длиннее
|
||||||
23 ч 40 мин) не принимается. Маршруты BMSTU (`OVPN_ROUTES`) следуют за туннелем: пока он
|
23 ч 40 мин) не принимается. Сети VPN (`OVPN_ROUTES`) следуют за туннелем: пока он
|
||||||
выключен по любой причине, они убраны.
|
выключен по любой причине, они убраны.
|
||||||
|
|
||||||
На сервере BMSTU одна сессия на пользователя. `off` закрывает туннель в mihomo и не даёт
|
Многие VPN-серверы пускают только одну сессию на пользователя. `off` закрывает туннель в
|
||||||
cron поднять его снова, и убирает его подсети (`OVPN_ROUTES`) из маршрутизации: они лежат в
|
mihomo и не даёт cron поднять его снова, и убирает его сети (`OVPN_ROUTES`) из
|
||||||
rule-provider `bmstu-routes`, который `off` очищает, а `on` возвращает, без перезапуска nikki.
|
маршрутизации: они лежат в rule-provider `openvpn-routes`, который `off` очищает, а `on`
|
||||||
Адреса BMSTU тогда идут по обычным правилам, как любые другие сайты: публичные открываются,
|
возвращает, без перезапуска nikki. Эти адреса тогда идут по обычным правилам, как любые
|
||||||
внутренние (`172.x`) — нет. Ядро kit при закрытии туннеля отправляет серверу EXIT, как
|
другие сайты: публичные открываются, внутренние — нет. Ядро kit при закрытии туннеля
|
||||||
Connect, и сессия освобождается за секунды — можно сразу подключаться с другого устройства.
|
отправляет серверу EXIT, как OpenVPN Connect, и сессия освобождается за секунды — можно сразу
|
||||||
С другим ядром EXIT не уходит, и сервер держит сессию до своего `ping-restart` (~5 минут).
|
подключаться с другого устройства. С другим ядром EXIT не уходит, и сервер держит сессию до
|
||||||
|
своего `ping-restart` (~5 минут).
|
||||||
|
|
||||||
На `whitelist` OpenVPN идёт через группу `OVPN-EXIT` — один раз выбрать в дашборде RU-ноду.
|
На `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
|
### OpenVPN под видом OpenVPN Connect
|
||||||
|
|
||||||
Для сервера BMSTU роутер выглядит как OpenVPN Connect 3.7.1 (5558) на macOS. Обычный
|
Для VPN-сервера роутер выглядит как OpenVPN Connect 3.7.1 (5558) на macOS. Обычный
|
||||||
mihomo представляется сам (`IV_VER=mihomo-openvpn`, `IV_PROTO=22`, своя строка опций), и в
|
mihomo представляется сам (`IV_VER=mihomo-openvpn`, `IV_PROTO=22`, своя строка опций), и в
|
||||||
логах сервера это видно. Маскировку дают ядро kit (правка
|
логах сервера это видно. Маскировку дают ядро kit (правка
|
||||||
`tools/core/openvpn-connect-mimic.patch`) и `bmstu-otp.sh`, который пишет в провайдер
|
`tools/core/openvpn-connect-mimic.patch`) и `ovpn.sh`, который пишет в провайдер
|
||||||
поля `options-string` и `peer-info-raw`.
|
поля `options-string` и `peer-info-raw`.
|
||||||
|
|
||||||
Совпадает с Connect:
|
Совпадает с Connect:
|
||||||
@ -120,15 +228,27 @@ mihomo представляется сам (`IV_VER=mihomo-openvpn`, `IV_PROTO=2
|
|||||||
повторяет позже, а не считает пароль отклонённым), `DNS_OPTION_V2` (DNS из `dns server …`
|
повторяет позже, а не считает пароль отклонённым), `DNS_OPTION_V2` (DNS из `dns server …`
|
||||||
ядро берёт так же, как из `dhcp-option DNS`), `AUTH_PENDING_KW` и `PUSH_UPDATE` (сообщения,
|
ядро берёт так же, как из `dhcp-option DNS`), `AUTH_PENDING_KW` и `PUSH_UPDATE` (сообщения,
|
||||||
которые ядро пропускает);
|
которые ядро пропускает);
|
||||||
- пароль в формате `SCRV1`, как отправляет Connect при `static-challenge`;
|
- код TOTP в формате `SCRV1`, как отправляет Connect при `static-challenge`;
|
||||||
- `ping 60`, `ping-restart 300` — то, что присылает сервер;
|
- `ping 60`, `ping-restart 300` — то, что обычно присылает сервер;
|
||||||
- туннель держится всё время, как у Connect (`auto-connect` у прокси). Он поднимается сразу
|
- туннель держится всё время, как у Connect (`auto-connect` у прокси). Он поднимается сразу
|
||||||
при загрузке провайдера, без ожидания трафика: init-скрипт nikki перед стартом mihomo
|
при загрузке провайдера, без ожидания трафика: init-скрипт nikki перед стартом mihomo
|
||||||
пишет провайдер со свежим OTP (`bmstu-otp.sh write`). После обрыва ядро через 2 с
|
пишет провайдер со свежим кодом (`ovpn.sh write`). После обрыва ядро переподключается
|
||||||
переподключается само, с auth-token сессии вместо пароля и OTP; если не вышло, пауза
|
само, с auth-token сессии вместо пароля и кода. Если сервер токен не принял (AUTH_FAILED),
|
||||||
удваивается до минуты, чтобы недоступный сервер не забивал лог. Если сервер токен не
|
ядро больше не пробует — как Connect, который тогда просит новый код, — и туннель
|
||||||
принял (AUTH_FAILED), ядро больше не пробует — как Connect, который тогда просит новый
|
поднимает cron (`ovpn.sh check`) со свежим кодом;
|
||||||
OTP, — и туннель поднимает cron (`bmstu-otp.sh check`) со свежим OTP;
|
- быстрых переподключений нет: некоторые серверы на моментальный реконнект после обрыва
|
||||||
|
или кика отвечают блокировкой учётки. После любого обрыва (в том числе молчаливого), неудачной
|
||||||
|
попытки или отказа в авторизации ядро ждёт `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
|
- при закрытии (`off`, перезапуск nikki, новый провайдер) сервер получает EXIT
|
||||||
(`cc-exit`) и сразу освобождает сессию.
|
(`cc-exit`) и сразу освобождает сессию.
|
||||||
|
|
||||||
@ -137,10 +257,10 @@ OpenSSL, поэтому набор шифров и расширений в Clien
|
|||||||
разборе трафика, в логах сервера — нет.
|
разборе трафика, в логах сервера — нет.
|
||||||
|
|
||||||
Без ядра kit (`stock`, `official`) эти поля игнорируются, и сервер снова видит mihomo.
|
Без ядра kit (`stock`, `official`) эти поля игнорируются, и сервер снова видит mihomo.
|
||||||
Выключить маскировку: `OVPN_MIMIC=mihomo` в `bmstu.env`. После обновления Connect — взять
|
Выключить маскировку: `OVPN_MIMIC=mihomo` в `openvpn.env`. После обновления Connect — взять
|
||||||
новые строки `Tunnel Options` и `Sending Peer Info` из его лога
|
новые строки `Tunnel Options` и `Sending Peer Info` из его лога
|
||||||
(`~/Library/Application Support/OpenVPN Connect/log/ovpn.log`) и поправить
|
(`~/Library/Application Support/OpenVPN Connect/log/ovpn.log`) и поправить
|
||||||
`mimic_connect_mac` в `router/bmstu-otp.sh`.
|
`mimic_connect_mac` в `router/ovpn.sh`.
|
||||||
|
|
||||||
## Обслуживание
|
## Обслуживание
|
||||||
|
|
||||||
@ -158,7 +278,7 @@ mihomo-kit.sh build # после правки /etc/nikki/profiles.d/*.
|
|||||||
| `/etc/nikki/profiles.d/common.env` | подписки, BOOT, модули (секреты, 600) |
|
| `/etc/nikki/profiles.d/common.env` | подписки, BOOT, модули (секреты, 600) |
|
||||||
| `/etc/nikki/profiles.d/main.env`, `whitelist.env` | профили поверх common.env |
|
| `/etc/nikki/profiles.d/main.env`, `whitelist.env` | профили поверх common.env |
|
||||||
| `/etc/nikki/profiles/*.yaml` | собранные конфиги, их запускает nikki |
|
| `/etc/nikki/profiles/*.yaml` | собранные конфиги, их запускает nikki |
|
||||||
| `/etc/nikki/bmstu.env`, `bmstu.ovpn` | OpenVPN: логин, пароль, TOTP-секрет |
|
| `/etc/nikki/openvpn.env`, `openvpn.ovpn` | OpenVPN: логин, пароль, TOTP-секрет; профиль `.ovpn` |
|
||||||
| `/etc/nikki/run/tailscale/` | ключ ноды Tailscale — не удалять |
|
| `/etc/nikki/run/tailscale/` | ключ ноды Tailscale — не удалять |
|
||||||
|
|
||||||
У каждой подписки есть имя — так называется провайдер в дашборде, и к нему привязаны
|
У каждой подписки есть имя — так называется провайдер в дашборде, и к нему привязаны
|
||||||
@ -188,16 +308,175 @@ BOOT — whitelisted seed-ноды для скачивания подписок:
|
|||||||
рвётся, когда меняется нода под ним, — отсюда пропадающие уведомления. Отключается
|
рвётся, когда меняется нода под ним, — отсюда пропадающие уведомления. Отключается
|
||||||
галочкой «Обход для пушей» (`PUSH=0` в `common.env`) — тогда пуши идут по общим правилам.
|
галочкой «Обход для пушей» (`PUSH=0` в `common.env`) — тогда пуши идут по общим правилам.
|
||||||
|
|
||||||
Свои серверы hysteria2 — LuCI → Настройка → «Свои серверы» (или `HY2="имя1 имя2"` и
|
Сервисы — сайты и приложения, которые всегда идут своим путём, что бы ни было выбрано в
|
||||||
`HY2_<ИМЯ>_SERVER/_PORT/_PASSWORD/_OBFS_PASSWORD/_SNI/_INSECURE/_UP/_DOWN` в
|
`MAIN`: LuCI → вкладка «Пулы и сервисы» (кнопка «+ Claude» добавляет готовый). У каждого
|
||||||
`common.env`). Они собираются в группу `MY` (url-test: самый быстрый живой; в дашборде
|
сервиса своя группа в дашборде (имя заглавными: `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: самый быстрый живой; в дашборде
|
||||||
можно закрепить конкретный). `MY` — пункт в `MAIN` рядом с `FOREIGN` (переключать
|
можно закрепить конкретный). `MY` — пункт в `MAIN` рядом с `FOREIGN` (переключать
|
||||||
вручную). К самим серверам на `whitelist` подключение через группу `MY-EXIT` (те же ноды,
|
вручную). К самим серверам на `whitelist` и с телефона подключение через группу `MY-EXIT`
|
||||||
что в `FOREIGN`, но с `tolerance: 300`: меняет ноду, только если текущая заметно хуже или
|
(те же ноды, что в `FOREIGN`, но с `tolerance: 300`: меняет ноду, только если текущая
|
||||||
умерла — каждая смена рвёт всё, что идёт через `MY`), на `main` — напрямую.
|
заметно хуже или умерла — каждая смена рвёт всё, что идёт через `MY`), на `main` —
|
||||||
|
напрямую, с CSQTT — через `UPLINK`. `dialer-proxy` из YAML сервера отбрасывается: его ставит kit.
|
||||||
|
|
||||||
|
Старые настройки по-прежнему собираются: 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 ([star-panel-csqtt](https://github.com/starkugz/csqtt-openwrt)) — резервный выход из белых
|
||||||
списков: галка «CSQTT» в LuCI → Настройка (`CSQTT=1` в `common.env`). Пакет ставится и
|
списков: галка «Включить CSQTT» на вкладке «CSQTT» в LuCI (`CSQTT=1` в `common.env`). Пакет ставится и
|
||||||
настраивается отдельно, в своей панели (Службы → star-panel-csqtt); он поднимает интерфейс
|
настраивается отдельно, в своей панели (Службы → star-panel-csqtt); он поднимает интерфейс
|
||||||
`csqtt0` и маршруты не меняет. Kit добавляет прокси `CSQTT` (`type: direct`,
|
`csqtt0` и маршруты не меняет. Kit добавляет прокси `CSQTT` (`type: direct`,
|
||||||
`interface-name: csqtt0`) и группу `UPLINK` — через что подключаться к нодам подписок, BOOT
|
`interface-name: csqtt0`) и группу `UPLINK` — через что подключаться к нодам подписок, BOOT
|
||||||
@ -230,19 +509,19 @@ VK-токен). Кнопка Stop в панели csqtt останавливае
|
|||||||
и трафик идёт по правилу `100.64.0.0/10` в `TAILSCALE`. В тейлнете должен быть включён
|
и трафик идёт по правилу `100.64.0.0/10` в `TAILSCALE`. В тейлнете должен быть включён
|
||||||
MagicDNS (админка Tailscale → DNS).
|
MagicDNS (админка Tailscale → DNS).
|
||||||
|
|
||||||
Проверка туннелей: у групп `BMSTU` и `TAILSCALE` свой адрес проверки — LuCI → Настройка
|
Проверка туннелей: у групп `OPENVPN` и `TAILSCALE` свой адрес проверки — LuCI, вкладки
|
||||||
(«Адрес для проверки» в блоках OpenVPN и Tailscale) или `OVPN_CHECK_URL` (по умолчанию
|
«OpenVPN» и «Tailscale» («Адрес для проверки») или `OVPN_CHECK_URL` (страница за VPN;
|
||||||
`https://eu.bmstu.ru`) / `TS_CHECK_URL` (HTTP-сервис на ноде тейлнета, по умолчанию
|
пусто — `generate_204` Google) / `TS_CHECK_URL` (HTTP-сервис на ноде тейлнета, по умолчанию
|
||||||
`http://100.69.216.50:8080`) в `common.env`.
|
`http://100.69.216.50:8080`) в `common.env`.
|
||||||
Кнопка проверки задержки этих групп в дашборде открывает его через туннель (если дашборд
|
Кнопка проверки задержки этих групп в дашборде открывает его через туннель (если дашборд
|
||||||
берёт адрес из группы); сами по таймеру они не проверяются. На странице mihomo-kit их
|
берёт адрес из группы); сами по таймеру они не проверяются. На странице mihomo-kit их
|
||||||
открывает кнопка «Проверить» (у OpenVPN — «Проверка сайта», `bmstu-otp.sh probe`).
|
открывает кнопка «Проверить» (у OpenVPN — «Проверка сайта», `ovpn.sh probe`).
|
||||||
|
|
||||||
OpenVPN сам ничего через туннель не проверяет. Connect таких запросов не делает, а
|
OpenVPN сам ничего через туннель не проверяет. Connect таких запросов не делает, а
|
||||||
URL-тест виден в логах сайта, который он открывает: `HEAD /` от Go-клиента, по таймеру.
|
URL-тест виден в логах сайта, который он открывает: `HEAD /` от Go-клиента, по таймеру.
|
||||||
Поэтому с ядром kit состояние туннеля (подключён с такого-то времени, подключается, сервер
|
Поэтому с ядром kit состояние туннеля (подключён с такого-то времени, подключается, сервер
|
||||||
не принял сессию) берётся из API mihomo — ядро отдаёт его в поле `openvpn` прокси, — и
|
не принял сессию) берётся из API mihomo — ядро отдаёт его в поле `openvpn` прокси, — и
|
||||||
cron, LuCI («Состояние») и `bmstu-otp.sh status` не шлют ни одного запроса. Новый OTP
|
cron, LuCI («Состояние») и `ovpn.sh status` не шлют ни одного запроса. Новый код
|
||||||
cron даёт, только если сервер не принял токен сессии или туннель не поднимается 5 минут
|
cron даёт, только если сервер не принял токен сессии или туннель не поднимается 5 минут
|
||||||
(`DOWN_GRACE`). Ядра `stock`/`official` состояние не отдают: с ними cron открывает адрес
|
(`DOWN_GRACE`). Ядра `stock`/`official` состояние не отдают: с ними cron открывает адрес
|
||||||
проверки не чаще раза в 10 минут (`PROBE_EVERY`), в случайную секунду.
|
проверки не чаще раза в 10 минут (`PROBE_EVERY`), в случайную секунду.
|
||||||
@ -255,50 +534,88 @@ cron даёт, только если сервер не принял токен
|
|||||||
|
|
||||||
| Фикс | Зачем |
|
| Фикс | Зачем |
|
||||||
|---|---|
|
|---|---|
|
||||||
| ядро kit `v1.19.32-ts4` вместо ядра из пакета | в v1.19.29 OpenVPN не проходит рукопожатие; Tailscale через `dialer-proxy` и маскировка OpenVPN — только в ядре kit |
|
| ядро kit `v1.19.34-ts8` вместо ядра из пакета | в v1.19.29 OpenVPN не проходит рукопожатие; Tailscale через `dialer-proxy` и маскировка OpenVPN — только в ядре kit |
|
||||||
| `TS_FORCE_NOISE_443=true` в `/etc/init.d/nikki` | провайдер ломает control-соединение Tailscale на порту 80, вход зависает |
|
| `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 и внутренние сети BMSTU мимо mihomo |
|
| убрать `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 тейлнета |
|
| `ts.net` в `rebind_domain` dnsmasq | иначе защита от DNS rebinding отбрасывает адреса 100.x тейлнета |
|
||||||
| metric: `wan`/`wan6` — 10, остальные выходы (модемы, wifi-клиент) — 50, 60, … (если не заданы руками) | при живом проводе интернет идёт по проводу, модемы — запасные |
|
| metric: `wan`/`wan6` — 10, остальные выходы (модемы, wifi-клиент) — 50, 60, … (если не заданы руками) | при живом проводе интернет идёт по проводу, модемы — запасные |
|
||||||
| cron `bmstu-otp.sh check` раз в минуту | держит туннель по расписанию/таймеру; со свежим OTP поднимает, если сервер не принял токен сессии или туннель долго лежит (состояние из ядра, без запросов через туннель) |
|
| cron `ovpn.sh check` раз в минуту | держит туннель по расписанию/таймеру; со свежим кодом поднимает, если сервер не принял токен сессии или туннель долго лежит (состояние из ядра, без запросов через туннель) |
|
||||||
| `bmstu-otp.sh write` в `/etc/init.d/nikki` | провайдер OpenVPN со свежим OTP перед стартом mihomo: ядро kit подключается сразу |
|
| `ovpn.sh write` в `/etc/init.d/nikki` | провайдер OpenVPN (со свежим кодом, если нужен) перед стартом mihomo: ядро kit подключается сразу |
|
||||||
| `GOMEMLIMIT` в `/etc/init.d/nikki` (только с `LITE=1`) | лимит памяти ядра для слабых роутеров, см. «Облегчённый режим» |
|
| `GOMEMLIMIT` в `/etc/init.d/nikki` (только с `LITE=1`) | лимит памяти ядра для слабых роутеров, см. «Облегчённый режим» |
|
||||||
| переустановка `libcurl4 curl`, если curl сломан | `Error relocating ... symbol not found` |
|
| переустановка `libcurl4 curl`, если curl сломан | `Error relocating ... symbol not found` |
|
||||||
|
|
||||||
## Телефон (FlClash)
|
Ещё `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 появится.
|
||||||
|
|
||||||
С роутера: LuCI → Настройка → галка «Конфиг для телефона» → «Сохранить и применить». На
|
## Телефон и компьютер
|
||||||
странице появится блок «Телефон (FlClash)» с QR-кодом и ссылкой
|
|
||||||
`http://<роутер>/mihomo-kit/<токен>.yaml`: FlClash → Профили → + → по ссылке (или QR).
|
Тот же обход можно взять в приложение на ядре 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=…`) — если страница открыта на самом телефоне.
|
||||||
Это `common.env`, собранный с `TARGET=mobile`: те же подписки, BOOT/`BOOT-AUTO`, HWID и
|
Это `common.env`, собранный с `TARGET=mobile`: те же подписки, BOOT/`BOOT-AUTO`, HWID и
|
||||||
RU-адреса, без OpenVPN, Tailscale, торрентов и `PUSH`; свои серверы — в `MY`, к ним всегда
|
RU-адреса, без OpenVPN, Tailscale, торрентов и `PUSH`; свои серверы — в `MY`, к ним всегда
|
||||||
через `MY-EXIT` (телефон часто на белых списках). Пересобирается вместе с профилями.
|
через `MY-EXIT` (телефон часто на белых списках). Пересобирается вместе с профилями.
|
||||||
|
|
||||||
Ссылка открывается только в сети роутера (вне дома FlClash просто не обновит профиль) и
|
Ссылка открывается только в сети роутера (вне дома приложение просто не обновит профиль) и
|
||||||
содержит ссылки подписок — токен и есть секрет; «Новая ссылка» (`mihomo-kit.sh mobile new`)
|
содержит ссылки подписок — токен и есть секрет; «Новая ссылка» (`mihomo-kit.sh mobile new`)
|
||||||
отзывает старую.
|
отзывает старую.
|
||||||
|
|
||||||
Без роутера — веб-конструктор:
|
|
||||||
|
|
||||||
Открыть [web/index.html](web/index.html) (из репозитория или со своего хостинга) →
|
|
||||||
«Телефон» → подписки и vless-ссылка BOOT → «Скачать» → FlClash: Профили → + → Файл.
|
|
||||||
Страница всё считает в браузере и никуда ничего не отправляет.
|
|
||||||
|
|
||||||
## Профили
|
## Профили
|
||||||
|
|
||||||
| | роутер `main` | роутер `whitelist` | роутер `foreign` | телефон |
|
| | роутер `main` | роутер `whitelist` | роутер `foreign` | телефон |
|
||||||
|---|---|---|---|---|
|
|---|---|---|---|---|
|
||||||
| подписки через `BOOT-AUTO` | ✓ | ✓ | ✓ | ✓ |
|
| подписки через `BOOT-AUTO` | ✓ | ✓ | ✓ | ✓ |
|
||||||
| `ru-inside` | напрямую | напрямую | через RU | напрямую |
|
| `ru-inside` | напрямую | напрямую | через RU | напрямую |
|
||||||
| остальные `.ru` / `.рф`, доп. IP (`RU_IPS`) | напрямую | через RU | через RU | через 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` |
|
| доп. IP / домены через FOREIGN, MY (`FOREIGN_*`, `MY_*`) | `FOREIGN` / `MY` | `FOREIGN` / `MY` | `FOREIGN` / `MY` | `FOREIGN` / `MY` |
|
||||||
| доп. домены через RU (`RU_DOMAINS`) | напрямую | через RU | через RU | через RU |
|
| доп. домены через RU (`RU_DOMAINS`) | напрямую | через RU | через RU | через RU |
|
||||||
|
| локальные адреса (`LOCAL_HOSTS`) | по LAN | по LAN | по LAN | — |
|
||||||
| всё остальное (`MAIN`) | `FOREIGN` | `FOREIGN` | напрямую (можно `MY`) | `FOREIGN` |
|
| всё остальное (`MAIN`) | `FOREIGN` | `FOREIGN` | напрямую (можно `MY`) | `FOREIGN` |
|
||||||
| торренты (порты 20000–20199) | ✓ | ✓ | ✓ | — |
|
| торренты (порты 20000–20199) | ✓ | ✓ | ✓ | — |
|
||||||
| OpenVPN | напрямую | через `OVPN-EXIT` (RU-нода) | через `OVPN-EXIT` (RU-нода) | — |
|
| OpenVPN | напрямую | через `OVPN-EXIT` (RU-нода) | через `OVPN-EXIT` (RU-нода) | — |
|
||||||
| Tailscale | напрямую | через `MY` (свои hysteria2), без них напрямую* | напрямую | — |
|
| Tailscale | напрямую | через `MY` (свои серверы и `[MY]`-ноды подписки), без них напрямую* | напрямую | — |
|
||||||
| свои серверы | напрямую | через `MY-EXIT` | напрямую | через `MY-EXIT` |
|
| свои серверы | напрямую | через `MY-EXIT` | напрямую | через `MY-EXIT` |
|
||||||
| пуши (`PUSH`, отключаемо) | `DIRECT` | `MY` | `DIRECT` | — |
|
| пуши (`PUSH`, отключаемо) | `DIRECT` | `MY` | `DIRECT` | — |
|
||||||
|
| сервисы (`SERVICES`) | своя группа | своя группа | своя группа | своя группа |
|
||||||
|
|
||||||
|
`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-нода, а
|
На `foreign` российские домены не попадают в исключения fake-ip: их разрешает RU-нода, а
|
||||||
для прямого трафика DNS — Cloudflare/Google вместо Яндекса.
|
для прямого трафика DNS — Cloudflare/Google вместо Яндекса.
|
||||||
@ -307,16 +624,24 @@ RU-адреса, без OpenVPN, Tailscale, торрентов и `PUSH`; сво
|
|||||||
он открывает UDP-сокет без адреса назначения, и любой прокси mihomo падает на его
|
он открывает UDP-сокет без адреса назначения, и любой прокси mihomo падает на его
|
||||||
резолве (`magicsock: Rebind IPv4 failed: failed to bind any ports`,
|
резолве (`magicsock: Rebind IPv4 failed: failed to bind any ports`,
|
||||||
[MetaCubeX/mihomo#3142](https://github.com/MetaCubeX/mihomo/issues/3142)). Поэтому kit
|
[MetaCubeX/mihomo#3142](https://github.com/MetaCubeX/mihomo/issues/3142)). Поэтому kit
|
||||||
ставит своё ядро `v1.19.32-ts4` — официальный v1.19.32 с правкой
|
ставит своё ядро `v1.19.34-ts8` — официальный v1.19.34 с правкой
|
||||||
`tools/core/tailscale-packet-listener.patch`: UDP-сокет открывается на роутере, а
|
`tools/core/tailscale-packet-listener.patch`: UDP-сокет открывается на роутере, а
|
||||||
control-сервер и DERP идут по TCP через `dialer-proxy`. На белых списках прямой UDP не
|
control-сервер и DERP идут по TCP через `dialer-proxy`. На белых списках прямой UDP не
|
||||||
проходит, и Tailscale работает через DERP — медленнее прямого соединения, но работает.
|
проходит, и Tailscale работает через DERP — медленнее прямого соединения, но работает.
|
||||||
|
|
||||||
Вторая правка того же ядра — `tools/core/openvpn-connect-mimic.patch`, маскировка OpenVPN
|
Вторая правка того же ядра — `tools/core/openvpn-connect-mimic.patch`, маскировка OpenVPN
|
||||||
под OpenVPN Connect (см. «OpenVPN под видом OpenVPN Connect»). Как собрать — в «Разработке».
|
под 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.
|
Если ядро не скачалось, `fix` оставляет текущее и запускает nikki.
|
||||||
|
|
||||||
Какое ядро на конкретном роутере — селект в «Обслуживании» (или
|
Какое ядро на конкретном роутере — селект на вкладке «Система» (или
|
||||||
`mihomo-kit.sh core stock|official|kit`), выбор хранится в `/etc/nikki/kit.env` как `CORE=`:
|
`mihomo-kit.sh core stock|official|kit`), выбор хранится в `/etc/nikki/kit.env` как `CORE=`:
|
||||||
- `stock` — ядро из пакета nikki/прошивки (`/usr/libexec/mihomo`), ничего не качается, место
|
- `stock` — ядро из пакета nikki/прошивки (`/usr/libexec/mihomo`), ничего не качается, место
|
||||||
во флеше освобождается;
|
во флеше освобождается;
|
||||||
@ -324,7 +649,17 @@ control-сервер и DERP идут по TCP через `dialer-proxy`. На
|
|||||||
- `kit` (по умолчанию) — своя сборка `CORE_KIT`: официальное ядро с правками kit (см. «Ядро kit»).
|
- `kit` (по умолчанию) — своя сборка `CORE_KIT`: официальное ядро с правками kit (см. «Ядро kit»).
|
||||||
|
|
||||||
Распакованному ядру нужно ~56 МБ во флеше: на роутерах с маленьким `/overlay` остаётся
|
Распакованному ядру нужно ~56 МБ во флеше: на роутерах с маленьким `/overlay` остаётся
|
||||||
`stock`. Версии `CORE_OFFICIAL`/`CORE_KIT` задаются в `router/mihomo-kit.sh` — роутеры с
|
`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=…` в
|
выбором `official`/`kit` подтягивают их при обновлении kit. Явный `MIHOMO_VERSION=…` в
|
||||||
`kit.env` главнее выбора. Когда исправление появится в mihomo, вернуть официальный релиз.
|
`kit.env` главнее выбора. Когда исправление появится в mihomo, вернуть официальный релиз.
|
||||||
|
|
||||||
@ -338,7 +673,7 @@ opkg сравнивает полный размер новых пакетов с
|
|||||||
новых, с запасом 2 МБ (`PKG_RESERVE_KB`). Не влезает — ничего не ставит. Влезает —
|
новых, с запасом 2 МБ (`PKG_RESERVE_KB`). Не влезает — ничего не ставит. Влезает —
|
||||||
останавливает nikki (запущенное ядро держит свой старый файл на флеше), ставит с
|
останавливает nikki (запущенное ядро держит свой старый файл на флеше), ставит с
|
||||||
`--force-space` и делает `fix`: обновление nikki перезаписывает `/etc/init.d/nikki`, и
|
`--force-space` и делает `fix`: обновление nikki перезаписывает `/etc/init.d/nikki`, и
|
||||||
правки kit (`TS_FORCE_NOISE_443`, OTP, `GOMEMLIMIT`) нужно вернуть.
|
правки kit (`TS_FORCE_NOISE_443`, провайдер OpenVPN, `GOMEMLIMIT`) нужно вернуть.
|
||||||
|
|
||||||
### Облегчённый режим (`LITE=1`)
|
### Облегчённый режим (`LITE=1`)
|
||||||
|
|
||||||
@ -364,9 +699,10 @@ opkg сравнивает полный размер новых пакетов с
|
|||||||
|
|
||||||
## Если что-то не работает
|
## Если что-то не работает
|
||||||
|
|
||||||
- **OpenVPN** `tunnel did not come up`: `bmstu-otp.sh debug` покажет настоящую ошибку.
|
- **OpenVPN** `tunnel did not come up`: `ovpn.sh debug` покажет настоящую ошибку.
|
||||||
`read hard reset response` — до сервера не доходят пакеты (zeroblock, правило для IP
|
`read hard reset response` — до сервера не доходят пакеты (zeroblock, правило для IP
|
||||||
сервера); `AUTH_FAILED` — формат пароля (`PASS_FORMAT` в `bmstu.env`, сейчас `scrv1`, как у OpenVPN Connect).
|
сервера); `AUTH_FAILED` — неверный логин или пароль, а с TOTP ещё и формат кода: «Как
|
||||||
|
отправлять код» в настройках (`PASS_FORMAT` в `openvpn.env`) или неверное время на роутере.
|
||||||
- **Tailscale** без ссылки: `mihomo-kit.sh ts-login`. Ссылка пишется в лог один раз и
|
- **Tailscale** без ссылки: `mihomo-kit.sh ts-login`. Ссылка пишется в лог один раз и
|
||||||
только на уровне `info` (у nikki по умолчанию `warning`), а неудачный первый запуск
|
только на уровне `info` (у nikki по умолчанию `warning`), а неудачный первый запуск
|
||||||
оставляет в `/etc/nikki/run/tailscale` состояние, с которым нода молчит — команда
|
оставляет в `/etc/nikki/run/tailscale` состояние, с которым нода молчит — команда
|
||||||
@ -378,54 +714,82 @@ opkg сравнивает полный размер новых пакетов с
|
|||||||
|
|
||||||
```
|
```
|
||||||
install.sh загрузчик: кит в /etc/nikki/kit + mihomo-kit.sh setup
|
install.sh загрузчик: кит в /etc/nikki/kit + mihomo-kit.sh setup
|
||||||
templates/ фрагменты конфига (общие для скрипта и страницы)
|
templates/ фрагменты конфига
|
||||||
presets/ профили, которые setup кладёт в profiles.d
|
presets/ профили, которые setup кладёт в profiles.d
|
||||||
router/
|
router/
|
||||||
mihomo-kit.sh сборка, setup-мастер, use/update/fix
|
mihomo-kit.sh сборка, setup-мастер, use/update/fix
|
||||||
bmstu-otp.sh OpenVPN BMSTU: TOTP в пароле, cron-сторож, on/off
|
ovpn.sh OpenVPN: провайдер из .ovpn (TOTP в пароле), cron-сторож, on/off, расписание
|
||||||
luci/ страница LuCI «Службы → mihomo-kit»: rpcd.sh (бэкенд), view, ACL, меню
|
luci/ страница LuCI «Службы → mihomo-kit»: rpcd.sh (бэкенд), view, ACL, меню,
|
||||||
web/ страница-конструктор: engine.js + index.src.html → index.html
|
servers.js (ссылки и YAML своих серверов), qrcode.js
|
||||||
tools/ push.sh, test.sh, build-web.py, render.js
|
tools/ push.sh, test.sh, test-servers.js, servers-ref.sh + servers-ref/ (эталоны
|
||||||
tests/fixtures/ профили для test.sh (фиктивные секреты)
|
для 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
|
||||||
```
|
```
|
||||||
|
|
||||||
Шаблоны: `templates/<секция>/NN-<модуль>[.<тег>...][.each].yaml`; секции собираются в
|
Шаблоны: `templates/<секция>/NN-<модуль>[.<тег>...][.each].yaml`; секции собираются в
|
||||||
порядке head, proxies, providers, sniffer, dns, groups, rules, файлы — по имени.
|
порядке head, proxies, providers, sniffer, dns, groups, rules, файлы — по имени.
|
||||||
|
|
||||||
- файл включается, если активны модуль и все теги; `.each` — по разу на элемент модуля
|
- файл включается, если активны модуль и все теги; `.each` — по разу на элемент модуля
|
||||||
(`sub` — подписка: `${SUB_NAME}`, `${SUB_URL}`; `hy2` — свой сервер: `${HY2_NAME}`, ...);
|
(`sub` — подписка: `${SUB_NAME}`, `${SUB_URL}`; `boot` — seed-нода: `${SEED_NAME}`, ...);
|
||||||
- `${@@VAR}` — строка повторяется для каждой строки `VAR` (пустая `VAR` — строки нет);
|
- `${@@VAR}` — строка повторяется для каждой строки `VAR` (пустая `VAR` — строки нет);
|
||||||
- `строка #@тег[,!тег]` — строка остаётся, только если условия выполнены;
|
- `строка #@тег[,!тег]` — строка остаётся, только если условия выполнены;
|
||||||
- `${@VAR}` — строка повторяется для каждого слова из `VAR`;
|
- `${@VAR}` — строка повторяется для каждого слова из `VAR`;
|
||||||
- `${VAR}` — подстановка.
|
- `${VAR}` — подстановка.
|
||||||
|
|
||||||
Теги: `base`, `sub`, `router`|`mobile`, `main`|`whitelist`|`foreign` (роутер), служебные `ovpn_exit` (whitelist, foreign), `hy2_exit` (whitelist, телефон), `boot`, `torrent`, `push`,
|
Теги: `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`, `hy2`, `csqtt`. Значения по умолчанию — `set_defaults` в
|
`openvpn`, `tailscale`, `ts_exit`, `my_links`, `local_hosts`, `csqtt`, `lite`. Значения по умолчанию — `set_defaults` в
|
||||||
`router/mihomo-kit.sh` и `DEFAULTS` в `web/engine.js` (держать одинаковыми).
|
`router/mihomo-kit.sh`.
|
||||||
|
|
||||||
### Ядро kit
|
### Ядро kit
|
||||||
|
|
||||||
Официальный mihomo плюс правки из `tools/core/*.patch` (Tailscale через `dialer-proxy`,
|
Официальный mihomo плюс правки из `tools/core/*.patch` (Tailscale через `dialer-proxy`,
|
||||||
маскировка OpenVPN). Нужны git и Go.
|
маскировка OpenVPN, версия клиента REALITY). Нужны git и Go.
|
||||||
|
|
||||||
1. `tools/core/build.sh v1.19.32 ts4` — клонирует mihomo `v1.19.32`, накладывает патчи и
|
1. `tools/core/build.sh v1.19.34 ts8` — клонирует mihomo `v1.19.34`, накладывает патчи и
|
||||||
собирает `tools/core/dist/mihomo-linux-<arch>-v1.19.32-ts4.gz` для arm64, amd64, armv7,
|
собирает `tools/core/dist/mihomo-linux-<arch>-v1.19.34-ts8.gz` для arm64, amd64, armv7,
|
||||||
mips-softfloat, mipsle-softfloat.
|
mips-softfloat, mipsle-softfloat.
|
||||||
2. В репозитории kit создать релиз с тегом `core-v1.19.32-ts4` и приложить все `.gz`, не
|
2. В репозитории kit создать релиз с тегом `core-v1.19.34-ts8` и приложить все `.gz`, не
|
||||||
переименовывая: роутер качает `$MIHOMO_BASE/mihomo-linux-<arch>-<версия>.gz`.
|
переименовывая: роутер качает `$MIHOMO_BASE/mihomo-linux-<arch>-<версия>.gz`.
|
||||||
3. `CORE_KIT` в `router/mihomo-kit.sh` — та же версия. Пушить кит только после релиза:
|
3. `CORE_KIT` в `router/mihomo-kit.sh` — та же версия. Пушить кит только после релиза:
|
||||||
роутеры берут кит из `main` и иначе не найдут ядро.
|
роутеры берут кит из `main` и иначе не найдут ядро.
|
||||||
4. На роутере: `mihomo-kit.sh update` (новый кит; ядро меняется, если версия другая),
|
4. На роутере: `mihomo-kit.sh update` (новый кит; ядро меняется, если версия другая),
|
||||||
`mihomo-kit.sh fix` (ядро и init-скрипт nikki: свежий OTP перед стартом mihomo), затем
|
`mihomo-kit.sh fix` (ядро и init-скрипт nikki: провайдер OpenVPN перед стартом mihomo), затем
|
||||||
`bmstu-otp.sh refresh` (провайдер OpenVPN с новыми полями). Проверить:
|
`ovpn.sh refresh` (провайдер OpenVPN с новыми полями). Проверить:
|
||||||
`mihomo-kit.sh core-info`, `bmstu-otp.sh status`.
|
`mihomo-kit.sh core-info`, `ovpn.sh status`.
|
||||||
|
|
||||||
Новая версия mihomo или новая правка — следующий суффикс (`ts5`) в шагах 1–3. Патчи
|
Новая версия mihomo или новая правка — следующий суффикс (`ts9`) в шагах 1–3. Патчи
|
||||||
применяются по алфавиту; если не накладываются, поправить их на новом теге.
|
применяются по алфавиту; если не накладываются, поправить их на новом теге.
|
||||||
|
|
||||||
После правки шаблонов или движка:
|
### Зеркало nikki
|
||||||
|
|
||||||
|
Роутер ставит nikki из релиза `nikki-<NIKKI_VERSION>` репозитория kit (GitHub из России
|
||||||
|
часто недоступен). Обновить зеркало на новый релиз nikki (нужны curl, jq; токен Gitea с
|
||||||
|
правом `write:repository`):
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
MIHOMO=/path/to/mihomo tools/test.sh # sh и JS дают одинаковый YAML, mihomo -t проходит
|
GITEA_TOKEN=... tools/nikki-mirror.sh latest # все архитектуры, OpenWrt 24.10
|
||||||
tools/build-web.py # пересобрать web/index.html
|
GITEA_TOKEN=... tools/nikki-mirror.sh v1.26.2 aarch64_cortex-a53 mipsel_24kc # только эти
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Скрипт создаёт релиз `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
Normal file
60
TODO.md
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
# Технический долг и планы
|
||||||
|
|
||||||
|
Что стоит сделать в 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,7 +12,13 @@ KIT_DIR=/etc/nikki/kit
|
|||||||
here=$(cd "$(dirname "$0")" 2>/dev/null && pwd || echo /nonexistent)
|
here=$(cd "$(dirname "$0")" 2>/dev/null && pwd || echo /nonexistent)
|
||||||
mkdir -p "$KIT_DIR"
|
mkdir -p "$KIT_DIR"
|
||||||
if [ -f "$here/router/mihomo-kit.sh" ]; then
|
if [ -f "$here/router/mihomo-kit.sh" ]; then
|
||||||
[ "$here" = "$KIT_DIR" ] || cp -r "$here/templates" "$here/presets" "$here/router" "$here/luci" "$KIT_DIR/"
|
# 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
|
||||||
else
|
else
|
||||||
tmp=/tmp/mihomo-kit.$$
|
tmp=/tmp/mihomo-kit.$$
|
||||||
mkdir -p "$tmp"
|
mkdir -p "$tmp"
|
||||||
@ -32,5 +38,16 @@ else
|
|||||||
echo "${sha:-?} $(date '+%Y-%m-%d %H:%M')" > "$KIT_DIR/VERSION"
|
echo "${sha:-?} $(date '+%Y-%m-%d %H:%M')" > "$KIT_DIR/VERSION"
|
||||||
rm -rf "$tmp"
|
rm -rf "$tmp"
|
||||||
fi
|
fi
|
||||||
# stdin may be the piped script: the wizard (setup --cli) reads answers from /dev/tty
|
# stdin may be the piped script: the wizard (setup --cli) reads answers from /dev/tty.
|
||||||
exec sh "$KIT_DIR/router/mihomo-kit.sh" setup "$@"
|
# 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"
|
||||||
|
|||||||
@ -3,12 +3,12 @@
|
|||||||
"description": "mihomo-kit: profiles, OpenVPN, Tailscale, CSQTT",
|
"description": "mihomo-kit: profiles, OpenVPN, Tailscale, CSQTT",
|
||||||
"read": {
|
"read": {
|
||||||
"ubus": {
|
"ubus": {
|
||||||
"mihomo-kit": [ "status", "ovpn_status", "ovpn_probe", "csqtt_status", "job", "update_check", "ts_check" ]
|
"mihomo-kit": [ "status", "ovpn_status", "ovpn_probe", "csqtt_status", "job", "update_check", "ts_check", "graph", "api" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"write": {
|
"write": {
|
||||||
"ubus": {
|
"ubus": {
|
||||||
"mihomo-kit": [ "run", "config_get", "config_set", "export", "import" ]
|
"mihomo-kit": [ "run", "config_get", "config_set", "export", "import", "group", "services_set" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1645
luci/graph.js
Normal file
1645
luci/graph.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -3,11 +3,26 @@
|
|||||||
"title": "mihomo-kit",
|
"title": "mihomo-kit",
|
||||||
"order": 61,
|
"order": 61,
|
||||||
"action": {
|
"action": {
|
||||||
"type": "view",
|
"type": "firstchild"
|
||||||
"path": "mihomo-kit"
|
|
||||||
},
|
},
|
||||||
"depends": {
|
"depends": {
|
||||||
"acl": [ "luci-app-mihomo-kit" ]
|
"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"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
157
luci/mihomo-kit-graph.js
Normal file
157
luci/mihomo-kit-graph.js
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
'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
|
||||||
|
});
|
||||||
File diff suppressed because it is too large
Load Diff
312
luci/rpcd.sh
312
luci/rpcd.sh
@ -3,8 +3,8 @@
|
|||||||
#
|
#
|
||||||
# status profile, nikki running, which features are on, kit version,
|
# status profile, nikki running, which features are on, kit version,
|
||||||
# mihomo API port/secret (dashboard link)
|
# mihomo API port/secret (dashboard link)
|
||||||
# ovpn_status OpenVPN state (bmstu-otp.sh state: mode, schedule, tunnel from the core,
|
# ovpn_status OpenVPN state (ovpn.sh state: mode, schedule, tunnel from the core,
|
||||||
# no traffic) + current OTP
|
# 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)
|
# 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)
|
# csqtt_status CSQTT state (mihomo-kit.sh csqtt state: csqtt status + group UPLINK)
|
||||||
# run start a whitelisted command as the background job
|
# run start a whitelisted command as the background job
|
||||||
@ -15,6 +15,15 @@
|
|||||||
# import {data, keep_local}: replace the settings with an export, as the job
|
# 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_get settings for the form (secrets: only whether they are set)
|
||||||
# config_set save the form (via "mihomo-kit.sh configure") as the job
|
# 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.
|
# rpcd kills calls after ~30 s; use/update/ts-login take longer, hence the job.
|
||||||
|
|
||||||
@ -40,7 +49,7 @@ q() { printf "'%s'" "$(printf '%s' "$1" | sed "s/'/'\\\\''/g")"; }
|
|||||||
|
|
||||||
job_running() { [ -f "$JOB/pid" ] && kill -0 "$(cat "$JOB/pid")" 2>/dev/null; }
|
job_running() { [ -f "$JOB/pid" ] && kill -0 "$(cat "$JOB/pid")" 2>/dev/null; }
|
||||||
|
|
||||||
# mihomo API base URL from nikki's mixin settings (as in bmstu-otp.sh)
|
# mihomo API base URL from nikki's mixin settings (as in ovpn.sh)
|
||||||
api_url() {
|
api_url() {
|
||||||
l=$(uci -q get nikki.mixin.api_listen)
|
l=$(uci -q get nikki.mixin.api_listen)
|
||||||
port=${l##*:} host=${l%:*}
|
port=${l##*:} host=${l%:*}
|
||||||
@ -129,18 +138,18 @@ delay_check() {
|
|||||||
|
|
||||||
m_ovpn_status() {
|
m_ovpn_status() {
|
||||||
json_init
|
json_init
|
||||||
# what decides the tunnel now and the next change (bmstu-otp.sh state); only
|
# what decides the tunnel now and the next change (ovpn.sh state); only
|
||||||
# known keys with plain values get through to eval
|
# known keys with plain values get through to eval
|
||||||
eval "$(bmstu-otp.sh state 2>/dev/null |
|
eval "$(ovpn.sh state 2>/dev/null |
|
||||||
sed -En -e 's/^(mode|want|tunnel|link|up_since|up_hm|up_day|until|until_hm|until_day|after|why|next|next_to|next_hm|next_day|win|sched|sched_start|sched_end|sched_days|jitter)=([A-Za-z0-9:._-]*)$/st_\1=\2/p' \
|
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")"
|
-e "s/^err='([^'\`\$\\\\]*)'\$/st_err='\\1'/p")"
|
||||||
for k in mode tunnel link up_hm up_day err until_hm until_day after why next_to next_hm next_day win sched_start sched_end sched_days; do
|
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:-}\""
|
eval "json_add_string $k \"\${st_$k:-}\""
|
||||||
done
|
done
|
||||||
for k in want up_since until next sched jitter; do
|
for k in want up_since until next sched sched_active timer_max jitter; do
|
||||||
eval "json_add_int $k \"\${st_$k:-0}\""
|
eval "json_add_int $k \"\${st_$k:-0}\""
|
||||||
done
|
done
|
||||||
json_add_string otp "$(bmstu-otp.sh otp 2>/dev/null)"
|
json_add_string otp "$(ovpn.sh otp 2>/dev/null)"
|
||||||
json_add_int otp_left "$((30 - $(date +%s) % 30))"
|
json_add_int otp_left "$((30 - $(date +%s) % 30))"
|
||||||
json_dump
|
json_dump
|
||||||
}
|
}
|
||||||
@ -165,7 +174,7 @@ m_ovpn_probe() {
|
|||||||
prof=$(uci -q get nikki.config.profile)
|
prof=$(uci -q get nikki.config.profile)
|
||||||
prof=${prof#file:}
|
prof=${prof#file:}
|
||||||
group=$(envval OVPN_GROUP "${prof%.yaml}")
|
group=$(envval OVPN_GROUP "${prof%.yaml}")
|
||||||
delay_check "${group:-BMSTU}" OVPN_CHECK_URL https://eu.bmstu.ru
|
delay_check "${group:-OPENVPN}" OVPN_CHECK_URL https://www.gstatic.com/generate_204
|
||||||
json_dump
|
json_dump
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,13 +183,14 @@ m_run() {
|
|||||||
cmd=$(jsonfilter -s "$input" -e '@.cmd' 2>/dev/null)
|
cmd=$(jsonfilter -s "$input" -e '@.cmd' 2>/dev/null)
|
||||||
arg=$(jsonfilter -s "$input" -e '@.arg' 2>/dev/null)
|
arg=$(jsonfilter -s "$input" -e '@.arg' 2>/dev/null)
|
||||||
case "$cmd" in
|
case "$cmd" in
|
||||||
ovpn-on) set -- bmstu-otp.sh on ;;
|
ovpn-on) set -- ovpn.sh on ;;
|
||||||
ovpn-off) set -- bmstu-otp.sh off ;;
|
ovpn-off) set -- ovpn.sh off ;;
|
||||||
ovpn-refresh) set -- bmstu-otp.sh refresh ;;
|
ovpn-refresh) set -- ovpn.sh refresh ;;
|
||||||
ovpn-for)
|
ovpn-for | ovpn-extend)
|
||||||
case "$arg" in '' | *[!0-9]* | 0) reply_error "bad minutes" ;; esac
|
case "$arg" in '' | *[!0-9]* | 0) reply_error "bad minutes" ;; esac
|
||||||
set -- bmstu-otp.sh for "$arg"
|
set -- ovpn.sh "${cmd#ovpn-}" "$arg"
|
||||||
;;
|
;;
|
||||||
|
ovpn-stop) set -- ovpn.sh stop ;;
|
||||||
ovpn-sched)
|
ovpn-sched)
|
||||||
# arg: "off" | "on" | "HH:MM HH:MM [DAYS]" (DAYS: digits 1..7); unquoted below to split
|
# arg: "off" | "on" | "HH:MM HH:MM [DAYS]" (DAYS: digits 1..7); unquoted below to split
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
@ -190,7 +200,7 @@ m_run() {
|
|||||||
;;
|
;;
|
||||||
*) reply_error "bad schedule" ;;
|
*) reply_error "bad schedule" ;;
|
||||||
esac
|
esac
|
||||||
set -- bmstu-otp.sh sched $arg
|
set -- ovpn.sh sched $arg
|
||||||
;;
|
;;
|
||||||
use)
|
use)
|
||||||
case "$arg" in '' | *[!A-Za-z0-9_-]*) reply_error "bad profile name" ;; esac
|
case "$arg" in '' | *[!A-Za-z0-9_-]*) reply_error "bad profile name" ;; esac
|
||||||
@ -233,7 +243,7 @@ start_job() {
|
|||||||
|
|
||||||
m_config_get() {
|
m_config_get() {
|
||||||
[ -f "$PROFILES_D/common.env" ] && . "$PROFILES_D/common.env"
|
[ -f "$PROFILES_D/common.env" ] && . "$PROFILES_D/common.env"
|
||||||
[ -f "$NIKKI_DIR/bmstu.env" ] && . "$NIKKI_DIR/bmstu.env"
|
[ -f "$NIKKI_DIR/openvpn.env" ] && . "$NIKKI_DIR/openvpn.env"
|
||||||
[ -f /etc/openwrt_release ] && . /etc/openwrt_release
|
[ -f /etc/openwrt_release ] && . /etc/openwrt_release
|
||||||
json_init
|
json_init
|
||||||
json_add_boolean configured "$(b test -f "$PROFILES_D/common.env")"
|
json_add_boolean configured "$(b test -f "$PROFILES_D/common.env")"
|
||||||
@ -273,26 +283,55 @@ m_config_get() {
|
|||||||
json_add_string hwid_os_ver "${HWID_OS_VER:-${DISTRIB_RELEASE:-}}"
|
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_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)}"
|
json_add_string hwid_id "${HWID_ID:-$(md5sum < /sys/class/net/br-lan/address 2>/dev/null | cut -c1-16)}"
|
||||||
json_add_boolean torrent "${TORRENT:-1}"
|
# a new router: torrents and push off, the phone config on
|
||||||
json_add_boolean push "${PUSH:-1}"
|
json_add_boolean torrent "${TORRENT:-0}"
|
||||||
|
json_add_boolean push "${PUSH:-0}"
|
||||||
json_add_string ru_ips "${RU_IPS:-}"
|
json_add_string ru_ips "${RU_IPS:-}"
|
||||||
json_add_string foreign_ips "${FOREIGN_IPS:-}"
|
json_add_string foreign_ips "${FOREIGN_IPS:-}"
|
||||||
json_add_string my_ips "${MY_IPS:-}"
|
json_add_string my_ips "${MY_IPS:-}"
|
||||||
json_add_string ru_domains "${RU_DOMAINS:-}"
|
json_add_string ru_domains "${RU_DOMAINS:-}"
|
||||||
json_add_string foreign_domains "${FOREIGN_DOMAINS:-}"
|
json_add_string foreign_domains "${FOREIGN_DOMAINS:-}"
|
||||||
json_add_string my_domains "${MY_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 openvpn "${OPENVPN:-0}"
|
||||||
json_add_boolean csqtt "${CSQTT:-0}"
|
json_add_boolean csqtt "${CSQTT:-0}"
|
||||||
json_add_boolean ovpn_file "$(b test -f "$NIKKI_DIR/bmstu.ovpn")"
|
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_string vpn_username "${VPN_USERNAME:-}"
|
json_add_string vpn_username "${VPN_USERNAME:-}"
|
||||||
json_add_boolean has_vpn_password "$(b test -n "${VPN_PASSWORD:-}")"
|
json_add_boolean has_vpn_password "$(b test -n "${VPN_PASSWORD:-}")"
|
||||||
json_add_boolean has_totp "$(b test -n "${TOTP_SECRET:-}")"
|
json_add_boolean has_totp "$(b test -n "${TOTP_SECRET:-}")"
|
||||||
json_add_boolean tailscale "${TAILSCALE:-0}"
|
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_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 ts_domains "${TS_DOMAINS:-}"
|
||||||
json_add_string ovpn_check_url "${OVPN_CHECK_URL:-https://eu.bmstu.ru}"
|
json_add_string ovpn_check_url "${OVPN_CHECK_URL:-}"
|
||||||
json_add_string ts_check_url "${TS_CHECK_URL:-http://100.69.216.50:8080}"
|
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}"
|
json_add_boolean mobile "${MOBILE:-0}"
|
||||||
|
else
|
||||||
|
json_add_boolean mobile 1
|
||||||
|
fi
|
||||||
json_add_boolean lite "${LITE:-0}"
|
json_add_boolean lite "${LITE:-0}"
|
||||||
json_add_string lite_gomemlimit "${LITE_GOMEMLIMIT:-}"
|
json_add_string lite_gomemlimit "${LITE_GOMEMLIMIT:-}"
|
||||||
json_add_array hy2
|
json_add_array hy2
|
||||||
@ -311,8 +350,11 @@ m_config_get() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# {"data": {boot_links (one per line), subs: [{url, via, hwid}], hwid_*, torrent, push, ru_ips,
|
# {"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,
|
# 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,
|
# 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,
|
# tailscale, ts_hostname, ts_domains, lite, lite_gomemlimit, hy2: [{name, server, port, password,
|
||||||
# obfs_password, sni, insecure, up, down}]}}; empty OpenVPN secrets keep the saved ones
|
# obfs_password, sni, insecure, up, down}]}}; empty OpenVPN secrets keep the saved ones
|
||||||
m_config_set() {
|
m_config_set() {
|
||||||
@ -320,14 +362,25 @@ m_config_set() {
|
|||||||
json_select data || reply_error "no data"
|
json_select data || reply_error "no data"
|
||||||
job_running && reply_error "busy: $(cat "$JOB/cmd")"
|
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 \
|
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 openvpn csqtt ovpn \
|
ru_domains foreign_domains my_domains local_hosts my_links openvpn csqtt ovpn \
|
||||||
vpn_username vpn_password totp_secret tailscale ts_hostname ts_domains ovpn_check_url ts_check_url mobile \
|
vpn_username vpn_password totp_secret totp_clear pass_format tailscale ts_hostname ts_domains ovpn_check_url \
|
||||||
lite lite_gomemlimit; do
|
ts_check_url mobile lite lite_gomemlimit; do
|
||||||
json_get_var "$v" "$v" ""
|
json_get_var "$v" "$v" ""
|
||||||
done
|
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
|
if [ -n "$ovpn" ]; then
|
||||||
umask 077
|
umask 077
|
||||||
printf '%s\n' "$ovpn" > "$NIKKI_DIR/bmstu.ovpn.tmp" && mv "$NIKKI_DIR/bmstu.ovpn.tmp" "$NIKKI_DIR/bmstu.ovpn"
|
printf '%s\n' "$ovpn" > "$NIKKI_DIR/openvpn.ovpn.tmp" && mv "$NIKKI_DIR/openvpn.ovpn.tmp" "$NIKKI_DIR/openvpn.ovpn"
|
||||||
fi
|
fi
|
||||||
umask 077
|
umask 077
|
||||||
env=$(mktemp /tmp/mihomo-kit-form.XXXXXX) || reply_error "mktemp failed"
|
env=$(mktemp /tmp/mihomo-kit-form.XXXXXX) || reply_error "mktemp failed"
|
||||||
@ -365,11 +418,35 @@ m_config_set() {
|
|||||||
echo "RU_DOMAINS=$(q "$ru_domains")"
|
echo "RU_DOMAINS=$(q "$ru_domains")"
|
||||||
echo "FOREIGN_DOMAINS=$(q "$foreign_domains")"
|
echo "FOREIGN_DOMAINS=$(q "$foreign_domains")"
|
||||||
echo "MY_DOMAINS=$(q "$my_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 "OPENVPN=$(q "${openvpn:-0}")"
|
||||||
echo "CSQTT=$(q "${csqtt:-0}")"
|
echo "CSQTT=$(q "${csqtt:-0}")"
|
||||||
echo "VPN_USERNAME=$(q "$vpn_username")"
|
echo "VPN_USERNAME=$(q "$vpn_username")"
|
||||||
[ -n "$vpn_password" ] && echo "VPN_PASSWORD=$(q "$vpn_password")"
|
[ -n "$vpn_password" ] && echo "VPN_PASSWORD=$(q "$vpn_password")"
|
||||||
[ -n "$totp_secret" ] && echo "TOTP_SECRET=$(q "$totp_secret")"
|
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
|
||||||
echo "TAILSCALE=$(q "${tailscale:-0}")"
|
echo "TAILSCALE=$(q "${tailscale:-0}")"
|
||||||
echo "TS_HOSTNAME=$(q "$ts_hostname")"
|
echo "TS_HOSTNAME=$(q "$ts_hostname")"
|
||||||
echo "TS_DOMAINS=$(q "$ts_domains")"
|
echo "TS_DOMAINS=$(q "$ts_domains")"
|
||||||
@ -399,11 +476,186 @@ m_config_set() {
|
|||||||
json_select ..
|
json_select ..
|
||||||
fi
|
fi
|
||||||
echo "HY2=$(q "$hy2")"
|
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"
|
} > "$env"
|
||||||
umask 022
|
umask 022
|
||||||
start_job mihomo-kit.sh configure "$env"
|
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() {
|
m_ts_check() {
|
||||||
json_init
|
json_init
|
||||||
delay_check TAILSCALE TS_CHECK_URL http://100.69.216.50:8080
|
delay_check TAILSCALE TS_CHECK_URL http://100.69.216.50:8080
|
||||||
@ -456,7 +708,7 @@ m_job() {
|
|||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
list)
|
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}}'
|
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":[]}}'
|
||||||
;;
|
;;
|
||||||
call)
|
call)
|
||||||
case "$2" in
|
case "$2" in
|
||||||
@ -472,6 +724,10 @@ case "$1" in
|
|||||||
ts_check) m_ts_check ;;
|
ts_check) m_ts_check ;;
|
||||||
export) m_export ;;
|
export) m_export ;;
|
||||||
import) m_import ;;
|
import) m_import ;;
|
||||||
|
graph) m_graph ;;
|
||||||
|
api) m_api ;;
|
||||||
|
group) m_group ;;
|
||||||
|
services_set) m_services_set ;;
|
||||||
*) reply_error "unknown method" ;;
|
*) reply_error "unknown method" ;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
|||||||
1715
luci/servers.js
Normal file
1715
luci/servers.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,27 +0,0 @@
|
|||||||
# /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"
|
|
||||||
# scrv1 (default, as OpenVPN Connect: SCRV1:b64(pass):b64(otp)) | otp-last | otp-first
|
|
||||||
#PASS_FORMAT=scrv1
|
|
||||||
# connect-mac (default: present as OpenVPN Connect 3.7.1 for macOS) | mihomo
|
|
||||||
#OVPN_MIMIC=connect-mac
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
# 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 `bmstu-otp.sh sched ...`; shown here for reference.
|
|
||||||
#OVPN_SCHED=0
|
|
||||||
#OVPN_SCHED_START=09:00
|
|
||||||
#OVPN_SCHED_END=17:00
|
|
||||||
#OVPN_SCHED_JITTER=10
|
|
||||||
1344
router/mihomo-kit.sh
1344
router/mihomo-kit.sh
File diff suppressed because it is too large
Load Diff
3
router/nikki-key-build.pub
Normal file
3
router/nikki-key-build.pub
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
untrusted comment: Nikki
|
||||||
|
RWSrAXyIqregizvXvG9kJI/JoTkaCCPDy6CQrrVQ4IZ8Qgu+iWMql0UW
|
||||||
|
|
||||||
35
router/openvpn.env.example
Normal file
35
router/openvpn.env.example
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
# /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
|
||||||
@ -1,11 +1,11 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# OpenVPN (BMSTU) + TOTP for mihomo / nikki on OpenWrt.
|
# 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
|
# 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
|
# static. 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 brings
|
# OTP baked into the password when TOTP_SECRET is set), reloads the provider via
|
||||||
# the tunnel up while the code is still valid. After that the server's auth-token
|
# the mihomo API and brings the tunnel up while the code is still valid. After
|
||||||
# keeps rekeys alive without an OTP. With the kit core (auto-connect, as OpenVPN
|
# 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
|
# 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
|
# 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).
|
# rejected it waits for a provider with a fresh OTP (cron check).
|
||||||
@ -17,38 +17,46 @@
|
|||||||
# cores report no state: there the cron check probes, rarely and at random moments.
|
# cores report no state: there the cron check probes, rarely and at random moments.
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# bmstu-otp.sh otp print the current TOTP code
|
# ovpn.sh otp print the current TOTP code
|
||||||
# bmstu-otp.sh authfile print username/password lines (openvpn auth-user-pass file)
|
# ovpn.sh authfile print username/password lines (openvpn auth-user-pass file)
|
||||||
# bmstu-otp.sh refresh regenerate provider with fresh OTP, reload, warm up
|
# ovpn.sh refresh regenerate provider with fresh OTP, reload, warm up
|
||||||
# bmstu-otp.sh up bring the tunnel up if it should be up and does not answer
|
# ovpn.sh up bring the tunnel up if it should be up and does not answer
|
||||||
# bmstu-otp.sh write only regenerate the provider and routes (nikki init, before mihomo starts)
|
# ovpn.sh write only regenerate the provider and routes (nikki init, before mihomo starts)
|
||||||
# bmstu-otp.sh check reconcile to the desired state (timer/manual/schedule) and
|
# 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)
|
# refresh a dead tunnel (cron, once a minute; no traffic with the kit core)
|
||||||
# bmstu-otp.sh for N up for N minutes over the manual off and the schedule, then back
|
# Three modes, one at a time: on (always), off, schedule. A timer runs over any of them
|
||||||
# to whatever held before
|
# and hands back to the mode when it ends.
|
||||||
# bmstu-otp.sh sched ... off | on | HH:MM HH:MM [DAYS] | days DAYS: work-hours schedule
|
# ovpn.sh on always on: drops the manual off, the schedule and the timer
|
||||||
# (MSK; DAYS 12345 | weekdays | weekend | all), persisted
|
# ovpn.sh off close the tunnel and keep it closed: drops the schedule and the
|
||||||
# bmstu-otp.sh off close the tunnel and keep it closed (sticky, wins over the schedule,
|
# timer (the VPN's addresses go without it); frees the server
|
||||||
# cancels a timer; BMSTU traffic goes without it); frees the single
|
# session (the kit core sends EXIT; other cores leave it until
|
||||||
# server session (the kit core sends EXIT; other cores leave it until
|
|
||||||
# ping-restart, ~5 min)
|
# ping-restart, ~5 min)
|
||||||
# bmstu-otp.sh on drop the manual off and the timer: the schedule (if any) decides
|
# ovpn.sh sched on the schedule decides (drops the manual off; the timer stays)
|
||||||
# bmstu-otp.sh status what decides now, the next change, the tunnel state (no traffic)
|
# ovpn.sh sched off schedule off, the tunnel off (as "off", the timer stays)
|
||||||
# bmstu-otp.sh probe open CHECK_URL through the tunnel (a request the site can log)
|
# ovpn.sh sched HH:MM HH:MM [DAYS] | days DAYS: only store the work hours
|
||||||
# bmstu-otp.sh state the same as key=value lines (LuCI)
|
# (router time; DAYS 12345 | weekdays | weekend | all); "sched on" uses them
|
||||||
# bmstu-otp.sh want exit code: should the tunnel be up now
|
# ovpn.sh for N up for N minutes from now over the mode, then back to it
|
||||||
# bmstu-otp.sh debug show the real handshake error in the nikki log
|
# 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
|
set -u
|
||||||
|
|
||||||
ENV_FILE="${ENV_FILE:-/etc/nikki/bmstu.env}"
|
# 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"
|
[ -f "$ENV_FILE" ] && . "$ENV_FILE"
|
||||||
|
|
||||||
: "${OVPN_FILE:=/etc/nikki/bmstu.ovpn}"
|
: "${OVPN_FILE:=$(_old bmstu.ovpn openvpn.ovpn)}"
|
||||||
: "${PROVIDER_FILE:=/etc/nikki/run/providers/bmstu.yaml}"
|
: "${PROVIDER_FILE:=/etc/nikki/run/providers/openvpn.yaml}"
|
||||||
: "${PROVIDER_NAME:=bmstu}"
|
: "${PROVIDER_NAME:=openvpn}"
|
||||||
: "${PROXY_NAME:=bmstu-ovpn}"
|
: "${PROXY_NAME:=openvpn}"
|
||||||
: "${GROUP_NAME:=BMSTU}"
|
: "${GROUP_NAME:=OPENVPN}"
|
||||||
# API address/secret: from nikki's mixin settings unless set in the env file
|
# API address/secret: from nikki's mixin settings unless set in the env file
|
||||||
uci_get() { uci -q get "$1" 2>/dev/null; }
|
uci_get() { uci -q get "$1" 2>/dev/null; }
|
||||||
# api_listen is host:port; a wildcard/empty host means loopback works
|
# api_listen is host:port; a wildcard/empty host means loopback works
|
||||||
@ -61,14 +69,16 @@ api_from_uci() {
|
|||||||
}
|
}
|
||||||
: "${API:=$(api_from_uci)}"
|
: "${API:=$(api_from_uci)}"
|
||||||
: "${API_SECRET:=$(uci_get nikki.mixin.api_secret)}"
|
: "${API_SECRET:=$(uci_get nikki.mixin.api_secret)}"
|
||||||
# while this file exists the tunnel stays off (bmstu-otp.sh off/on); it is the
|
# while this file exists the tunnel stays off (ovpn.sh off/on); it is the
|
||||||
# sticky manual off and wins over the schedule
|
# sticky manual off and wins over the schedule
|
||||||
: "${OFF_FLAG:=/etc/nikki/bmstu.off}"
|
: "${OFF_FLAG:=$(_old bmstu.off openvpn.off)}"
|
||||||
# timer (bmstu-otp.sh for N): holds an epoch; the tunnel stays up until then,
|
# 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
|
# overriding the schedule, then this file is removed and the schedule resumes
|
||||||
: "${UNTIL_FLAG:=/etc/nikki/bmstu.until}"
|
: "${UNTIL_FLAG:=$(_old bmstu.until openvpn.until)}"
|
||||||
# schedule: with OVPN_SCHED=1 the tunnel is up only inside [START,END] local time
|
# the longest a timer (for / extend) reaches from now, minutes
|
||||||
# (the router is MSK). A deterministic per-day jitter of up to OVPN_SCHED_JITTER
|
: "${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.
|
# 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
|
# OVPN_SCHED_DAYS: weekdays the window opens on, digits 1 (Mon) .. 7 (Sun); a window
|
||||||
# past midnight belongs to the day it starts on.
|
# past midnight belongs to the day it starts on.
|
||||||
@ -76,7 +86,7 @@ api_from_uci() {
|
|||||||
: "${OVPN_SCHED_DAYS:=1234567}"
|
: "${OVPN_SCHED_DAYS:=1234567}"
|
||||||
# what "probe" opens through the tunnel: OVPN_CHECK_URL of the profiles (LuCI)
|
# 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:=$(sed -n 's/^OVPN_CHECK_URL=//p' /etc/nikki/profiles.d/common.env 2>/dev/null | tail -n 1 | tr -d "'\"")}"
|
||||||
: "${CHECK_URL:=https://eu.bmstu.ru}"
|
: "${CHECK_URL:=https://www.gstatic.com/generate_204}"
|
||||||
# ms, must exceed HANDSHAKE_TIMEOUT (max 32767)
|
# ms, must exceed HANDSHAKE_TIMEOUT (max 32767)
|
||||||
: "${CHECK_TIMEOUT:=25000}"
|
: "${CHECK_TIMEOUT:=25000}"
|
||||||
# cores without the tunnel state: the cron check probes at most every PROBE_EVERY
|
# cores without the tunnel state: the cron check probes at most every PROBE_EVERY
|
||||||
@ -85,11 +95,22 @@ api_from_uci() {
|
|||||||
# kit core: a tunnel that has not come up for this long gets a fresh OTP (it
|
# kit core: a tunnel that has not come up for this long gets a fresh OTP (it
|
||||||
# reconnects by itself meanwhile)
|
# reconnects by itself meanwhile)
|
||||||
: "${DOWN_GRACE:=300}"
|
: "${DOWN_GRACE:=300}"
|
||||||
# scrv1 - what openvpn / OpenVPN Connect send for "static-challenge ... 1" (the BMSTU
|
# kit core: no quick reconnects, a quick reconnect into a drop or a kick gets the
|
||||||
# profile): SCRV1:b64(pass):b64(otp)
|
# account blocked. After the tunnel went down, a failed connect or rejected
|
||||||
# otp-last - <password><otp> (the server accepts it too)
|
# 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>
|
# otp-first - <otp><password>
|
||||||
: "${PASS_FORMAT:=scrv1}"
|
# 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):
|
# 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
|
# connect-mac - OpenVPN Connect 3.7.1 (5558) for macOS, as its log shows them
|
||||||
# mihomo - what mihomo sends itself (IV_VER=mihomo-openvpn)
|
# mihomo - what mihomo sends itself (IV_VER=mihomo-openvpn)
|
||||||
@ -106,7 +127,7 @@ api_from_uci() {
|
|||||||
: "${MIXED_PORT:=$(uci_get nikki.mixin.mixed_port || echo 7890)}"
|
: "${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')")}"
|
: "${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; }
|
log() { logger -t openvpn "$*" 2>/dev/null; echo "$*" >&2; }
|
||||||
die() { log "error: $*"; exit 1; }
|
die() { log "error: $*"; exit 1; }
|
||||||
|
|
||||||
# --- TOTP (RFC 6238, HMAC-SHA1) --------------------------------------------
|
# --- TOTP (RFC 6238, HMAC-SHA1) --------------------------------------------
|
||||||
@ -163,9 +184,16 @@ fresh_totp() {
|
|||||||
|
|
||||||
b64() { printf '%s' "$1" | openssl base64 -A 2>/dev/null || printf '%s' "$1" | base64 | tr -d '\n'; }
|
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() {
|
make_password() {
|
||||||
otp=$1
|
[ -n "${TOTP_SECRET:-}" ] || { echo "$VPN_PASSWORD"; return; }
|
||||||
case "$PASS_FORMAT" in
|
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")" ;;
|
scrv1) echo "SCRV1:$(b64 "$VPN_PASSWORD"):$(b64 "$otp")" ;;
|
||||||
otp-first) echo "$otp$VPN_PASSWORD" ;;
|
otp-first) echo "$otp$VPN_PASSWORD" ;;
|
||||||
otp-last) echo "$VPN_PASSWORD$otp" ;;
|
otp-last) echo "$VPN_PASSWORD$otp" ;;
|
||||||
@ -196,6 +224,9 @@ mimic_connect_mac() {
|
|||||||
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\""
|
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)
|
# up right away, reconnect with the auth-token, EXIT on close (kit core)
|
||||||
echo " auto-connect: true"
|
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: |"
|
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 \
|
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_CIPHERS=AES-128-CBC:AES-192-CBC:AES-256-CBC:AES-128-GCM:AES-192-GCM:AES-256-GCM:CHACHA20-POLY1305 \
|
||||||
@ -210,21 +241,24 @@ write_provider() {
|
|||||||
[ -f "$OVPN_FILE" ] || die "no $OVPN_FILE"
|
[ -f "$OVPN_FILE" ] || die "no $OVPN_FILE"
|
||||||
[ -n "${VPN_USERNAME:-}" ] || die "VPN_USERNAME is empty"
|
[ -n "${VPN_USERNAME:-}" ] || die "VPN_USERNAME is empty"
|
||||||
[ -n "${VPN_PASSWORD:-}" ] || die "VPN_PASSWORD is empty"
|
[ -n "${VPN_PASSWORD:-}" ] || die "VPN_PASSWORD is empty"
|
||||||
[ -n "${TOTP_SECRET:-}" ] || die "TOTP_SECRET is empty"
|
|
||||||
|
|
||||||
# first "remote host port proto" line
|
# first "remote host port proto" line
|
||||||
set -- $(ovpn_opt remote)
|
set -- $(ovpn_opt remote)
|
||||||
host=$1 port=${2:-1194} proto=${3:-udp}
|
host=$1 port=${2:-1194} proto=${3:-udp}
|
||||||
case "$proto" in tcp*) proto=tcp ;; *) proto=udp ;; esac
|
case "$proto" in tcp*) proto=tcp ;; *) proto=udp ;; esac
|
||||||
fallback=$(ovpn_opt data-ciphers-fallback)
|
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 "$(fresh_totp)") || exit 1
|
pass=$(make_password) || exit 1
|
||||||
|
|
||||||
mkdir -p "$(dirname "$PROVIDER_FILE")"
|
mkdir -p "$(dirname "$PROVIDER_FILE")"
|
||||||
# per process: the init hook can write while a cron refresh does
|
# per process: the init hook can write while a cron refresh does
|
||||||
tmp="$PROVIDER_FILE.tmp.$$"
|
tmp="$PROVIDER_FILE.tmp.$$"
|
||||||
{
|
{
|
||||||
echo "# generated by bmstu-otp.sh at $(date '+%F %T') - do not edit"
|
echo "# generated by ovpn.sh at $(date '+%F %T') - do not edit"
|
||||||
echo "proxies:"
|
echo "proxies:"
|
||||||
echo " - name: $PROXY_NAME"
|
echo " - name: $PROXY_NAME"
|
||||||
echo " type: openvpn"
|
echo " type: openvpn"
|
||||||
@ -234,10 +268,9 @@ write_provider() {
|
|||||||
echo " udp: true"
|
echo " udp: true"
|
||||||
echo " username: $(yaml_str "$VPN_USERNAME")"
|
echo " username: $(yaml_str "$VPN_USERNAME")"
|
||||||
echo " password: $(yaml_str "$pass")"
|
echo " password: $(yaml_str "$pass")"
|
||||||
# the server pushes AES-256-GCM
|
echo " data-ciphers: [$ciphers]"
|
||||||
echo " data-ciphers: [AES-256-GCM, AES-128-GCM]"
|
|
||||||
[ -n "$fallback" ] && echo " data-ciphers-fallback: $fallback"
|
[ -n "$fallback" ] && echo " data-ciphers-fallback: $fallback"
|
||||||
# what the server pushes (and OpenVPN Connect uses); mihomo ignores pushed ping.
|
# 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.
|
# A dead tunnel is noticed by the cron check sooner than by ping-restart.
|
||||||
echo " ping: 60"
|
echo " ping: 60"
|
||||||
echo " ping-restart: 300"
|
echo " ping-restart: 300"
|
||||||
@ -288,7 +321,8 @@ probe() {
|
|||||||
|
|
||||||
# tunnel state from the kit core, no traffic: _cs_since (unix, 0 = down),
|
# 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
|
# _cs_failed (true once the server rejected the credentials), _cs_err (last
|
||||||
# connect error). Non-zero when the core reports none (stock / official core,
|
# 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).
|
# OVPN_MIMIC=mihomo without auto-connect, no such proxy, API down).
|
||||||
core_state() {
|
core_state() {
|
||||||
_j=$(api GET "/providers/proxies/$PROVIDER_NAME/$PROXY_NAME" 2>/dev/null) || return 1
|
_j=$(api GET "/providers/proxies/$PROVIDER_NAME/$PROXY_NAME" 2>/dev/null) || return 1
|
||||||
@ -296,7 +330,10 @@ core_state() {
|
|||||||
_cs_since=$(jsonfilter -s "$_j" -e '@.openvpn.connected_since' 2>/dev/null)
|
_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_failed=$(jsonfilter -s "$_j" -e '@.openvpn.auth_failed' 2>/dev/null)
|
||||||
_cs_err=$(jsonfilter -s "$_j" -e '@.openvpn.last_error' 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_since" in '' | *[!0-9]*) _cs_since=0 ;; esac
|
||||||
|
case "$_cs_retry" in '' | *[!0-9]*) _cs_retry=0 ;; esac
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,6 +345,7 @@ wait_up() {
|
|||||||
core_state || return 2
|
core_state || return 2
|
||||||
[ "$_cs_since" -gt 0 ] && return 0
|
[ "$_cs_since" -gt 0 ] && return 0
|
||||||
[ "$_cs_failed" = true ] && return 1
|
[ "$_cs_failed" = true ] && return 1
|
||||||
|
[ "$_cs_retry" -gt "$(date +%s)" ] && return 1
|
||||||
[ "$_i" -ge "$1" ] && return 1
|
[ "$_i" -ge "$1" ] && return 1
|
||||||
sleep 1
|
sleep 1
|
||||||
_i=$((_i + 1))
|
_i=$((_i + 1))
|
||||||
@ -326,18 +364,18 @@ tunnel_ok() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# provider with a single direct proxy: the old tunnel gets closed with the
|
# provider with a single direct proxy: the old tunnel gets closed with the
|
||||||
# outdated proxy, and BMSTU traffic goes without it (public resources still
|
# outdated proxy, and the VPN's addresses go without it (on whitelist / foreign
|
||||||
# open; on street the provider's dialer-proxy sends it through OVPN-EXIT)
|
# the provider's dialer-proxy sends them through OVPN-EXIT)
|
||||||
write_off_provider() {
|
write_off_provider() {
|
||||||
mkdir -p "$(dirname "$PROVIDER_FILE")"
|
mkdir -p "$(dirname "$PROVIDER_FILE")"
|
||||||
printf '# bmstu-otp.sh off\nproxies:\n - name: %s-off\n type: direct\n' "$PROVIDER_NAME" > "$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
|
# rule-provider <PROVIDER_NAME>-routes (written by mihomo-kit.sh build): with the
|
||||||
# tunnel off it is emptied, so BMSTU addresses follow the normal rules
|
# tunnel off it is emptied, so the VPN's addresses follow the normal rules
|
||||||
ROUTES=${ROUTES:-$(dirname "$PROVIDER_FILE")/$PROVIDER_NAME-routes}
|
ROUTES=${ROUTES:-$(dirname "$PROVIDER_FILE")/$PROVIDER_NAME-routes}
|
||||||
routes_body() {
|
routes_body() {
|
||||||
if [ "$1" = off ]; then
|
if [ "$1" = off ] || { [ -f "$ROUTES.all" ] && ! grep -q . "$ROUTES.all"; }; then
|
||||||
echo 'payload: []'
|
echo 'payload: []'
|
||||||
elif [ -f "$ROUTES.all" ]; then
|
elif [ -f "$ROUTES.all" ]; then
|
||||||
echo 'payload:'
|
echo 'payload:'
|
||||||
@ -356,7 +394,17 @@ routes_set() {
|
|||||||
log "warning: routes reload failed (API $API), applies on the next nikki restart"
|
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() {
|
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
|
write_provider
|
||||||
wait_api
|
wait_api
|
||||||
api PUT "/providers/proxies/$PROVIDER_NAME" >/dev/null || die "provider reload failed (API $API)"
|
api PUT "/providers/proxies/$PROVIDER_NAME" >/dev/null || die "provider reload failed (API $API)"
|
||||||
@ -375,12 +423,18 @@ refresh() {
|
|||||||
# kit core, steady state (cron): it reconnects by itself with the session
|
# 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
|
# token. A fresh OTP is needed once the server rejected the token, or when the
|
||||||
# tunnel has stayed down for DOWN_GRACE seconds.
|
# tunnel has stayed down for DOWN_GRACE seconds.
|
||||||
DOWN_SINCE=${DOWN_SINCE:-/tmp/bmstu-otp.down}
|
DOWN_SINCE=${DOWN_SINCE:-/tmp/openvpn.down}
|
||||||
watch_core() {
|
watch_core() {
|
||||||
if [ "$_cs_since" -gt 0 ]; then
|
if [ "$_cs_since" -gt 0 ]; then
|
||||||
rm -f "$DOWN_SINCE"
|
rm -f "$DOWN_SINCE"
|
||||||
return 0
|
return 0
|
||||||
fi
|
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
|
if [ "$_cs_failed" = true ]; then
|
||||||
log "the server rejected the session (${_cs_err:-AUTH_FAILED}), new OTP"
|
log "the server rejected the session (${_cs_err:-AUTH_FAILED}), new OTP"
|
||||||
refresh
|
refresh
|
||||||
@ -396,7 +450,7 @@ watch_core() {
|
|||||||
|
|
||||||
# other cores (no tunnel state): probe CHECK_URL, but only every PROBE_EVERY
|
# 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
|
# seconds and not on the minute mark, so it does not look like a clock
|
||||||
PROBE_LAST=${PROBE_LAST:-/tmp/bmstu-otp.probe}
|
PROBE_LAST=${PROBE_LAST:-/tmp/openvpn.probe}
|
||||||
watch_probe() {
|
watch_probe() {
|
||||||
_now=$(date +%s)
|
_now=$(date +%s)
|
||||||
_last=$(cat "$PROBE_LAST" 2>/dev/null)
|
_last=$(cat "$PROBE_LAST" 2>/dev/null)
|
||||||
@ -588,8 +642,9 @@ when() {
|
|||||||
# mode timer | manual | schedule | always: what decides now
|
# mode timer | manual | schedule | always: what decides now
|
||||||
# want 1 when the tunnel should be up now
|
# want 1 when the tunnel should be up now
|
||||||
# tunnel up | down: whether the provider holds the tunnel (not a probe)
|
# tunnel up | down: whether the provider holds the tunnel (not a probe)
|
||||||
# link closed | up | connecting | rejected | unknown: the kit core's tunnel
|
# link closed | up | connecting | rejected | held | unknown: the kit core's tunnel
|
||||||
# state, no traffic (unknown: the core reports none)
|
# 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
|
# up_since when the tunnel came up (epoch, 0 = not up), up_hm, up_day
|
||||||
# err the core's last connect error, single-quoted
|
# err the core's last connect error, single-quoted
|
||||||
# until timer end (epoch, 0 = none), until_hm, until_day (today|tomorrow|date)
|
# until timer end (epoch, 0 = none), until_hm, until_day (today|tomorrow|date)
|
||||||
@ -618,7 +673,7 @@ state() {
|
|||||||
fi
|
fi
|
||||||
echo "mode=$_mode"
|
echo "mode=$_mode"
|
||||||
echo "want=$_want"
|
echo "want=$_want"
|
||||||
_link=unknown _cs_since=0
|
_link=unknown _cs_since=0 _cs_retry=0
|
||||||
if tunnel_is_down; then
|
if tunnel_is_down; then
|
||||||
echo "tunnel=down"
|
echo "tunnel=down"
|
||||||
_link=closed
|
_link=closed
|
||||||
@ -629,9 +684,16 @@ state() {
|
|||||||
_link=up
|
_link=up
|
||||||
elif [ "$_cs_failed" = true ]; then
|
elif [ "$_cs_failed" = true ]; then
|
||||||
_link=rejected
|
_link=rejected
|
||||||
|
elif [ "$_cs_retry" -gt "$(date +%s)" ]; then
|
||||||
|
_link=held
|
||||||
else
|
else
|
||||||
_link=connecting
|
_link=connecting
|
||||||
fi
|
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
|
# 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)'"
|
[ -n "$_cs_err" ] && echo "err='$(printf '%s' "$_cs_err" | tr -d "'\"\`\\\\\$\n" | cut -c1-200)'"
|
||||||
fi
|
fi
|
||||||
@ -656,13 +718,18 @@ state() {
|
|||||||
echo "win=$(min_to_hhmm "$_s")-$(min_to_hhmm "$_e")"
|
echo "win=$(min_to_hhmm "$_s")-$(min_to_hhmm "$_e")"
|
||||||
fi
|
fi
|
||||||
echo "sched=${OVPN_SCHED:-0}"
|
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_start=$OVPN_SCHED_START"
|
||||||
echo "sched_end=$OVPN_SCHED_END"
|
echo "sched_end=$OVPN_SCHED_END"
|
||||||
echo "sched_days=$OVPN_SCHED_DAYS"
|
echo "sched_days=$OVPN_SCHED_DAYS"
|
||||||
echo "jitter=$OVPN_SCHED_JITTER"
|
echo "jitter=$OVPN_SCHED_JITTER"
|
||||||
}
|
}
|
||||||
|
|
||||||
# persist KEY=value in the env file (bmstu.env) and apply it to this process,
|
# 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
|
# so the cron and the init hook that source the file pick the change up
|
||||||
sched_set() {
|
sched_set() {
|
||||||
eval "$1=\$2"
|
eval "$1=\$2"
|
||||||
@ -715,7 +782,7 @@ reconcile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# one state change at a time (cron check, LuCI buttons, use): lock_take <wait s>
|
# one state change at a time (cron check, LuCI buttons, use): lock_take <wait s>
|
||||||
LOCK=${LOCK:-/tmp/bmstu-otp.lock}
|
LOCK=${LOCK:-/tmp/openvpn.lock}
|
||||||
lock_take() {
|
lock_take() {
|
||||||
_w=0
|
_w=0
|
||||||
until mkdir "$LOCK" 2>/dev/null; do
|
until mkdir "$LOCK" 2>/dev/null; do
|
||||||
@ -733,15 +800,18 @@ lock_take() {
|
|||||||
trap 'rm -rf "$LOCK"' EXIT
|
trap 'rm -rf "$LOCK"' EXIT
|
||||||
}
|
}
|
||||||
# a check with two probes and a refresh takes up to ~2 min
|
# a check with two probes and a refresh takes up to ~2 min
|
||||||
lock_wait() { lock_take 150 || die "busy: another bmstu-otp.sh run holds $LOCK"; }
|
lock_wait() { lock_take 150 || die "busy: another ovpn.sh run holds $LOCK"; }
|
||||||
|
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
otp) totp ;;
|
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
|
# auth-user-pass file for testing with the real openvpn client
|
||||||
authfile) printf '%s\n%s\n' "$VPN_USERNAME" "$(make_password "$(fresh_totp)")" ;;
|
authfile) printf '%s\n%s\n' "$VPN_USERNAME" "$(make_password)" ;;
|
||||||
refresh)
|
refresh)
|
||||||
lock_wait
|
lock_wait
|
||||||
want_up || die "OpenVPN is off now ($(base_state | cut -d' ' -f2)): bmstu-otp.sh on, or for <min>"
|
want_up || die "OpenVPN is off now ($(base_state | cut -d' ' -f2)): ovpn.sh on, or for <min>"
|
||||||
routes_set on
|
routes_set on
|
||||||
refresh
|
refresh
|
||||||
;;
|
;;
|
||||||
@ -774,28 +844,41 @@ case "${1:-}" in
|
|||||||
lock_wait
|
lock_wait
|
||||||
touch "$OFF_FLAG"
|
touch "$OFF_FLAG"
|
||||||
rm -f "$UNTIL_FLAG"
|
rm -f "$UNTIL_FLAG"
|
||||||
|
[ "${OVPN_SCHED:-0}" = 1 ] && sched_set OVPN_SCHED 0
|
||||||
tunnel_down
|
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)"
|
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)
|
on)
|
||||||
lock_wait
|
lock_wait
|
||||||
rm -f "$OFF_FLAG" "$UNTIL_FLAG"
|
rm -f "$OFF_FLAG" "$UNTIL_FLAG"
|
||||||
|
[ "${OVPN_SCHED:-0}" = 1 ] && sched_set OVPN_SCHED 0
|
||||||
wait_api
|
wait_api
|
||||||
reconcile
|
reconcile
|
||||||
;;
|
;;
|
||||||
# bring the tunnel up for N minutes, over the manual off and the schedule;
|
# 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)
|
# then whatever was in force before holds again (the cron applies it)
|
||||||
for)
|
for | extend)
|
||||||
case "${2:-}" in '' | *[!0-9]* | 0) die "usage: bmstu-otp.sh for <minutes>" ;; esac
|
case "${2:-}" in '' | *[!0-9]* | 0) die "usage: ovpn.sh $1 <minutes>" ;; esac
|
||||||
lock_wait
|
lock_wait
|
||||||
echo "$(($(date +%s) + $2 * 60))" > "$UNTIL_FLAG"
|
_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
|
wait_api
|
||||||
reconcile
|
reconcile
|
||||||
rc=$?
|
rc=$?
|
||||||
eval "$(state)"
|
eval "$(state)"
|
||||||
log "OpenVPN on for $2 min, until $until_hm; then $after ($why)"
|
log "OpenVPN on by timer until $until_hm $until_day; then $after ($why)"
|
||||||
exit $rc
|
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) |
|
# 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.
|
# "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.
|
# Persists to the env file so the cron and the init hook read the same thing.
|
||||||
@ -803,7 +886,7 @@ case "${1:-}" in
|
|||||||
case "${2:-}" in
|
case "${2:-}" in
|
||||||
'' | show)
|
'' | show)
|
||||||
if [ "${OVPN_SCHED:-0}" = 1 ]; then
|
if [ "${OVPN_SCHED:-0}" = 1 ]; then
|
||||||
echo "schedule on: $OVPN_SCHED_START-$OVPN_SCHED_END MSK, days $OVPN_SCHED_DAYS, jitter +-$OVPN_SCHED_JITTER min"
|
echo "schedule on: $OVPN_SCHED_START-$OVPN_SCHED_END (router time), days $OVPN_SCHED_DAYS, jitter +-$OVPN_SCHED_JITTER min"
|
||||||
else
|
else
|
||||||
echo "schedule off"
|
echo "schedule off"
|
||||||
fi
|
fi
|
||||||
@ -812,14 +895,20 @@ case "${1:-}" in
|
|||||||
esac
|
esac
|
||||||
lock_wait
|
lock_wait
|
||||||
case "$2" in
|
case "$2" in
|
||||||
off) sched_set OVPN_SCHED 0 ;;
|
off)
|
||||||
on) sched_set OVPN_SCHED 1 ;;
|
sched_set OVPN_SCHED 0
|
||||||
|
touch "$OFF_FLAG"
|
||||||
|
;;
|
||||||
|
on)
|
||||||
|
rm -f "$OFF_FLAG"
|
||||||
|
sched_set OVPN_SCHED 1
|
||||||
|
;;
|
||||||
days)
|
days)
|
||||||
_dz=$(days_norm "${3:-}") && [ -n "$_dz" ] || die "usage: bmstu-otp.sh sched days 12345 | weekdays | weekend | all"
|
_dz=$(days_norm "${3:-}") && [ -n "$_dz" ] || die "usage: ovpn.sh sched days 12345 | weekdays | weekend | all"
|
||||||
sched_set OVPN_SCHED_DAYS "$_dz"
|
sched_set OVPN_SCHED_DAYS "$_dz"
|
||||||
;;
|
;;
|
||||||
[0-9][0-9]:[0-9][0-9])
|
[0-9][0-9]:[0-9][0-9])
|
||||||
_a=$(hhmm_to_min "$2") && _b=$(hhmm_to_min "${3:-}") || die "usage: bmstu-otp.sh sched HH:MM HH:MM"
|
_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
|
# the jittered edges must not cross, or the window flips between
|
||||||
# almost the whole day and nothing from day to day
|
# almost the whole day and nothing from day to day
|
||||||
_j=$((${OVPN_SCHED_JITTER:-0} * 2))
|
_j=$((${OVPN_SCHED_JITTER:-0} * 2))
|
||||||
@ -832,9 +921,8 @@ case "${1:-}" in
|
|||||||
fi
|
fi
|
||||||
sched_set OVPN_SCHED_START "$2"
|
sched_set OVPN_SCHED_START "$2"
|
||||||
sched_set OVPN_SCHED_END "$3"
|
sched_set OVPN_SCHED_END "$3"
|
||||||
sched_set OVPN_SCHED 1
|
|
||||||
;;
|
;;
|
||||||
*) die "usage: bmstu-otp.sh sched off | on | HH:MM HH:MM [DAYS] | days DAYS" ;;
|
*) die "usage: ovpn.sh sched off | on | HH:MM HH:MM [DAYS] | days DAYS" ;;
|
||||||
esac
|
esac
|
||||||
wait_api
|
wait_api
|
||||||
reconcile
|
reconcile
|
||||||
@ -854,22 +942,23 @@ case "${1:-}" in
|
|||||||
eval "$(state)"
|
eval "$(state)"
|
||||||
case "$mode" in
|
case "$mode" in
|
||||||
timer) echo "on by timer until $until_hm $until_day, then $after ($why)" ;;
|
timer) echo "on by timer until $until_hm $until_day, then $after ($why)" ;;
|
||||||
manual) echo "off (manual, until bmstu-otp.sh on)" ;;
|
manual) echo "off (manual, until ovpn.sh on)" ;;
|
||||||
always) echo "on (no schedule)" ;;
|
always) echo "on (no schedule)" ;;
|
||||||
schedule)
|
schedule)
|
||||||
[ "$want" = 1 ] && echo "on by schedule" || echo "off by schedule"
|
[ "$want" = 1 ] && echo "on by schedule" || echo "off by schedule"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
if [ "$next" -gt 0 ]; then
|
if [ "$next" -gt 0 ]; then
|
||||||
echo "schedule: $sched_start-$sched_end MSK, days $sched_days, today $win (jitter +-$jitter min)"
|
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"
|
[ "$mode" = schedule ] && echo "turns $next_to at $next_hm $next_day"
|
||||||
fi
|
fi
|
||||||
case "$link" in
|
case "$link" in
|
||||||
closed) echo "tunnel closed" ;;
|
closed) echo "tunnel closed" ;;
|
||||||
up) echo "tunnel up since $up_hm $up_day" ;;
|
up) echo "tunnel up since $up_hm $up_day" ;;
|
||||||
connecting) echo "tunnel connecting${err:+ (last error: $err)}" ;;
|
connecting) echo "tunnel connecting${err:+ (last error: $err)}" ;;
|
||||||
rejected) echo "the server rejected the session: the cron check gets a new OTP within a minute" ;;
|
rejected) echo "the server rejected the session: the cron check gets a new OTP${retry_hm:+ after the pause, at $retry_hm}" ;;
|
||||||
*) echo "tunnel state unknown: this core does not report it (bmstu-otp.sh probe opens $CHECK_URL)" ;;
|
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
|
esac
|
||||||
[ "$want" = 1 ] && [ "$tunnel" = down ] && echo "the cron check brings it up within a minute"
|
[ "$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"
|
[ "$want" = 0 ] && [ "$tunnel" = up ] && echo "the cron check takes it down within a minute"
|
||||||
@ -881,16 +970,16 @@ case "${1:-}" in
|
|||||||
HANDSHAKE_TIMEOUT=0 write_provider
|
HANDSHAKE_TIMEOUT=0 write_provider
|
||||||
api PATCH /configs -H 'Content-Type: application/json' -d '{"log-level":"debug"}' >/dev/null
|
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)"
|
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)"
|
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" \
|
curl -skS -m 25 -o /dev/null -w "request via mihomo: http %{http_code}\n" \
|
||||||
${MIXED_AUTH:+--proxy-user "$MIXED_AUTH"} \
|
${MIXED_AUTH:+--proxy-user "$MIXED_AUTH"} \
|
||||||
-x "http://127.0.0.1:$MIXED_PORT" "${DEBUG_URL:-https://195.19.34.102/}"
|
-x "http://127.0.0.1:$MIXED_PORT" "${DEBUG_URL:-$CHECK_URL}"
|
||||||
# let LAN clients trigger a handshake and hit the 5s dial timeout
|
# let LAN clients trigger a handshake and hit the 5s dial timeout
|
||||||
sleep 20
|
sleep 20
|
||||||
echo "--- log ---"
|
echo "--- log ---"
|
||||||
{ cat /var/log/nikki/core.log 2>/dev/null || logread; } | grep -iE "openvpn|bmstu" | tail -n 30
|
{ cat /var/log/nikki/core.log 2>/dev/null || logread; } | grep -iE "openvpn" | tail -n 30
|
||||||
echo "--- handshake errors ---"
|
echo "--- handshake errors ---"
|
||||||
{ cat /var/log/nikki/core.log 2>/dev/null || logread; } | grep -E "OpenVPN" | tail -n 5
|
{ 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 ;;
|
*) echo "usage: $0 otp|authfile|refresh|check|on|off|sched|for|extend|stop|status|debug" >&2; exit 2 ;;
|
||||||
esac
|
esac
|
||||||
@ -44,19 +44,49 @@ TORRENT=1
|
|||||||
|
|
||||||
# own lists, space separated, above torrents / ru-inside / .ru / MAIN; first match:
|
# 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);
|
# 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_* need own servers (HY2)
|
# domains: with subdomains ("example.com" = "*.example.com"); MY_*: group MY (HY2 and "[MY] ..." nodes of the subscriptions)
|
||||||
RU_IPS="194.190.191.112/32"
|
RU_IPS="194.190.191.112/32"
|
||||||
#FOREIGN_IPS="1.2.3.0/24"
|
#FOREIGN_IPS="1.2.3.0/24"
|
||||||
#MY_IPS="10.8.0.0/24"
|
#MY_IPS="10.8.0.0/24"
|
||||||
#RU_DOMAINS="example.ru *.example.com"
|
#RU_DOMAINS="example.ru *.example.com"
|
||||||
#FOREIGN_DOMAINS="example.org"
|
#FOREIGN_DOMAINS="example.org"
|
||||||
#MY_DOMAINS="home.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
|
||||||
|
|
||||||
# OpenVPN (BMSTU), needs /etc/nikki/bmstu.env and bmstu-otp.sh
|
# 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=0
|
OPENVPN=0
|
||||||
#OVPN_SERVER_HOST=openvpn4.bmstu.ru
|
#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_IPS="195.19.40.7 195.19.33.86"
|
#OVPN_SERVER_HOST=vpn.example.com # default: the remote lines of the .ovpn
|
||||||
#OVPN_ROUTES="172.16.0.0/16 172.19.33.0/24 195.19.32.0/19"
|
#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
|
# 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)
|
# without QUIC, quiet core; on apply also GOMEMLIMIT (LITE_GOMEMLIMIT, default 64MiB)
|
||||||
|
|||||||
@ -13,6 +13,8 @@ dns:
|
|||||||
# tailnet names: real 100.x addresses from MagicDNS (nameserver-policy below) #@tailscale
|
# tailnet names: real 100.x addresses from MagicDNS (nameserver-policy below) #@tailscale
|
||||||
- '+.ts.net' #@tailscale
|
- '+.ts.net' #@tailscale
|
||||||
- '+.${@TS_DOMAINS}' #@tailscale
|
- '+.${@TS_DOMAINS}' #@tailscale
|
||||||
|
# own servers in the LAN (LOCAL_HOSTS): clients get the real LAN address #@local_hosts
|
||||||
|
- '+.${@LOCAL_DOMAINS}' #@local_hosts
|
||||||
|
|
||||||
default-nameserver:
|
default-nameserver:
|
||||||
- 77.88.8.8
|
- 77.88.8.8
|
||||||
@ -37,3 +39,8 @@ dns:
|
|||||||
nameserver-policy: #@tailscale
|
nameserver-policy: #@tailscale
|
||||||
'+.ts.net': tailscale://tailscale #@tailscale
|
'+.ts.net': tailscale://tailscale #@tailscale
|
||||||
'+.${@TS_DOMAINS}': 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
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
# url: what the dashboard's delay test opens through the tunnel;
|
# url: what the dashboard's delay test opens through the tunnel;
|
||||||
# interval 0: no background checks (they would redial with a stale OTP)
|
# interval 0: no background checks (they would redial with a stale code)
|
||||||
- name: ${OVPN_GROUP}
|
- name: ${OVPN_GROUP}
|
||||||
type: select
|
type: select
|
||||||
use: [${OVPN_PROVIDER}]
|
use: [${OVPN_PROVIDER}]
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
# what the OpenVPN tunnel itself goes through on whitelist and foreign (ovpn_exit).
|
# what the OpenVPN tunnel itself goes through on whitelist and foreign (ovpn_exit):
|
||||||
# select, not url-test: switching nodes would break the tunnel.
|
# a RU node, for a VPN server in Russia. select, not url-test: switching nodes
|
||||||
# Pick a concrete RU node in the dashboard, the choice is remembered.
|
# would break the tunnel. Pick one in the dashboard, the choice is remembered.
|
||||||
- name: OVPN-EXIT
|
- name: OVPN-EXIT
|
||||||
type: select
|
type: select
|
||||||
use: [${SUB_LIST}]
|
use: [${SUB_LIST}]
|
||||||
|
|||||||
15
templates/groups/44-pool.each.yaml
Normal file
15
templates/groups/44-pool.each.yaml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# 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
|
||||||
@ -1,21 +0,0 @@
|
|||||||
# 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 #@!lite
|
|
||||||
interval: 600 #@lite
|
|
||||||
tolerance: 50
|
|
||||||
lazy: false #@!lite
|
|
||||||
lazy: true #@lite
|
|
||||||
|
|
||||||
# whitelist 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
|
|
||||||
23
templates/groups/45-sub.yaml
Normal file
23
templates/groups/45-sub.yaml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# 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
|
||||||
15
templates/groups/46-svc.each.yaml
Normal file
15
templates/groups/46-svc.each.yaml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# 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
|
||||||
15
templates/groups/47-vgroup.each.yaml
Normal file
15
templates/groups/47-vgroup.each.yaml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# ${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.
|
# cannot do it in mihomo, so only ss / hysteria2 / tuic / socks5 nodes here.
|
||||||
- name: TS-EXIT
|
- name: TS-EXIT
|
||||||
type: select
|
type: select
|
||||||
proxies: [MY] #@hy2
|
proxies: [MY] #@own
|
||||||
use: [${SUB_LIST}]
|
use: [${SUB_LIST}]
|
||||||
exclude-type: "vless|vmess|trojan"
|
exclude-type: "vless|vmess|trojan"
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
# UPLINK: what the subscription nodes, BOOT seeds and own servers connect
|
# UPLINK: what the subscription nodes, BOOT seeds and own servers connect
|
||||||
# through. DIRECT - as before; CSQTT - through csqtt0 first (out of the
|
# through. DIRECT - as before; CSQTT - through csqtt0 first (out of the
|
||||||
# whitelist), then FOREIGN / MY / RU work on top of it as usual.
|
# 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.
|
# On whitelist own servers go MY-EXIT -> node -> UPLINK.
|
||||||
- name: UPLINK
|
- name: UPLINK
|
||||||
type: select
|
type: select
|
||||||
proxies: [DIRECT, CSQTT]
|
proxies: [DIRECT${UPLINK_MORE}]
|
||||||
@ -1,5 +1,5 @@
|
|||||||
- name: MAIN
|
- name: MAIN
|
||||||
type: select
|
type: select
|
||||||
proxies: [FOREIGN, ${HY2_MAIN}RU, DIRECT${CSQTT_MAIN}] #@!foreign
|
proxies: [FOREIGN, MY, RU, DIRECT${CSQTT_MAIN}] #@!foreign
|
||||||
# abroad: direct by default, own servers / pools by hand #@foreign
|
# abroad: direct by default, own servers / pools by hand #@foreign
|
||||||
proxies: [DIRECT, ${HY2_MAIN}FOREIGN, RU${CSQTT_MAIN}] #@foreign
|
proxies: [DIRECT, MY, FOREIGN, RU${CSQTT_MAIN}] #@foreign
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
- name: PUSH
|
- name: PUSH
|
||||||
type: select
|
type: select
|
||||||
proxies: [DIRECT, ${HY2_MAIN}FOREIGN] #@!whitelist
|
proxies: [DIRECT, MY, FOREIGN] #@!whitelist
|
||||||
proxies: [${HY2_MAIN}FOREIGN, DIRECT] #@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
|
||||||
|
|||||||
@ -4,9 +4,9 @@
|
|||||||
path: ./providers/${SUB_NAME}.yaml
|
path: ./providers/${SUB_NAME}.yaml
|
||||||
interval: 3600
|
interval: 3600
|
||||||
proxy: ${@SUB_PROXY}
|
proxy: ${@SUB_PROXY}
|
||||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь"
|
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||||
override: #@csqtt
|
override: #@uplink
|
||||||
dialer-proxy: UPLINK #@csqtt
|
dialer-proxy: UPLINK #@uplink
|
||||||
header:
|
header:
|
||||||
User-Agent: ["${SUB_UA}"]
|
User-Agent: ["${SUB_UA}"]
|
||||||
${@@SUB_HEADERS}
|
${@@SUB_HEADERS}
|
||||||
|
|||||||
32
templates/providers/15-sub.each.yaml
Normal file
32
templates/providers/15-sub.each.yaml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
# 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
|
||||||
24
templates/providers/16-myvia.each.yaml
Normal file
24
templates/providers/16-myvia.each.yaml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# [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
|
||||||
18
templates/providers/17-my_links.yaml
Normal file
18
templates/providers/17-my_links.yaml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# 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
|
||||||
26
templates/providers/19-vprov.each.yaml
Normal file
26
templates/providers/19-vprov.each.yaml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# ${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,6 +1,6 @@
|
|||||||
# OpenVPN: file written on the router by bmstu-otp.sh (fresh TOTP in the
|
# 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
|
# password). No health-check here: a dead tunnel would be redialed with a
|
||||||
# stale OTP; the cron watchdog (bmstu-otp.sh check) handles it.
|
# stale code; the cron watchdog (ovpn.sh check) handles it.
|
||||||
${OVPN_PROVIDER}:
|
${OVPN_PROVIDER}:
|
||||||
type: file
|
type: file
|
||||||
path: ./providers/${OVPN_PROVIDER}.yaml
|
path: ./providers/${OVPN_PROVIDER}.yaml
|
||||||
|
|||||||
@ -12,4 +12,4 @@
|
|||||||
reality-opts:
|
reality-opts:
|
||||||
public-key: ${SEED_PBK}
|
public-key: ${SEED_PBK}
|
||||||
short-id: ${SEED_SID}
|
short-id: ${SEED_SID}
|
||||||
dialer-proxy: UPLINK #@csqtt
|
dialer-proxy: UPLINK #@uplink
|
||||||
|
|||||||
@ -9,6 +9,7 @@
|
|||||||
udp: true
|
udp: true
|
||||||
accept-routes: true
|
accept-routes: true
|
||||||
dialer-proxy: TS-EXIT #@ts_exit
|
dialer-proxy: TS-EXIT #@ts_exit
|
||||||
# whitelist: control and DERP over TCP through own servers (MY -> hysteria2 -> MY-EXIT); #@whitelist,hy2,!ts_exit
|
# whitelist: control and DERP over TCP through own servers (MY -> own node -> MY-EXIT); #@whitelist,!ts_exit
|
||||||
# needs the kit's core (v1.19.32-ts1, tools/core/*.patch, MetaCubeX/mihomo#3142) #@whitelist,hy2,!ts_exit
|
# MY holds hysteria2 from the settings and "[MY]" nodes of the subscriptions; empty MY is direct #@whitelist,!ts_exit
|
||||||
dialer-proxy: MY #@whitelist,hy2,!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
|
||||||
|
|||||||
@ -1,14 +0,0 @@
|
|||||||
- 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
|
|
||||||
dialer-proxy: UPLINK #@csqtt,!hy2_exit
|
|
||||||
8
templates/proxies/30-own_srv.yaml
Normal file
8
templates/proxies/30-own_srv.yaml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# 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}
|
||||||
3
templates/proxies/35-variant.yaml
Normal file
3
templates/proxies/35-variant.yaml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# 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}
|
||||||
@ -7,3 +7,12 @@
|
|||||||
url: "${RULESET_URL}/ru-inside.mrs"
|
url: "${RULESET_URL}/ru-inside.mrs"
|
||||||
path: ./ruleset/ru-inside.mrs
|
path: ./ruleset/ru-inside.mrs
|
||||||
interval: 86400
|
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,6 +1,6 @@
|
|||||||
# OpenVPN routes (OVPN_ROUTES): the file is written by mihomo-kit.sh build and
|
# OpenVPN routes (OVPN_ROUTES): the file is written by mihomo-kit.sh build and
|
||||||
# emptied by bmstu-otp.sh off, so with the tunnel off these addresses follow
|
# emptied by ovpn.sh off, so with the tunnel off these addresses follow
|
||||||
# the normal rules instead of a dead BMSTU group
|
# the normal rules instead of a dead OpenVPN group
|
||||||
${OVPN_PROVIDER}-routes:
|
${OVPN_PROVIDER}-routes:
|
||||||
type: file
|
type: file
|
||||||
behavior: ipcidr
|
behavior: ipcidr
|
||||||
|
|||||||
8
templates/rule-providers/30-geosite.each.yaml
Normal file
8
templates/rule-providers/30-geosite.each.yaml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# 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
|
||||||
7
templates/rule-providers/35-svc.each.yaml
Normal file
7
templates/rule-providers/35-svc.each.yaml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# 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,8 +1,8 @@
|
|||||||
# OpenVPN server itself must not go into its own tunnel
|
# 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,DIRECT,no-resolve #@!ovpn_exit
|
||||||
- IP-CIDR,${@OVPN_SERVER_IPS}/32,OVPN-EXIT,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},DIRECT #@!ovpn_exit
|
||||||
- DOMAIN,${OVPN_SERVER_HOST},OVPN-EXIT #@ovpn_exit
|
- DOMAIN,${@OVPN_SERVER_HOST},OVPN-EXIT #@ovpn_exit
|
||||||
# networks pushed by the server (before the private-range DIRECT rules);
|
# the networks that go through the VPN (OVPN_ROUTES; before the private-range DIRECT
|
||||||
# a rule-provider so that bmstu-otp.sh off can drop them without a restart
|
# rules); a rule-provider so that ovpn.sh off can drop them without a restart
|
||||||
- RULE-SET,${OVPN_PROVIDER}-routes,${OVPN_GROUP},no-resolve
|
- RULE-SET,${OVPN_PROVIDER}-routes,${OVPN_GROUP},no-resolve
|
||||||
|
|||||||
5
templates/rules/38-svc.each.yaml
Normal file
5
templates/rules/38-svc.each.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# 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
|
||||||
@ -2,11 +2,13 @@
|
|||||||
# tunnels, LAN and push. Domains (DOMAIN-SUFFIX: the domain and all subdomains)
|
# tunnels, LAN and push. Domains (DOMAIN-SUFFIX: the domain and all subdomains)
|
||||||
# before IPs; first match wins: MY, then FOREIGN, then RU.
|
# before IPs; first match wins: MY, then FOREIGN, then RU.
|
||||||
# RU on main (home, own white IP): reachable directly; whitelist/abroad: through RU
|
# RU on main (home, own white IP): reachable directly; whitelist/abroad: through RU
|
||||||
- DOMAIN-SUFFIX,${@MY_DOMAINS},MY #@hy2
|
# 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,${@FOREIGN_DOMAINS},FOREIGN
|
||||||
- DOMAIN-SUFFIX,${@RU_DOMAINS},DIRECT #@main
|
- DOMAIN-SUFFIX,${@RU_DOMAINS},DIRECT #@main
|
||||||
- DOMAIN-SUFFIX,${@RU_DOMAINS},RU #@!main
|
- DOMAIN-SUFFIX,${@RU_DOMAINS},RU #@!main
|
||||||
- IP-CIDR,${@MY_IPS},MY #@hy2
|
- IP-CIDR,${@MY_IPS},MY
|
||||||
- IP-CIDR,${@FOREIGN_IPS},FOREIGN
|
- IP-CIDR,${@FOREIGN_IPS},FOREIGN
|
||||||
- IP-CIDR,${@RU_IPS},DIRECT #@main
|
- IP-CIDR,${@RU_IPS},DIRECT #@main
|
||||||
- IP-CIDR,${@RU_IPS},RU #@!main
|
- IP-CIDR,${@RU_IPS},RU #@!main
|
||||||
|
|||||||
@ -1,9 +1,13 @@
|
|||||||
- RULE-SET,ru-inside,DIRECT #@!foreign
|
- RULE-SET,ru-inside,DIRECT #@!foreign
|
||||||
# abroad: Russian services through the RU pool too #@foreign
|
# abroad: Russian services through the RU pool too #@foreign
|
||||||
- RULE-SET,ru-inside,RU #@foreign
|
- RULE-SET,ru-inside,RU #@foreign
|
||||||
# main (home, own white IP): .ru/.рф directly; elsewhere through RU
|
# 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,ru,DIRECT #@main
|
||||||
|
- DOMAIN-SUFFIX,su,DIRECT #@main
|
||||||
- DOMAIN-SUFFIX,xn--p1ai,DIRECT #@main
|
- DOMAIN-SUFFIX,xn--p1ai,DIRECT #@main
|
||||||
|
- RULE-SET,ru-services,RU #@!main
|
||||||
- DOMAIN-SUFFIX,ru,RU #@!main
|
- DOMAIN-SUFFIX,ru,RU #@!main
|
||||||
|
- DOMAIN-SUFFIX,su,RU #@!main
|
||||||
- DOMAIN-SUFFIX,xn--p1ai,RU #@!main
|
- DOMAIN-SUFFIX,xn--p1ai,RU #@!main
|
||||||
- MATCH,MAIN
|
- MATCH,MAIN
|
||||||
|
|||||||
@ -3,6 +3,11 @@ sniffer:
|
|||||||
force-dns-mapping: true
|
force-dns-mapping: true
|
||||||
parse-pure-ip: true
|
parse-pure-ip: true
|
||||||
override-destination: false
|
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:
|
sniff:
|
||||||
HTTP:
|
HTTP:
|
||||||
ports: [80, 8080-8880] #@!lite
|
ports: [80, 8080-8880] #@!lite
|
||||||
|
|||||||
24
tests/amnezia/awg2.conf
Normal file
24
tests/amnezia/awg2.conf
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
[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
|
||||||
31
tests/amnezia/awg2.expected.json
Normal file
31
tests/amnezia/awg2.expected.json
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"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": []
|
||||||
|
}
|
||||||
24
tests/amnezia/awg3.conf
Normal file
24
tests/amnezia/awg3.conf
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# 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
|
||||||
35
tests/amnezia/awg3.expected.json
Normal file
35
tests/amnezia/awg3.expected.json
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"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": []
|
||||||
|
}
|
||||||
6
tests/amnezia/broken.conf
Normal file
6
tests/amnezia/broken.conf
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[Interface]
|
||||||
|
Address = 10.0.0.2/32
|
||||||
|
PrivateKey = 9mpa7dajJsZ00c7XLuNEOM5MYGIlPWQn/WDqg0uGHtc=
|
||||||
|
|
||||||
|
[Peer]
|
||||||
|
PublicKey = 9qAqsbJr88uWikvCYZjXRZZLmRwppEfyxr/s5y9YSP0=
|
||||||
6
tests/amnezia/broken.expected.json
Normal file
6
tests/amnezia/broken.expected.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"servers": [],
|
||||||
|
"errors": [
|
||||||
|
".conf: нет Endpoint в [Peer]"
|
||||||
|
]
|
||||||
|
}
|
||||||
32
tests/amnezia/key.expected.json
Normal file
32
tests/amnezia/key.expected.json
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
"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
tests/amnezia/key.vpn
Normal file
1
tests/amnezia/key.vpn
Normal file
@ -0,0 +1 @@
|
|||||||
|
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
|
||||||
20
tests/amnezia/keys.expected.json
Normal file
20
tests/amnezia/keys.expected.json
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"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"
|
||||||
|
]
|
||||||
|
}
|
||||||
3
tests/amnezia/keys.txt
Normal file
3
tests/amnezia/keys.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
vpn://AAABq3jahZBBT8JAEIX_y1ytpWygwiYeDBwwiiGIILimWeiUrm23y3ZbKE3_u7FVSbx4m8m8-fLeq2CXSsOFRJ0BfasuK1DgicSz4NdHoXGfc-2DBZeZVqBSbYBCvzsgDlgQ88x4u1QGYg8UKgZhmpknniADyqBQ0sYTT1SMtkTDwGINgAFtABaDXSxQGk-o5qHr2EPbsUmj_D4pLQovwrIR9FZlt7jfFO6hPPjkeRGcT53jq8ud0J-u9mG8dDkZq230Ek9vG0iGukDtqXz7y3gczoPyeDU7jW86ixVJorA3Gn7ciSQdyMmDW87Xs2gSbpZrN2sZiclbdz3itBlQZyIzX-4iROXxWBRtYtJnUENdv1vgY8Dz2Iz-afenMKB_64L6Eyw7kD4
|
||||||
|
vpn://AAAAO3jaq1ZKLMiMz06tVLJSqlDSUUrOz0vLTI8vSy0qzszPU7Iy0lHKS8xNVbJScszNS63KTFQIKErNzSzNVaoFAFV2FB8
|
||||||
|
vpn://not-a-key
|
||||||
9
tests/amnezia/plain-wg.conf
Normal file
9
tests/amnezia/plain-wg.conf
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
[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
|
||||||
15
tests/amnezia/plain-wg.expected.json
Normal file
15
tests/amnezia/plain-wg.expected.json
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"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": []
|
||||||
|
}
|
||||||
324
tests/expected/mobile.yaml
Normal file
324
tests/expected/mobile.yaml
Normal file
@ -0,0 +1,324 @@
|
|||||||
|
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
|
||||||
292
tests/expected/router-boots.yaml
Normal file
292
tests/expected/router-boots.yaml
Normal file
@ -0,0 +1,292 @@
|
|||||||
|
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
|
||||||
303
tests/expected/router-csqtt-foreign.yaml
Normal file
303
tests/expected/router-csqtt-foreign.yaml
Normal file
@ -0,0 +1,303 @@
|
|||||||
|
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
|
||||||
311
tests/expected/router-csqtt.yaml
Normal file
311
tests/expected/router-csqtt.yaml
Normal file
@ -0,0 +1,311 @@
|
|||||||
|
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
|
||||||
339
tests/expected/router-foreign.yaml
Normal file
339
tests/expected/router-foreign.yaml
Normal file
@ -0,0 +1,339 @@
|
|||||||
|
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
|
||||||
270
tests/expected/router-hwid.yaml
Normal file
270
tests/expected/router-hwid.yaml
Normal file
@ -0,0 +1,270 @@
|
|||||||
|
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
|
||||||
306
tests/expected/router-ids.yaml
Normal file
306
tests/expected/router-ids.yaml
Normal file
@ -0,0 +1,306 @@
|
|||||||
|
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
|
||||||
297
tests/expected/router-lite-csqtt.yaml
Normal file
297
tests/expected/router-lite-csqtt.yaml
Normal file
@ -0,0 +1,297 @@
|
|||||||
|
# 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
|
||||||
289
tests/expected/router-lite.yaml
Normal file
289
tests/expected/router-lite.yaml
Normal file
@ -0,0 +1,289 @@
|
|||||||
|
# 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
|
||||||
358
tests/expected/router-main.yaml
Normal file
358
tests/expected/router-main.yaml
Normal file
@ -0,0 +1,358 @@
|
|||||||
|
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
|
||||||
209
tests/expected/router-minimal.yaml
Normal file
209
tests/expected/router-minimal.yaml
Normal file
@ -0,0 +1,209 @@
|
|||||||
|
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
|
||||||
366
tests/expected/router-myvia.yaml
Normal file
366
tests/expected/router-myvia.yaml
Normal file
@ -0,0 +1,366 @@
|
|||||||
|
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
|
||||||
569
tests/expected/router-whitelist-ts-my.yaml
Normal file
569
tests/expected/router-whitelist-ts-my.yaml
Normal file
@ -0,0 +1,569 @@
|
|||||||
|
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
|
||||||
316
tests/expected/router-whitelist-ts.yaml
Normal file
316
tests/expected/router-whitelist-ts.yaml
Normal file
@ -0,0 +1,316 @@
|
|||||||
|
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
|
||||||
371
tests/expected/router-whitelist.yaml
Normal file
371
tests/expected/router-whitelist.yaml
Normal file
@ -0,0 +1,371 @@
|
|||||||
|
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,3 +3,13 @@ HY2=m1
|
|||||||
HY2_M1_SERVER=m.example.com
|
HY2_M1_SERVER=m.example.com
|
||||||
HY2_M1_PORT=443
|
HY2_M1_PORT=443
|
||||||
HY2_M1_PASSWORD=p
|
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
Normal file
9
tests/fixtures/openvpn.ovpn
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# 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
Normal file
5
tests/fixtures/own.servers
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{"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"}
|
||||||
4
tests/fixtures/router-boots.env
vendored
4
tests/fixtures/router-boots.env
vendored
@ -1,5 +1,5 @@
|
|||||||
TARGET=router
|
TARGET=router
|
||||||
LOCATION=whitelist
|
LOCATION=whitelist
|
||||||
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
|
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=PBK2&sid=b2"
|
vless://22222222-2222-2222-2222-222222222222@seed2.example.com:8443?security=reality&sni=ya.ru&pbk=ppQ9FwLrLIa0AOrp1WvcyiaQ37vg2WSy_CD4bIdiTUw&sid=b2"
|
||||||
SUB_EXAMPLE_PROXY=BOOT
|
SUB_EXAMPLE_PROXY=BOOT
|
||||||
|
|||||||
1
tests/fixtures/router-csqtt-foreign.env
vendored
1
tests/fixtures/router-csqtt-foreign.env
vendored
@ -5,3 +5,4 @@ HY2=nl-1
|
|||||||
HY2_NL_1_SERVER=vpn.example.com
|
HY2_NL_1_SERVER=vpn.example.com
|
||||||
HY2_NL_1_PORT=443
|
HY2_NL_1_PORT=443
|
||||||
HY2_NL_1_PASSWORD=p
|
HY2_NL_1_PASSWORD=p
|
||||||
|
MY_SERVERS_FILE=tests/fixtures/own.servers
|
||||||
|
|||||||
1
tests/fixtures/router-csqtt.env
vendored
1
tests/fixtures/router-csqtt.env
vendored
@ -1,3 +1,4 @@
|
|||||||
TARGET=router
|
TARGET=router
|
||||||
LOCATION=whitelist
|
LOCATION=whitelist
|
||||||
CSQTT=1
|
CSQTT=1
|
||||||
|
MY_SERVERS_FILE=tests/fixtures/own.servers
|
||||||
|
|||||||
2
tests/fixtures/router-foreign.env
vendored
2
tests/fixtures/router-foreign.env
vendored
@ -1,6 +1,8 @@
|
|||||||
TARGET=router
|
TARGET=router
|
||||||
LOCATION=foreign
|
LOCATION=foreign
|
||||||
OPENVPN=1
|
OPENVPN=1
|
||||||
|
OVPN_SERVER_IPS="198.51.100.4"
|
||||||
|
OVPN_ROUTES="10.30.0.0/16"
|
||||||
TAILSCALE=1
|
TAILSCALE=1
|
||||||
HY2=nl-1
|
HY2=nl-1
|
||||||
HY2_NL_1_SERVER=vpn.example.com
|
HY2_NL_1_SERVER=vpn.example.com
|
||||||
|
|||||||
4
tests/fixtures/router-main.env
vendored
4
tests/fixtures/router-main.env
vendored
@ -1,5 +1,7 @@
|
|||||||
LOCATION=main
|
LOCATION=main
|
||||||
OPENVPN=1
|
OPENVPN=1
|
||||||
|
OVPN_FILE=tests/fixtures/openvpn.ovpn
|
||||||
|
OVPN_ROUTES="10.20.0.0/16 192.0.2.7/32"
|
||||||
TAILSCALE=1
|
TAILSCALE=1
|
||||||
HY2=home-hy
|
HY2=home-hy
|
||||||
HY2_HOME_HY_SERVER=1.1.1.1
|
HY2_HOME_HY_SERVER=1.1.1.1
|
||||||
@ -11,3 +13,5 @@ MY_IPS="10.8.0.0/24"
|
|||||||
RU_DOMAINS="*.example.com +.gosuslugi.example .bank.example plain.example"
|
RU_DOMAINS="*.example.com +.gosuslugi.example .bank.example plain.example"
|
||||||
FOREIGN_DOMAINS="api.example.com"
|
FOREIGN_DOMAINS="api.example.com"
|
||||||
MY_DOMAINS="*.home.example"
|
MY_DOMAINS="*.home.example"
|
||||||
|
LOCAL_HOSTS="sub2.example.com=192.168.64.20 *.lan-srv.example=10.0.0.5"
|
||||||
|
MY_SERVERS_FILE=tests/fixtures/own.servers
|
||||||
|
|||||||
2
tests/fixtures/router-minimal.env
vendored
2
tests/fixtures/router-minimal.env
vendored
@ -4,5 +4,5 @@ TORRENT=0
|
|||||||
RU_IPS=""
|
RU_IPS=""
|
||||||
PUSH=0
|
PUSH=0
|
||||||
FOREIGN_IPS="9.9.9.9"
|
FOREIGN_IPS="9.9.9.9"
|
||||||
# no own servers: MY lists are dropped
|
# no hysteria2: MY still exists ("[MY] ..." nodes of the subscriptions)
|
||||||
MY_DOMAINS="home.example"
|
MY_DOMAINS="home.example"
|
||||||
|
|||||||
13
tests/fixtures/router-myvia.env
vendored
Normal file
13
tests/fixtures/router-myvia.env
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
LOCATION=whitelist
|
||||||
|
# [MY] nodes with an entry of their own (LuCI: «Свои серверы» → «Вход»)
|
||||||
|
MY_NODE_1='FOREIGN|example-my|[MY] 🇩🇪 de-1 (a)'
|
||||||
|
MY_NODE_2='FOREIGN|example-my|[MY] nl.2'
|
||||||
|
MY_NODE_3='DE|example2-my|[MY] fi`3'
|
||||||
|
POOLS='de mix'
|
||||||
|
POOL_DE_SUBS='example'
|
||||||
|
POOL_MIX_SUBS='example-my'
|
||||||
|
SERVICES='claude'
|
||||||
|
SVC_CLAUDE_DOMAINS='claude.ai'
|
||||||
|
SVC_CLAUDE_SERVER='[MY] nl.2'
|
||||||
|
SVC_CLAUDE_PROVIDER='example-my'
|
||||||
|
SVC_CLAUDE_CHAIN='RU'
|
||||||
26
tests/fixtures/router-whitelist-ts-my.env
vendored
Normal file
26
tests/fixtures/router-whitelist-ts-my.env
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
TARGET=router
|
||||||
|
LOCATION=whitelist
|
||||||
|
TAILSCALE=1
|
||||||
|
MY_LINKS='vless://00000000-0000-0000-0000-000000000001@x.example.com:443?security=reality&sni=www.example.com&pbk=Nc9ZSDuQMwHN4M6TeDHjfJhgZ6SBTBbfMwx5iHQZ1ns&sid=ab&type=xhttp&path=%2Fx#de%201 trojan://pw@t.example.org:443?sni=t.example.org#tr'
|
||||||
|
MY_SERVERS_FILE=tests/fixtures/own.servers
|
||||||
|
SERVICES="claude chat yt"
|
||||||
|
SVC_CLAUDE_GEOSITE=anthropic
|
||||||
|
SVC_CLAUDE_VIA=DE
|
||||||
|
SVC_CLAUDE_CHAIN=WL
|
||||||
|
SVC_CLAUDE_DOMAINS="*.claude.example"
|
||||||
|
SVC_CHAT_GEOSITE="openai anthropic"
|
||||||
|
SVC_CHAT_IPS="1.2.3.4"
|
||||||
|
SVC_CHAT_VIA=MY
|
||||||
|
SVC_CHAT_CHAIN=FOREIGN
|
||||||
|
SVC_YT_HOSTLIST="tests/hostlists/youtube.txt tests/hostlists/extra.txt.gz tests/hostlists/missing.txt"
|
||||||
|
SVC_YT_VIA=RU
|
||||||
|
POOLS="de gone wl"
|
||||||
|
POOL_DE_TYPE=url-test
|
||||||
|
POOL_DE_SERVERS='🇩🇪 de 1; hy-own; renamed-server'
|
||||||
|
POOL_DE_SUBS="example example2-my no-such"
|
||||||
|
POOL_DE_FILTER='(?i)🇩🇪|\bde\b'
|
||||||
|
POOL_DE_EXCLUDE='(?i)tor'
|
||||||
|
POOL_GONE_SERVERS='renamed-server'
|
||||||
|
POOL_WL_SUBS="example"
|
||||||
|
POOL_WL_FILTER='\[WL\]'
|
||||||
|
POOL_WL_UPLINK=1
|
||||||
4
tests/fixtures/router-whitelist.env
vendored
4
tests/fixtures/router-whitelist.env
vendored
@ -1,5 +1,7 @@
|
|||||||
LOCATION=whitelist
|
LOCATION=whitelist
|
||||||
OPENVPN=1
|
OPENVPN=1
|
||||||
|
OVPN_SERVER_HOST="vpn1.corp.example vpn2.corp.example"
|
||||||
|
OVPN_ROUTES="10.20.0.0/16 172.16.5.0/24"
|
||||||
TAILSCALE=1
|
TAILSCALE=1
|
||||||
TS_EXIT=1
|
TS_EXIT=1
|
||||||
TS_DOMAINS="corp.example internal.example"
|
TS_DOMAINS="corp.example internal.example"
|
||||||
@ -17,6 +19,6 @@ HY2_DE_2_PASSWORD=x
|
|||||||
HY2_DE_2_SNI=www.bing.com
|
HY2_DE_2_SNI=www.bing.com
|
||||||
HY2_DE_2_INSECURE=1
|
HY2_DE_2_INSECURE=1
|
||||||
TS_CHECK_URL=http://100.69.216.50:8080/
|
TS_CHECK_URL=http://100.69.216.50:8080/
|
||||||
OVPN_CHECK_URL=https://lks.bmstu.ru/
|
OVPN_CHECK_URL=https://intranet.corp.example/
|
||||||
RU_DOMAINS="*.example.com"
|
RU_DOMAINS="*.example.com"
|
||||||
MY_IPS="10.8.0.0/24"
|
MY_IPS="10.8.0.0/24"
|
||||||
|
|||||||
BIN
tests/hostlists/extra.txt.gz
Normal file
BIN
tests/hostlists/extra.txt.gz
Normal file
Binary file not shown.
11
tests/hostlists/youtube.txt
Normal file
11
tests/hostlists/youtube.txt
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# zapret hostlist
|
||||||
|
youtube.com
|
||||||
|
YouTu.be
|
||||||
|
googlevideo.com # video
|
||||||
|
|
||||||
|
^exact.example
|
||||||
|
*.wild.example
|
||||||
|
.dot.example
|
||||||
|
youtube.com
|
||||||
|
bad domain!
|
||||||
|
1.2.3.4
|
||||||
178
tests/links/links-edge.expected.json
Normal file
178
tests/links/links-edge.expected.json
Normal file
@ -0,0 +1,178 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"client-fingerprint": "chrome",
|
||||||
|
"name": "upper",
|
||||||
|
"network": "ws",
|
||||||
|
"port": "443",
|
||||||
|
"server": "Upper.Example.com",
|
||||||
|
"tls": true,
|
||||||
|
"type": "vless",
|
||||||
|
"udp": true,
|
||||||
|
"uuid": "uuid",
|
||||||
|
"ws-opts": {
|
||||||
|
"headers": {
|
||||||
|
"Host": "",
|
||||||
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36"
|
||||||
|
},
|
||||||
|
"path": "/w"
|
||||||
|
},
|
||||||
|
"xudp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client-fingerprint": "chrome",
|
||||||
|
"name": "plus",
|
||||||
|
"password": "a+b+c",
|
||||||
|
"port": "443",
|
||||||
|
"server": "t.example",
|
||||||
|
"skip-cert-verify": false,
|
||||||
|
"sni": "a b",
|
||||||
|
"type": "trojan",
|
||||||
|
"udp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client-fingerprint": "chrome",
|
||||||
|
"name": "two-at",
|
||||||
|
"password": "us@er",
|
||||||
|
"port": "443",
|
||||||
|
"server": "t.example",
|
||||||
|
"skip-cert-verify": false,
|
||||||
|
"type": "trojan",
|
||||||
|
"udp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client-fingerprint": "chrome",
|
||||||
|
"name": "noport-trojan",
|
||||||
|
"password": "pw",
|
||||||
|
"port": "",
|
||||||
|
"server": "t.example",
|
||||||
|
"skip-cert-verify": false,
|
||||||
|
"type": "trojan",
|
||||||
|
"udp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"down": "",
|
||||||
|
"fingerprint": "",
|
||||||
|
"name": "colon-pass",
|
||||||
|
"obfs": "",
|
||||||
|
"obfs-password": "",
|
||||||
|
"password": "user:pa%3Ass",
|
||||||
|
"port": "443",
|
||||||
|
"server": "h.example",
|
||||||
|
"skip-cert-verify": false,
|
||||||
|
"sni": "",
|
||||||
|
"type": "hysteria2",
|
||||||
|
"up": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cipher": "aes-128-gcm",
|
||||||
|
"name": "ss-legacy-padded",
|
||||||
|
"password": "pw",
|
||||||
|
"port": "8388",
|
||||||
|
"server": "1.1.1.1",
|
||||||
|
"type": "ss",
|
||||||
|
"udp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cipher": "chacha20-ietf-poly1305",
|
||||||
|
"name": "plugin-no-semicolon",
|
||||||
|
"password": "pass",
|
||||||
|
"port": "8388",
|
||||||
|
"server": "h.example",
|
||||||
|
"type": "ss",
|
||||||
|
"udp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client-fingerprint": "chrome",
|
||||||
|
"name": "empty-values",
|
||||||
|
"network": "tcp",
|
||||||
|
"port": "443",
|
||||||
|
"server": "example.com",
|
||||||
|
"tls": true,
|
||||||
|
"type": "vless",
|
||||||
|
"udp": true,
|
||||||
|
"uuid": "uuid",
|
||||||
|
"xudp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"http-opts": {
|
||||||
|
"headers": {},
|
||||||
|
"path": [
|
||||||
|
"/"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"name": "tcp-http-upper",
|
||||||
|
"network": "http",
|
||||||
|
"port": "443",
|
||||||
|
"server": "example.com",
|
||||||
|
"type": "vless",
|
||||||
|
"udp": true,
|
||||||
|
"uuid": "uuid",
|
||||||
|
"xudp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "empty-pass",
|
||||||
|
"password": "",
|
||||||
|
"port": "443",
|
||||||
|
"server": "tu.example",
|
||||||
|
"type": "tuic",
|
||||||
|
"udp": true,
|
||||||
|
"uuid": "uuid"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "4.4.4.4:1080",
|
||||||
|
"password": "",
|
||||||
|
"port": "1080",
|
||||||
|
"server": "4.4.4.4",
|
||||||
|
"skip-cert-verify": true,
|
||||||
|
"type": "socks5",
|
||||||
|
"username": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "escaped-user",
|
||||||
|
"network": "tcp",
|
||||||
|
"port": "443",
|
||||||
|
"server": "example.com",
|
||||||
|
"type": "vless",
|
||||||
|
"udp": true,
|
||||||
|
"uuid": "uuid",
|
||||||
|
"xudp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"down": "",
|
||||||
|
"fingerprint": "",
|
||||||
|
"name": "plus-in-query",
|
||||||
|
"obfs": "salamander",
|
||||||
|
"obfs-password": "a+b c",
|
||||||
|
"password": "pw",
|
||||||
|
"port": "443",
|
||||||
|
"server": "h.example",
|
||||||
|
"skip-cert-verify": false,
|
||||||
|
"sni": "",
|
||||||
|
"type": "hysteria2",
|
||||||
|
"up": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alpn": [
|
||||||
|
"h2",
|
||||||
|
"http/1.1"
|
||||||
|
],
|
||||||
|
"alterId": 0,
|
||||||
|
"cipher": "auto",
|
||||||
|
"h2-opts": {
|
||||||
|
"host": [
|
||||||
|
"h"
|
||||||
|
],
|
||||||
|
"path": "/p"
|
||||||
|
},
|
||||||
|
"name": "h2 path",
|
||||||
|
"network": "h2",
|
||||||
|
"port": "443",
|
||||||
|
"server": "x.example",
|
||||||
|
"skip-cert-verify": false,
|
||||||
|
"tls": true,
|
||||||
|
"type": "vmess",
|
||||||
|
"udp": true,
|
||||||
|
"uuid": "i",
|
||||||
|
"xudp": true
|
||||||
|
}
|
||||||
|
]
|
||||||
20
tests/links/links-edge.txt
Normal file
20
tests/links/links-edge.txt
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
VLESS://uuid@Upper.Example.com:443?security=TLS&type=WS&path=%2Fw#upper
|
||||||
|
trojan://a+b%2Bc@t.example:443?sni=a+b#plus
|
||||||
|
trojan://us@er@t.example:443#two-at
|
||||||
|
trojan://pw@t.example:44x3#badport
|
||||||
|
trojan://pw@t.example#noport-trojan
|
||||||
|
hy2://user:pa:ss@h.example:443#colon-pass
|
||||||
|
hy2://pass word@h.example:443#space
|
||||||
|
ss://YWVzLTEyOC1nY206cHdAMS4xLjEuMTo4Mzg4#ss-legacy-padded
|
||||||
|
ss://Y2hhY2hhMjAtaWV0Zi1wb2x5MTMwNTpwYXNz@h.example:8388/?plugin=simple-obfs#plugin-no-semicolon
|
||||||
|
vmess://eyJ2IjoiMiIsInBzIjo1LCJhZGQiOiJ4IiwicG9ydCI6IjEiLCJpZCI6ImkifQ==
|
||||||
|
vmess://bm90IGpzb24=
|
||||||
|
vless://uuid@example.com:443?security=tls&sni=&alpn=#empty-values
|
||||||
|
vless://uuid@example.com:443?type=tcp&headerType=HTTP#tcp-http-upper
|
||||||
|
anytls://pw@:443#nohost
|
||||||
|
tuic://uuid:@tu.example:443#empty-pass
|
||||||
|
socks://@4.4.4.4:1080
|
||||||
|
vless://%75uid@example.com:443#escaped-user
|
||||||
|
hy2://pw@h.example:443/?obfs=salamander&obfs-password=a%2Bb+c#plus-in-query
|
||||||
|
vless://uuid@lead.example:443#leading-space
|
||||||
|
vmess://eyJ2IjoiMiIsInBzIjoiaDIgcGF0aCIsImFkZCI6InguZXhhbXBsZSIsInBvcnQiOiI0NDMiLCJpZCI6ImkiLCJuZXQiOiJodHRwIiwiaG9zdCI6ImgiLCJwYXRoIjoiL3AiLCJ0bHMiOiJ0bHMiLCJhbHBuIjoiaDIsaHR0cC8xLjEifQ==
|
||||||
793
tests/links/links.expected.json
Normal file
793
tests/links/links.expected.json
Normal file
@ -0,0 +1,793 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"alpn": [
|
||||||
|
"h3",
|
||||||
|
"h4"
|
||||||
|
],
|
||||||
|
"down": "514",
|
||||||
|
"fingerprint": "65b3acd7db555768304a16abb6f4366c1a0c0bb5cec81429617f0150d7d66726",
|
||||||
|
"name": "hy2test",
|
||||||
|
"obfs": "salamander",
|
||||||
|
"obfs-password": "gawrgura",
|
||||||
|
"password": "letmein",
|
||||||
|
"port": "8443",
|
||||||
|
"server": "example.com",
|
||||||
|
"skip-cert-verify": true,
|
||||||
|
"sni": "real.example.com",
|
||||||
|
"type": "hysteria2",
|
||||||
|
"up": "114"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"down": "",
|
||||||
|
"fingerprint": "",
|
||||||
|
"name": "hop",
|
||||||
|
"obfs": "",
|
||||||
|
"obfs-password": "",
|
||||||
|
"password": "letmein",
|
||||||
|
"port": "443",
|
||||||
|
"ports": "443,5000-6000",
|
||||||
|
"server": "example.com",
|
||||||
|
"skip-cert-verify": false,
|
||||||
|
"sni": "example.com",
|
||||||
|
"type": "hysteria2",
|
||||||
|
"up": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"down": "",
|
||||||
|
"fingerprint": "",
|
||||||
|
"name": "realm",
|
||||||
|
"obfs": "",
|
||||||
|
"obfs-password": "",
|
||||||
|
"password": "letmein",
|
||||||
|
"port": "8443",
|
||||||
|
"realm-opts": {
|
||||||
|
"enable": true,
|
||||||
|
"realm-id": "rid42",
|
||||||
|
"server-url": "https://rendezvous.example.com:8443",
|
||||||
|
"stun-servers": [
|
||||||
|
"stun1:3478",
|
||||||
|
"stun2:3478"
|
||||||
|
],
|
||||||
|
"token": "tok3n"
|
||||||
|
},
|
||||||
|
"server": "rendezvous.example.com",
|
||||||
|
"skip-cert-verify": false,
|
||||||
|
"sni": "example.com",
|
||||||
|
"type": "hysteria2",
|
||||||
|
"up": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"down": "",
|
||||||
|
"fingerprint": "",
|
||||||
|
"name": "v6 hy2",
|
||||||
|
"obfs": "",
|
||||||
|
"obfs-password": "",
|
||||||
|
"password": "p%40ss%3Aw0rd",
|
||||||
|
"port": "8443",
|
||||||
|
"server": "2001:db8::1",
|
||||||
|
"skip-cert-verify": false,
|
||||||
|
"sni": "x.example",
|
||||||
|
"type": "hysteria2",
|
||||||
|
"up": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"down": "",
|
||||||
|
"fingerprint": "",
|
||||||
|
"name": "noport",
|
||||||
|
"obfs": "",
|
||||||
|
"obfs-password": "",
|
||||||
|
"password": "pw",
|
||||||
|
"port": "443",
|
||||||
|
"server": "h.example",
|
||||||
|
"skip-cert-verify": false,
|
||||||
|
"sni": "",
|
||||||
|
"type": "hysteria2",
|
||||||
|
"up": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"handshake-mode": "HANDSHAKE_NO_WAIT",
|
||||||
|
"multiplexing": "MULTIPLEXING_HIGH",
|
||||||
|
"name": "default:6666/TCP",
|
||||||
|
"password": "pass",
|
||||||
|
"port": 6666,
|
||||||
|
"server": "1.2.3.4",
|
||||||
|
"traffic-pattern": "CCoQARoECAEQCiIYCAMQASoIMDAwMTAyMDMqCDA0MDUwNjA3",
|
||||||
|
"transport": "TCP",
|
||||||
|
"type": "mieru",
|
||||||
|
"udp": true,
|
||||||
|
"username": "user"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"handshake-mode": "HANDSHAKE_NO_WAIT",
|
||||||
|
"multiplexing": "MULTIPLEXING_HIGH",
|
||||||
|
"name": "default:9998-9999/TCP",
|
||||||
|
"password": "pass",
|
||||||
|
"port-range": "9998-9999",
|
||||||
|
"server": "1.2.3.4",
|
||||||
|
"traffic-pattern": "CCoQARoECAEQCiIYCAMQASoIMDAwMTAyMDMqCDA0MDUwNjA3",
|
||||||
|
"transport": "TCP",
|
||||||
|
"type": "mieru",
|
||||||
|
"udp": true,
|
||||||
|
"username": "user"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"handshake-mode": "HANDSHAKE_NO_WAIT",
|
||||||
|
"multiplexing": "MULTIPLEXING_HIGH",
|
||||||
|
"name": "default:6489/UDP",
|
||||||
|
"password": "pass",
|
||||||
|
"port": 6489,
|
||||||
|
"server": "1.2.3.4",
|
||||||
|
"traffic-pattern": "CCoQARoECAEQCiIYCAMQASoIMDAwMTAyMDMqCDA0MDUwNjA3",
|
||||||
|
"transport": "UDP",
|
||||||
|
"type": "mieru",
|
||||||
|
"udp": true,
|
||||||
|
"username": "user"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"handshake-mode": "HANDSHAKE_NO_WAIT",
|
||||||
|
"multiplexing": "MULTIPLEXING_HIGH",
|
||||||
|
"name": "default:4896/UDP",
|
||||||
|
"password": "pass",
|
||||||
|
"port": 4896,
|
||||||
|
"server": "1.2.3.4",
|
||||||
|
"traffic-pattern": "CCoQARoECAEQCiIYCAMQASoIMDAwMTAyMDMqCDA0MDUwNjA3",
|
||||||
|
"transport": "UDP",
|
||||||
|
"type": "mieru",
|
||||||
|
"udp": true,
|
||||||
|
"username": "user"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "simple:443/TCP",
|
||||||
|
"password": "pass",
|
||||||
|
"port": 443,
|
||||||
|
"server": "example.com",
|
||||||
|
"transport": "TCP",
|
||||||
|
"type": "mieru",
|
||||||
|
"udp": true,
|
||||||
|
"username": "user"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client-fingerprint": "chrome",
|
||||||
|
"encryption": "none",
|
||||||
|
"flow": "xtls-rprx-vision",
|
||||||
|
"name": "My-VLESS-Reality-Vision",
|
||||||
|
"network": "tcp",
|
||||||
|
"port": "34888",
|
||||||
|
"reality-opts": {
|
||||||
|
"public-key": "ppQ9FwLrLIa0AOrp1WvcyiaQ37vg2WSy_CD4bIdiTUw",
|
||||||
|
"short-id": "6ba85179f3a2b4c5"
|
||||||
|
},
|
||||||
|
"server": "142.98.76.54",
|
||||||
|
"servername": "github.io",
|
||||||
|
"tls": true,
|
||||||
|
"type": "vless",
|
||||||
|
"udp": true,
|
||||||
|
"uuid": "a1b2c3d4-eacc-4433-981b-7e5f9a8b",
|
||||||
|
"xudp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client-fingerprint": "chrome",
|
||||||
|
"http-opts": {
|
||||||
|
"headers": {
|
||||||
|
"Host": [
|
||||||
|
"cdn.example.com"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"method": "POST",
|
||||||
|
"path": [
|
||||||
|
"/edge"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"name": "vless-http",
|
||||||
|
"network": "http",
|
||||||
|
"port": "443",
|
||||||
|
"server": "example.com",
|
||||||
|
"tls": true,
|
||||||
|
"type": "vless",
|
||||||
|
"udp": true,
|
||||||
|
"uuid": "uuid",
|
||||||
|
"xudp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client-fingerprint": "chrome",
|
||||||
|
"h2-opts": {
|
||||||
|
"host": [
|
||||||
|
"cdn.example.com"
|
||||||
|
],
|
||||||
|
"path": "/grpc"
|
||||||
|
},
|
||||||
|
"name": "vless-h2",
|
||||||
|
"network": "h2",
|
||||||
|
"port": "443",
|
||||||
|
"server": "example.com",
|
||||||
|
"tls": true,
|
||||||
|
"type": "vless",
|
||||||
|
"udp": true,
|
||||||
|
"uuid": "uuid",
|
||||||
|
"xudp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alpn": [
|
||||||
|
"h2",
|
||||||
|
"http/1.1"
|
||||||
|
],
|
||||||
|
"client-fingerprint": "chrome",
|
||||||
|
"name": "ws ed",
|
||||||
|
"network": "ws",
|
||||||
|
"port": "443",
|
||||||
|
"server": "example.com",
|
||||||
|
"tls": true,
|
||||||
|
"type": "vless",
|
||||||
|
"udp": true,
|
||||||
|
"uuid": "uuid",
|
||||||
|
"ws-opts": {
|
||||||
|
"early-data-header-name": "Sec-WebSocket-Protocol",
|
||||||
|
"headers": {
|
||||||
|
"Host": "cdn.example.com",
|
||||||
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36"
|
||||||
|
},
|
||||||
|
"max-early-data": 2048,
|
||||||
|
"path": "/ws?ed=2048"
|
||||||
|
},
|
||||||
|
"xudp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "hu",
|
||||||
|
"network": "ws",
|
||||||
|
"port": "443",
|
||||||
|
"server": "example.com",
|
||||||
|
"type": "vless",
|
||||||
|
"udp": true,
|
||||||
|
"uuid": "uuid",
|
||||||
|
"ws-opts": {
|
||||||
|
"early-data-header-name": "X-Ed",
|
||||||
|
"headers": {
|
||||||
|
"Host": "h",
|
||||||
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36"
|
||||||
|
},
|
||||||
|
"path": "/u",
|
||||||
|
"v2ray-http-upgrade": true,
|
||||||
|
"v2ray-http-upgrade-fast-open": true
|
||||||
|
},
|
||||||
|
"xudp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client-fingerprint": "chrome",
|
||||||
|
"grpc-opts": {
|
||||||
|
"grpc-service-name": "svc"
|
||||||
|
},
|
||||||
|
"name": "grpc",
|
||||||
|
"network": "grpc",
|
||||||
|
"packet-addr": true,
|
||||||
|
"port": "443",
|
||||||
|
"server": "example.com",
|
||||||
|
"tls": true,
|
||||||
|
"type": "vless",
|
||||||
|
"udp": true,
|
||||||
|
"uuid": "uuid"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client-fingerprint": "chrome",
|
||||||
|
"name": "xhttp extra",
|
||||||
|
"network": "xhttp",
|
||||||
|
"port": "443",
|
||||||
|
"reality-opts": {
|
||||||
|
"public-key": "K",
|
||||||
|
"short-id": "ab",
|
||||||
|
"support-x25519mlkem768": true
|
||||||
|
},
|
||||||
|
"server": "example.com",
|
||||||
|
"tls": true,
|
||||||
|
"type": "vless",
|
||||||
|
"udp": true,
|
||||||
|
"uuid": "uuid",
|
||||||
|
"xhttp-opts": {
|
||||||
|
"download-settings": {
|
||||||
|
"path": "/d",
|
||||||
|
"port": 443,
|
||||||
|
"reality-opts": {
|
||||||
|
"public-key": "P",
|
||||||
|
"short-id": "s"
|
||||||
|
},
|
||||||
|
"server": "d.example",
|
||||||
|
"tls": true
|
||||||
|
},
|
||||||
|
"host": "x.example",
|
||||||
|
"mode": "packet-up",
|
||||||
|
"no-grpc-header": true,
|
||||||
|
"path": "/x",
|
||||||
|
"reuse-settings": {
|
||||||
|
"h-keep-alive-period": 30,
|
||||||
|
"max-concurrency": "16-32"
|
||||||
|
},
|
||||||
|
"x-padding-bytes": "100-1000"
|
||||||
|
},
|
||||||
|
"xudp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client-fingerprint": "firefox",
|
||||||
|
"fingerprint": "abc",
|
||||||
|
"flow": "xtls-rprx-vision",
|
||||||
|
"name": "flow",
|
||||||
|
"network": "tcp",
|
||||||
|
"port": "443",
|
||||||
|
"server": "example.com",
|
||||||
|
"tls": true,
|
||||||
|
"type": "vless",
|
||||||
|
"udp": true,
|
||||||
|
"uuid": "uuid"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client-fingerprint": "chrome",
|
||||||
|
"name": "b64host",
|
||||||
|
"network": "tcp",
|
||||||
|
"port": "443",
|
||||||
|
"server": "example.com",
|
||||||
|
"tls": true,
|
||||||
|
"type": "vless",
|
||||||
|
"udp": true,
|
||||||
|
"uuid": "uuid",
|
||||||
|
"xudp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "semicolon",
|
||||||
|
"network": "tcp",
|
||||||
|
"port": "443",
|
||||||
|
"server": "example.com",
|
||||||
|
"servername": "s",
|
||||||
|
"type": "vless",
|
||||||
|
"udp": true,
|
||||||
|
"uuid": "uuid",
|
||||||
|
"xudp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "badesc",
|
||||||
|
"network": "tcp",
|
||||||
|
"port": "443",
|
||||||
|
"server": "example.com",
|
||||||
|
"servername": "a b",
|
||||||
|
"type": "vless",
|
||||||
|
"udp": true,
|
||||||
|
"uuid": "uuid",
|
||||||
|
"xudp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alterId": "0",
|
||||||
|
"cipher": "auto",
|
||||||
|
"h2-opts": {
|
||||||
|
"host": [
|
||||||
|
"cdn.example.com"
|
||||||
|
],
|
||||||
|
"path": "/grpc"
|
||||||
|
},
|
||||||
|
"name": "demo",
|
||||||
|
"network": "h2",
|
||||||
|
"port": "443",
|
||||||
|
"server": "server.example.com",
|
||||||
|
"skip-cert-verify": false,
|
||||||
|
"tls": true,
|
||||||
|
"type": "vmess",
|
||||||
|
"udp": true,
|
||||||
|
"uuid": "b831381d-6324-4d53-ad4f-8cda48b30811",
|
||||||
|
"xudp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alpn": [
|
||||||
|
"h2"
|
||||||
|
],
|
||||||
|
"alterId": 0,
|
||||||
|
"cipher": "auto",
|
||||||
|
"name": "ws ed-01",
|
||||||
|
"network": "ws",
|
||||||
|
"port": 443,
|
||||||
|
"server": "v.example.com",
|
||||||
|
"servername": "s.example",
|
||||||
|
"skip-cert-verify": false,
|
||||||
|
"tls": true,
|
||||||
|
"type": "vmess",
|
||||||
|
"udp": true,
|
||||||
|
"uuid": "id",
|
||||||
|
"ws-opts": {
|
||||||
|
"early-data-header-name": "Sec-WebSocket-Protocol",
|
||||||
|
"headers": {
|
||||||
|
"Host": "v.example.com"
|
||||||
|
},
|
||||||
|
"max-early-data": 2048,
|
||||||
|
"path": "/w?a=1&b=2"
|
||||||
|
},
|
||||||
|
"xudp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alterId": 0,
|
||||||
|
"cipher": "auto",
|
||||||
|
"http-opts": {
|
||||||
|
"headers": {
|
||||||
|
"Host": [
|
||||||
|
"hh"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"path": [
|
||||||
|
"/p"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"name": "http",
|
||||||
|
"network": "http",
|
||||||
|
"port": "80",
|
||||||
|
"server": "v.example.com",
|
||||||
|
"skip-cert-verify": false,
|
||||||
|
"tls": false,
|
||||||
|
"type": "vmess",
|
||||||
|
"udp": true,
|
||||||
|
"uuid": "id",
|
||||||
|
"xudp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alterId": 0,
|
||||||
|
"cipher": "aes-128-gcm",
|
||||||
|
"grpc-opts": {
|
||||||
|
"grpc-service-name": "svc"
|
||||||
|
},
|
||||||
|
"name": "grpc-01",
|
||||||
|
"network": "grpc",
|
||||||
|
"port": "443",
|
||||||
|
"server": "v.example.com",
|
||||||
|
"skip-cert-verify": false,
|
||||||
|
"tls": true,
|
||||||
|
"type": "vmess",
|
||||||
|
"udp": true,
|
||||||
|
"uuid": "id",
|
||||||
|
"xudp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alterId": 0,
|
||||||
|
"cipher": "auto",
|
||||||
|
"name": "demo-01",
|
||||||
|
"network": "tcp",
|
||||||
|
"port": "443",
|
||||||
|
"server": "dup.example.com",
|
||||||
|
"skip-cert-verify": false,
|
||||||
|
"tls": false,
|
||||||
|
"type": "vmess",
|
||||||
|
"udp": true,
|
||||||
|
"uuid": "id",
|
||||||
|
"xudp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alterId": 0,
|
||||||
|
"cipher": "auto",
|
||||||
|
"name": "hu-01",
|
||||||
|
"network": "ws",
|
||||||
|
"port": "443",
|
||||||
|
"server": "v.example.com",
|
||||||
|
"skip-cert-verify": false,
|
||||||
|
"tls": false,
|
||||||
|
"type": "vmess",
|
||||||
|
"udp": true,
|
||||||
|
"uuid": "id",
|
||||||
|
"ws-opts": {
|
||||||
|
"early-data-header-name": "X",
|
||||||
|
"headers": {},
|
||||||
|
"path": "/u?eh=X",
|
||||||
|
"v2ray-http-upgrade": true,
|
||||||
|
"v2ray-http-upgrade-fast-open": true
|
||||||
|
},
|
||||||
|
"xudp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alterId": 0,
|
||||||
|
"cipher": "aes-128-gcm",
|
||||||
|
"client-fingerprint": "chrome",
|
||||||
|
"name": "aead",
|
||||||
|
"network": "ws",
|
||||||
|
"port": "443",
|
||||||
|
"server": "aead.example.com",
|
||||||
|
"tls": true,
|
||||||
|
"type": "vmess",
|
||||||
|
"udp": true,
|
||||||
|
"uuid": "uuid",
|
||||||
|
"ws-opts": {
|
||||||
|
"headers": {
|
||||||
|
"Host": "h",
|
||||||
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36"
|
||||||
|
},
|
||||||
|
"path": "/a"
|
||||||
|
},
|
||||||
|
"xudp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alpn": [
|
||||||
|
"h2"
|
||||||
|
],
|
||||||
|
"client-fingerprint": "chrome",
|
||||||
|
"grpc-opts": {
|
||||||
|
"grpc-service-name": "g"
|
||||||
|
},
|
||||||
|
"name": "tr",
|
||||||
|
"network": "grpc",
|
||||||
|
"password": "pw",
|
||||||
|
"port": "443",
|
||||||
|
"server": "t.example.org",
|
||||||
|
"skip-cert-verify": true,
|
||||||
|
"sni": "t.example.org",
|
||||||
|
"type": "trojan",
|
||||||
|
"udp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client-fingerprint": "safari",
|
||||||
|
"fingerprint": "deadbeef",
|
||||||
|
"name": "tr-ws",
|
||||||
|
"network": "ws",
|
||||||
|
"password": "p@w",
|
||||||
|
"port": "443",
|
||||||
|
"server": "t.example.org",
|
||||||
|
"skip-cert-verify": false,
|
||||||
|
"type": "trojan",
|
||||||
|
"udp": true,
|
||||||
|
"ws-opts": {
|
||||||
|
"headers": {
|
||||||
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36"
|
||||||
|
},
|
||||||
|
"path": "/ws"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client-fingerprint": "chrome",
|
||||||
|
"name": "tr-hu",
|
||||||
|
"network": "ws",
|
||||||
|
"password": "pw",
|
||||||
|
"port": "443",
|
||||||
|
"server": "t.example.org",
|
||||||
|
"skip-cert-verify": false,
|
||||||
|
"type": "trojan",
|
||||||
|
"udp": true,
|
||||||
|
"ws-opts": {
|
||||||
|
"headers": {
|
||||||
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36"
|
||||||
|
},
|
||||||
|
"path": "/hu",
|
||||||
|
"v2ray-http-upgrade": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client-fingerprint": "chrome",
|
||||||
|
"name": "tr-badbool",
|
||||||
|
"password": "pw",
|
||||||
|
"port": "443",
|
||||||
|
"server": "t.example.org",
|
||||||
|
"skip-cert-verify": false,
|
||||||
|
"type": "trojan",
|
||||||
|
"udp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cipher": "aes-256-gcm",
|
||||||
|
"name": "ss1",
|
||||||
|
"password": "pass",
|
||||||
|
"port": "8388",
|
||||||
|
"server": "1.2.3.4",
|
||||||
|
"type": "ss",
|
||||||
|
"udp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cipher": "aes-256-gcm",
|
||||||
|
"name": "ss-padded",
|
||||||
|
"password": "pass",
|
||||||
|
"port": "8389",
|
||||||
|
"server": "1.2.3.4",
|
||||||
|
"type": "ss",
|
||||||
|
"udp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cipher": "chacha20-ietf-poly1305",
|
||||||
|
"name": "ss-sip002-old",
|
||||||
|
"password": "secret",
|
||||||
|
"port": "9000",
|
||||||
|
"server": "5.6.7.8",
|
||||||
|
"type": "ss",
|
||||||
|
"udp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cipher": "2022-blake3-aes-128-gcm",
|
||||||
|
"name": "ss2022",
|
||||||
|
"password": "YWJjZGVmZ2hpamtsbW5vcA==",
|
||||||
|
"port": "443",
|
||||||
|
"server": "9.9.9.9",
|
||||||
|
"type": "ss",
|
||||||
|
"udp": true,
|
||||||
|
"udp-over-tcp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cipher": "aes-128-gcm",
|
||||||
|
"name": "ss-obfs",
|
||||||
|
"password": "pw",
|
||||||
|
"plugin": "obfs",
|
||||||
|
"plugin-opts": {
|
||||||
|
"host": "bing.com",
|
||||||
|
"mode": "http"
|
||||||
|
},
|
||||||
|
"port": "443",
|
||||||
|
"server": "h.example",
|
||||||
|
"type": "ss",
|
||||||
|
"udp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cipher": "aes-128-gcm",
|
||||||
|
"name": "ss-v2ray",
|
||||||
|
"password": "pw",
|
||||||
|
"plugin": "v2ray-plugin",
|
||||||
|
"plugin-opts": {
|
||||||
|
"host": "h.example",
|
||||||
|
"mode": "websocket",
|
||||||
|
"path": "/v",
|
||||||
|
"tls": true
|
||||||
|
},
|
||||||
|
"port": "443",
|
||||||
|
"server": "h.example",
|
||||||
|
"type": "ss",
|
||||||
|
"udp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alpn": [
|
||||||
|
"h3"
|
||||||
|
],
|
||||||
|
"congestion-controller": "bbr",
|
||||||
|
"disable-sni": true,
|
||||||
|
"name": "tuic5",
|
||||||
|
"password": "pass",
|
||||||
|
"port": "443",
|
||||||
|
"server": "tu.example",
|
||||||
|
"sni": "tu.example",
|
||||||
|
"type": "tuic",
|
||||||
|
"udp": true,
|
||||||
|
"udp-relay-mode": "native",
|
||||||
|
"uuid": "uuid"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "tuic4",
|
||||||
|
"port": "443",
|
||||||
|
"server": "tu.example",
|
||||||
|
"token": "token",
|
||||||
|
"type": "tuic",
|
||||||
|
"udp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fingerprint": "xx",
|
||||||
|
"name": "any",
|
||||||
|
"password": "pw",
|
||||||
|
"port": "443",
|
||||||
|
"server": "an.example",
|
||||||
|
"skip-cert-verify": true,
|
||||||
|
"sni": "an.example",
|
||||||
|
"type": "anytls",
|
||||||
|
"udp": true,
|
||||||
|
"username": "pw"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fingerprint": "",
|
||||||
|
"name": "an.example:8443",
|
||||||
|
"password": "pw",
|
||||||
|
"port": "8443",
|
||||||
|
"server": "an.example",
|
||||||
|
"skip-cert-verify": false,
|
||||||
|
"sni": "",
|
||||||
|
"type": "anytls",
|
||||||
|
"udp": true,
|
||||||
|
"username": "user"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sk",
|
||||||
|
"password": "pass",
|
||||||
|
"port": "1080",
|
||||||
|
"server": "1.1.1.1",
|
||||||
|
"skip-cert-verify": true,
|
||||||
|
"type": "socks5",
|
||||||
|
"username": "user"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "2.2.2.2:3128",
|
||||||
|
"password": "",
|
||||||
|
"port": "3128",
|
||||||
|
"server": "2.2.2.2",
|
||||||
|
"skip-cert-verify": true,
|
||||||
|
"type": "http",
|
||||||
|
"username": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "tlsproxy",
|
||||||
|
"password": "pass",
|
||||||
|
"port": "443",
|
||||||
|
"server": "3.3.3.3",
|
||||||
|
"skip-cert-verify": true,
|
||||||
|
"tls": true,
|
||||||
|
"type": "http",
|
||||||
|
"username": "user"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cipher": "aes-256-cfb",
|
||||||
|
"name": "ssr name",
|
||||||
|
"obfs": "plain",
|
||||||
|
"obfs-param": "op",
|
||||||
|
"password": "pwd",
|
||||||
|
"port": "443",
|
||||||
|
"protocol": "origin",
|
||||||
|
"server": "1.2.3.4",
|
||||||
|
"type": "ssr",
|
||||||
|
"udp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alpn": [
|
||||||
|
"h3"
|
||||||
|
],
|
||||||
|
"auth_str": "a",
|
||||||
|
"down": "50",
|
||||||
|
"name": "hy1",
|
||||||
|
"obfs": "xplus",
|
||||||
|
"port": "443",
|
||||||
|
"protocol": "udp",
|
||||||
|
"server": "h1.example",
|
||||||
|
"skip-cert-verify": true,
|
||||||
|
"sni": "sni.example",
|
||||||
|
"type": "hysteria",
|
||||||
|
"up": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client-fingerprint": "chrome",
|
||||||
|
"name": "v6vless",
|
||||||
|
"network": "tcp",
|
||||||
|
"port": "443",
|
||||||
|
"server": "2001:db8::2",
|
||||||
|
"servername": "v6.example",
|
||||||
|
"tls": true,
|
||||||
|
"type": "vless",
|
||||||
|
"udp": true,
|
||||||
|
"uuid": "uuid",
|
||||||
|
"xudp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client-fingerprint": "chrome",
|
||||||
|
"name": "✓ emoji 🇩🇪",
|
||||||
|
"network": "tcp",
|
||||||
|
"port": "443",
|
||||||
|
"server": "example.com",
|
||||||
|
"tls": true,
|
||||||
|
"type": "vless",
|
||||||
|
"udp": true,
|
||||||
|
"uuid": "uuid",
|
||||||
|
"xudp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client-fingerprint": "chrome",
|
||||||
|
"name": "dup",
|
||||||
|
"network": "tcp",
|
||||||
|
"port": "443",
|
||||||
|
"server": "example.com",
|
||||||
|
"tls": true,
|
||||||
|
"type": "vless",
|
||||||
|
"udp": true,
|
||||||
|
"uuid": "uuid",
|
||||||
|
"xudp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client-fingerprint": "chrome",
|
||||||
|
"name": "dup-01",
|
||||||
|
"network": "tcp",
|
||||||
|
"port": "443",
|
||||||
|
"server": "example.com",
|
||||||
|
"tls": true,
|
||||||
|
"type": "vless",
|
||||||
|
"udp": true,
|
||||||
|
"uuid": "uuid",
|
||||||
|
"xudp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client-fingerprint": "chrome",
|
||||||
|
"name": "dup-02",
|
||||||
|
"network": "tcp",
|
||||||
|
"port": "443",
|
||||||
|
"server": "example.com",
|
||||||
|
"tls": true,
|
||||||
|
"type": "vless",
|
||||||
|
"udp": true,
|
||||||
|
"uuid": "uuid",
|
||||||
|
"xudp": true
|
||||||
|
}
|
||||||
|
]
|
||||||
54
tests/links/links.txt
Normal file
54
tests/links/links.txt
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
hysteria2://letmein@example.com:8443/?insecure=1&obfs=salamander&obfs-password=gawrgura&pinSHA256=65b3acd7db555768304a16abb6f4366c1a0c0bb5cec81429617f0150d7d66726&sni=real.example.com&up=114&down=514&alpn=h3,h4#hy2test
|
||||||
|
hysteria2://letmein@example.com:443,5000-6000/?sni=example.com#hop
|
||||||
|
hysteria2+realm://tok3n@rendezvous.example.com:8443/rid42?auth=letmein&stun=stun1:3478&stun=stun2:3478&sni=example.com#realm
|
||||||
|
hy2://p%40ss%3Aw0rd@[2001:db8::1]:8443?sni=x.example#v6%20hy2
|
||||||
|
hy2://pw@h.example#noport
|
||||||
|
mierus://user:pass@1.2.3.4?handshake-mode=HANDSHAKE_NO_WAIT&mtu=1400&multiplexing=MULTIPLEXING_HIGH&port=6666&port=9998-9999&port=6489&port=4896&profile=default&protocol=TCP&protocol=TCP&protocol=UDP&protocol=UDP&traffic-pattern=CCoQARoECAEQCiIYCAMQASoIMDAwMTAyMDMqCDA0MDUwNjA3
|
||||||
|
mierus://user:pass@example.com?port=443&protocol=TCP&profile=simple
|
||||||
|
vless://a1b2c3d4-eacc-4433-981b-7e5f9a8b@142.98.76.54:34888?encryption=none&security=reality&type=tcp&sni=github.io&fp=chrome&pbk=ppQ9FwLrLIa0AOrp1WvcyiaQ37vg2WSy_CD4bIdiTUw&sid=6ba85179f3a2b4c5&flow=xtls-rprx-vision#My-VLESS-Reality-Vision
|
||||||
|
vless://uuid@example.com:443?security=tls&type=tcp&headerType=http&host=cdn.example.com&path=%2Fedge&method=POST#vless-http
|
||||||
|
vless://uuid@example.com:443?security=tls&type=http&host=cdn.example.com&path=%2Fgrpc#vless-h2
|
||||||
|
vless://uuid@example.com:443?security=tls&type=ws&host=cdn.example.com&path=%2Fws%3Fed%3D2048&ed=2048&alpn=h2,http/1.1#ws%20ed
|
||||||
|
vless://uuid@example.com:443?security=none&type=httpupgrade&host=h&path=%2Fu&ed=1024&eh=X-Ed#hu
|
||||||
|
vless://uuid@example.com:443?security=tls&type=grpc&serviceName=svc&packetEncoding=packet#grpc
|
||||||
|
vless://uuid@example.com:443?security=reality&type=xhttp&pbk=K&sid=ab&mode=packet-up&host=x.example&path=%2Fx&support-x25519mlkem768=true&extra=%7B%22xPaddingBytes%22%3A%22100-1000%22%2C%22noGRPCHeader%22%3Atrue%2C%22xmux%22%3A%7B%22maxConcurrency%22%3A%2216-32%22%2C%22hKeepAlivePeriod%22%3A30%7D%2C%22downloadSettings%22%3A%7B%22address%22%3A%22d.example%22%2C%22port%22%3A443%2C%22security%22%3A%22reality%22%2C%22realitySettings%22%3A%7B%22publicKey%22%3A%22P%22%2C%22shortId%22%3A%22s%22%7D%2C%22xhttpSettings%22%3A%7B%22path%22%3A%22%2Fd%22%7D%7D%7D#xhttp%20extra
|
||||||
|
vless://uuid@example.com:443?packetEncoding=none&flow=XTLS-RPRX-VISION&fp=firefox&security=tls&pcs=abc#flow
|
||||||
|
vless://uuid@example.com?security=tls#noport
|
||||||
|
vless://uuid@ZXhhbXBsZS5jb206NDQz?security=tls#b64host
|
||||||
|
vless://uuid@example.com:443?type=ws&ed=abc#bad-ed
|
||||||
|
vless://uuid@example.com:443?a=b;c=d&sni=s#semicolon
|
||||||
|
vless://uuid@example.com:443?sni=a+b&path=%zz#badesc
|
||||||
|
vmess://eyJ2IjoiMiIsInBzIjoiZGVtbyIsImFkZCI6InNlcnZlci5leGFtcGxlLmNvbSIsInBvcnQiOiI0NDMiLCJpZCI6ImI4MzEzODFkLTYzMjQtNGQ1My1hZDRmLThjZGE0OGIzMDgxMSIsImFpZCI6IjAiLCJzY3kiOiJhdXRvIiwibmV0IjoiaDIiLCJ0eXBlIjoibm9uZSIsImhvc3QiOiJjZG4uZXhhbXBsZS5jb20iLCJwYXRoIjoiL2dycGMiLCJ0bHMiOiJ0bHMifQ==
|
||||||
|
vmess://eyJ2IjoiMiIsInBzIjoid3MgZWQiLCJhZGQiOiJ2LmV4YW1wbGUuY29tIiwicG9ydCI6NDQzLCJpZCI6ImlkIiwiYWlkIjowLCJuZXQiOiJ3cyIsImhvc3QiOiJ2LmV4YW1wbGUuY29tIiwicGF0aCI6Ii93P2VkPTIwNDgmYj0yJmE9MSIsInRscyI6InRscyIsInNuaSI6InMuZXhhbXBsZSIsImFscG4iOiJoMiJ9
|
||||||
|
vmess://eyJ2IjoiMiIsInBzIjoiaHR0cCIsImFkZCI6InYuZXhhbXBsZS5jb20iLCJwb3J0IjoiODAiLCJpZCI6ImlkIiwibmV0IjoidGNwIiwidHlwZSI6Imh0dHAiLCJob3N0IjoiaGgiLCJwYXRoIjoiL3AifQ==
|
||||||
|
vmess://eyJ2IjoiMiIsInBzIjoiZ3JwYyIsImFkZCI6InYuZXhhbXBsZS5jb20iLCJwb3J0IjoiNDQzIiwiaWQiOiJpZCIsIm5ldCI6ImdycGMiLCJwYXRoIjoic3ZjIiwidGxzIjoiVExTIiwic2N5IjoiYWVzLTEyOC1nY20ifQ==
|
||||||
|
vmess://eyJ2IjoiMiIsInBzIjoiZGVtbyIsImFkZCI6ImR1cC5leGFtcGxlLmNvbSIsInBvcnQiOiI0NDMiLCJpZCI6ImlkIiwibmV0IjoidGNwIn0=
|
||||||
|
vmess://eyJ2IjoiMiIsInBzIjoiaHUiLCJhZGQiOiJ2LmV4YW1wbGUuY29tIiwicG9ydCI6IjQ0MyIsImlkIjoiaWQiLCJuZXQiOiJodHRwdXBncmFkZSIsInBhdGgiOiIvdT9lZD0xMDI0JmVoPVgifQ==
|
||||||
|
vmess://eyJ2IjoiMiIsImFkZCI6Im5vbmFtZS5leGFtcGxlLmNvbSIsInBvcnQiOiI0NDMiLCJpZCI6ImlkIn0=
|
||||||
|
vmess://uuid@aead.example.com:443?encryption=aes-128-gcm&type=ws&path=%2Fa&host=h&security=tls#aead
|
||||||
|
trojan://pw@t.example.org:443?sni=t.example.org&type=grpc&serviceName=g&allowInsecure=1&alpn=h2#tr
|
||||||
|
trojan://p%40w@t.example.org:443?type=ws&path=%2Fws&fp=safari&pcs=deadbeef#tr-ws
|
||||||
|
trojan://pw@t.example.org:443?type=httpupgrade&path=%2Fhu#tr-hu
|
||||||
|
trojan://pw@t.example.org:443?allowInsecure=yes#tr-badbool
|
||||||
|
ss://YWVzLTI1Ni1nY206cGFzcw@1.2.3.4:8388#ss1
|
||||||
|
ss://YWVzLTI1Ni1nY206cGFzcw==@1.2.3.4:8389#ss-padded
|
||||||
|
ss://Y2hhY2hhMjAtaWV0Zi1wb2x5MTMwNTpzZWNyZXRANS42LjcuODo5MDAw#ss-sip002-old
|
||||||
|
ss://2022-blake3-aes-128-gcm:YWJjZGVmZ2hpamtsbW5vcA%3D%3D@9.9.9.9:443?uot=1#ss2022
|
||||||
|
ss://YWVzLTEyOC1nY206cHc@h.example:443?plugin=obfs-local%3Bobfs%3Dhttp%3Bobfs-host%3Dbing.com#ss-obfs
|
||||||
|
ss://YWVzLTEyOC1nY206cHc@h.example:443?plugin=v2ray-plugin%3Bmode%3Dwebsocket%3Bhost%3Dh.example%3Bpath%3D%2Fv%3Btls#ss-v2ray
|
||||||
|
tuic://uuid:pass@tu.example:443?congestion_control=bbr&alpn=h3&sni=tu.example&udp_relay_mode=native&disable_sni=1#tuic5
|
||||||
|
tuic://token@tu.example:443#tuic4
|
||||||
|
anytls://pw@an.example:443?sni=an.example&insecure=1&hpkp=xx#any
|
||||||
|
anytls://user:pw@an.example:8443
|
||||||
|
socks5://dXNlcjpwYXNz@1.1.1.1:1080#sk
|
||||||
|
http://2.2.2.2:3128
|
||||||
|
https://dXNlcjpwYXNz@3.3.3.3:443#tlsproxy
|
||||||
|
ssr://MS4yLjMuNDo0NDM6b3JpZ2luOmFlcy0yNTYtY2ZiOnBsYWluOmNIZGsvP3JlbWFya3M9YzNOeUlHNWhiV1Umb2Jmc3BhcmFtPWIzQQ
|
||||||
|
hysteria://h1.example:443?peer=sni.example&auth=a&upmbps=10&downmbps=50&obfs=xplus&alpn=h3&protocol=udp&insecure=true#hy1
|
||||||
|
unknown://foo@bar:1
|
||||||
|
just text
|
||||||
|
vless://uuid@[2001:db8::2]:443?security=tls&sni=v6.example#v6vless
|
||||||
|
vless://uuid@example.com:443?security=tls#%E2%9C%93%20emoji%20%F0%9F%87%A9%F0%9F%87%AA
|
||||||
|
vless://uuid@example.com:443?security=tls#dup
|
||||||
|
vless://uuid@example.com:443?security=tls#dup
|
||||||
|
vless://uuid@example.com:443?security=tls#dup
|
||||||
1
tests/links/sub.b64
Normal file
1
tests/links/sub.b64
Normal file
@ -0,0 +1 @@
|
|||||||
|
dmxlc3M6Ly91dWlkQHMxLmV4YW1wbGU6NDQzP3NlY3VyaXR5PXJlYWxpdHkmcGJrPUsmc2lkPTEjczEKdHJvamFuOi8vcHdAczIuZXhhbXBsZTo0NDMjczI=
|
||||||
28
tests/links/sub.expected.json
Normal file
28
tests/links/sub.expected.json
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"client-fingerprint": "chrome",
|
||||||
|
"name": "s1",
|
||||||
|
"network": "tcp",
|
||||||
|
"port": "443",
|
||||||
|
"reality-opts": {
|
||||||
|
"public-key": "K",
|
||||||
|
"short-id": "1"
|
||||||
|
},
|
||||||
|
"server": "s1.example",
|
||||||
|
"tls": true,
|
||||||
|
"type": "vless",
|
||||||
|
"udp": true,
|
||||||
|
"uuid": "uuid",
|
||||||
|
"xudp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client-fingerprint": "chrome",
|
||||||
|
"name": "s2",
|
||||||
|
"password": "pw",
|
||||||
|
"port": "443",
|
||||||
|
"server": "s2.example",
|
||||||
|
"skip-cert-verify": false,
|
||||||
|
"type": "trojan",
|
||||||
|
"udp": true
|
||||||
|
}
|
||||||
|
]
|
||||||
95
tests/yaml/clash.expected.json
Normal file
95
tests/yaml/clash.expected.json
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
{
|
||||||
|
"port": 7890,
|
||||||
|
"proxies": [
|
||||||
|
{
|
||||||
|
"alpn": [
|
||||||
|
"h2",
|
||||||
|
"http/1.1"
|
||||||
|
],
|
||||||
|
"client-fingerprint": "chrome",
|
||||||
|
"name": "🇩🇪 de-1 | vless",
|
||||||
|
"network": "xhttp",
|
||||||
|
"port": 443,
|
||||||
|
"reality-opts": {
|
||||||
|
"public-key": "K-_kk",
|
||||||
|
"short-id": "ab"
|
||||||
|
},
|
||||||
|
"server": "x.example",
|
||||||
|
"servername": "www.example.com",
|
||||||
|
"tls": true,
|
||||||
|
"type": "vless",
|
||||||
|
"udp": true,
|
||||||
|
"uuid": "0b1c2d3e-0000-4000-8000-000000000001",
|
||||||
|
"xhttp-opts": {
|
||||||
|
"headers": {
|
||||||
|
"X-Forwarded-For": "1.2.3.4"
|
||||||
|
},
|
||||||
|
"mode": "packet-up",
|
||||||
|
"path": "/x"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "b",
|
||||||
|
"password": "p#w",
|
||||||
|
"port": 443,
|
||||||
|
"server": "t:x",
|
||||||
|
"sni": "t.example",
|
||||||
|
"type": "trojan",
|
||||||
|
"udp": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"down": "100 mbps",
|
||||||
|
"name": "c",
|
||||||
|
"obfs": "salamander",
|
||||||
|
"obfs-password": "a\"b\\cé",
|
||||||
|
"password": "it's",
|
||||||
|
"ports": "2000-3000",
|
||||||
|
"server": "h.example",
|
||||||
|
"skip-cert-verify": true,
|
||||||
|
"type": "hysteria2",
|
||||||
|
"up": "50 mbps"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cipher": "aes-256-gcm",
|
||||||
|
"name": "d",
|
||||||
|
"password": 123456,
|
||||||
|
"plugin": "obfs",
|
||||||
|
"plugin-opts": {
|
||||||
|
"host": "bing.com",
|
||||||
|
"mode": "tls"
|
||||||
|
},
|
||||||
|
"port": 8388,
|
||||||
|
"server": "1.2.3.4",
|
||||||
|
"type": "ss"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alterId": 0,
|
||||||
|
"cipher": "auto",
|
||||||
|
"name": "e",
|
||||||
|
"port": "443",
|
||||||
|
"server": "v.example",
|
||||||
|
"smux": {
|
||||||
|
"enabled": false,
|
||||||
|
"padding": null
|
||||||
|
},
|
||||||
|
"type": "vmess",
|
||||||
|
"uuid": "x",
|
||||||
|
"ws-opts": {
|
||||||
|
"headers": {
|
||||||
|
"Host": "v.example"
|
||||||
|
},
|
||||||
|
"path": "/w?ed=2048"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"proxy-groups": [
|
||||||
|
{
|
||||||
|
"name": "G",
|
||||||
|
"proxies": [
|
||||||
|
"b",
|
||||||
|
"c"
|
||||||
|
],
|
||||||
|
"type": "select"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
61
tests/yaml/clash.yaml
Normal file
61
tests/yaml/clash.yaml
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
# a typical subscription / Clash config
|
||||||
|
port: 7890
|
||||||
|
proxies:
|
||||||
|
- name: "🇩🇪 de-1 | vless" # a comment
|
||||||
|
type: vless
|
||||||
|
server: x.example
|
||||||
|
port: 443
|
||||||
|
uuid: 0b1c2d3e-0000-4000-8000-000000000001
|
||||||
|
network: xhttp
|
||||||
|
tls: true
|
||||||
|
udp: true
|
||||||
|
servername: www.example.com
|
||||||
|
client-fingerprint: chrome
|
||||||
|
alpn: [h2, "http/1.1"]
|
||||||
|
reality-opts: {public-key: K-_kk, short-id: ab}
|
||||||
|
xhttp-opts:
|
||||||
|
path: /x
|
||||||
|
mode: packet-up
|
||||||
|
headers:
|
||||||
|
X-Forwarded-For: 1.2.3.4
|
||||||
|
- {name: b, type: trojan, server: "t:x", port: 443, password: "p#w", udp: true, sni: t.example}
|
||||||
|
- name: c
|
||||||
|
type: hysteria2
|
||||||
|
server: h.example
|
||||||
|
ports: 2000-3000
|
||||||
|
password: 'it''s'
|
||||||
|
up: 50 mbps
|
||||||
|
down: "100 mbps"
|
||||||
|
obfs: salamander
|
||||||
|
obfs-password: "a\"b\\cé"
|
||||||
|
skip-cert-verify: True
|
||||||
|
- name: d
|
||||||
|
type: ss
|
||||||
|
server: 1.2.3.4
|
||||||
|
port: 8388
|
||||||
|
cipher: aes-256-gcm
|
||||||
|
password: 123456
|
||||||
|
plugin: obfs
|
||||||
|
plugin-opts:
|
||||||
|
mode: tls
|
||||||
|
host: bing.com
|
||||||
|
-
|
||||||
|
name: e
|
||||||
|
type: vmess
|
||||||
|
server: v.example
|
||||||
|
port: "443"
|
||||||
|
uuid: x
|
||||||
|
alterId: 0
|
||||||
|
cipher: auto
|
||||||
|
ws-opts:
|
||||||
|
path: "/w?ed=2048"
|
||||||
|
headers: {Host: v.example}
|
||||||
|
smux:
|
||||||
|
enabled: false
|
||||||
|
padding: ~
|
||||||
|
proxy-groups:
|
||||||
|
- name: G
|
||||||
|
type: select
|
||||||
|
proxies:
|
||||||
|
- b
|
||||||
|
- c
|
||||||
39
tests/yaml/list.expected.json
Normal file
39
tests/yaml/list.expected.json
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"colon-in": "http://a.example:8080/p",
|
||||||
|
"dash": "-",
|
||||||
|
"empty": null,
|
||||||
|
"float": 1.5,
|
||||||
|
"folded": "word one word two\npara",
|
||||||
|
"hash-in": "a#b",
|
||||||
|
"hex": 31,
|
||||||
|
"multi": [
|
||||||
|
"a",
|
||||||
|
"b",
|
||||||
|
"c"
|
||||||
|
],
|
||||||
|
"name": "one",
|
||||||
|
"neg": -3,
|
||||||
|
"nested": [
|
||||||
|
[
|
||||||
|
1,
|
||||||
|
2
|
||||||
|
],
|
||||||
|
{
|
||||||
|
"k": "v",
|
||||||
|
"k2": [
|
||||||
|
"a",
|
||||||
|
{
|
||||||
|
"x": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"port": 1080,
|
||||||
|
"quoted": "two lines",
|
||||||
|
"server": "s.example",
|
||||||
|
"str-num": "443",
|
||||||
|
"text": "line 1\nline 2\n",
|
||||||
|
"type": "socks5"
|
||||||
|
}
|
||||||
|
]
|
||||||
29
tests/yaml/list.yaml
Normal file
29
tests/yaml/list.yaml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
- name: one
|
||||||
|
type: socks5
|
||||||
|
server: s.example
|
||||||
|
port: 1080
|
||||||
|
empty:
|
||||||
|
nested:
|
||||||
|
- - 1
|
||||||
|
- 2
|
||||||
|
- k: v
|
||||||
|
k2: [a, {x: 1}]
|
||||||
|
multi: [a,
|
||||||
|
b, c]
|
||||||
|
text: |
|
||||||
|
line 1
|
||||||
|
line 2
|
||||||
|
folded: >-
|
||||||
|
word one
|
||||||
|
word two
|
||||||
|
|
||||||
|
para
|
||||||
|
quoted: "two
|
||||||
|
lines"
|
||||||
|
float: 1.5
|
||||||
|
hex: 0x1F
|
||||||
|
neg: -3
|
||||||
|
str-num: "443"
|
||||||
|
colon-in: http://a.example:8080/p
|
||||||
|
hash-in: a#b
|
||||||
|
dash: "-"
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user