Compare commits
No commits in common. "main" and "core-v1.19.34-ts8" have entirely different histories.
main
...
core-v1.19
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,7 +11,6 @@
|
||||
__pycache__/
|
||||
tools/core/work/
|
||||
tools/core/dist/
|
||||
tools/nikki-work/
|
||||
|
||||
# Local agent notes
|
||||
/AGENTS.md
|
||||
|
||||
90
README.md
90
README.md
@ -21,24 +21,7 @@ ssh root@192.168.32.1 sh /etc/nikki/kit/install.sh
|
||||
```
|
||||
|
||||
Установщик ставит nikki (если нет), правильное ядро, фиксы и kit со страницей LuCI —
|
||||
ничего не спрашивает. Пакеты nikki берутся из релиза `nikki-<версия>` этого репозитория
|
||||
(зеркало релиза [OpenWrt-nikki](https://github.com/nikkinikki-org/OpenWrt-nikki/releases)),
|
||||
и только если там нет — с GitHub; зависимости — из обычных фидов OpenWrt. Нужна OpenWrt 24.10
|
||||
(opkg); 25.12 с apk пока не поддерживается.
|
||||
|
||||
Если роутер не достаёт ни до одного источника — на компьютере скачать архив под свой роутер
|
||||
(`nikki_<DISTRIB_ARCH>-openwrt-24.10.tar.gz`, арх — `grep DISTRIB_ARCH /etc/openwrt_release`;
|
||||
установщик сам печатает имя и ссылку), положить в `/tmp` роутера и запустить с `NIKKI_TGZ`:
|
||||
|
||||
```sh
|
||||
scp -O nikki_aarch64_cortex-a53-openwrt-24.10.tar.gz root@192.168.32.1:/tmp/
|
||||
ssh root@192.168.32.1 'NIKKI_TGZ=/tmp/nikki_aarch64_cortex-a53-openwrt-24.10.tar.gz sh /etc/nikki/kit/install.sh'
|
||||
```
|
||||
|
||||
Архив релиза nikki — это готовый подписанный фид: установщик распаковывает его в `/tmp`,
|
||||
временно подключает к opkg (подпись проверяется ключом nikki из kit,
|
||||
`router/nikki-key-build.pub`), ставит `mihomo-meta nikki luci-app-nikki luci-i18n-nikki-ru`
|
||||
и убирает фид. Не скачалось или не поставилось — установка останавливается с ошибкой. Дальше всё в браузере: LuCI → **Службы → mihomo-kit**
|
||||
ничего не спрашивает. Дальше всё в браузере: LuCI → **Службы → mihomo-kit**
|
||||
(адрес установщик печатает в конце; если пункта нет — выйти из LuCI и войти снова).
|
||||
Страница разбита на вкладки по темам: «Обзор» (состояние, профиль), «Подписки» (подписки,
|
||||
vless-ссылки BOOT), «Правила» (торренты, пуши, свои домены и IP), «Свои серверы», «Пулы и
|
||||
@ -324,16 +307,6 @@ claude.ai, claude.com, anthropic.com, clau.de, claudeusercontent.com…; `openai
|
||||
- `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,
|
||||
на графе откройте сервис → «Выход сервиса» → «Фиксированный сервер». Выберите источник
|
||||
(«Свои серверы» или конкретную подписку) и имя из подсказок, затем «Сохранить и применить».
|
||||
@ -394,7 +367,6 @@ 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 | пул
|
||||
|
||||
@ -420,24 +392,6 @@ mihomo разбирает подписку (`luci/servers.js` — перенос
|
||||
сверяет с ним): 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]` … или файл — тогда сервер называется по имени файла). Получается сервер
|
||||
@ -534,7 +488,7 @@ cron даёт, только если сервер не принял токен
|
||||
|
||||
| Фикс | Зачем |
|
||||
|---|---|
|
||||
| ядро kit `v1.19.34-ts8` вместо ядра из пакета | в v1.19.29 OpenVPN не проходит рукопожатие; Tailscale через `dialer-proxy` и маскировка OpenVPN — только в ядре kit |
|
||||
| ядро kit `v1.19.33-ts7` вместо ядра из пакета | в v1.19.29 OpenVPN не проходит рукопожатие; Tailscale через `dialer-proxy` и маскировка OpenVPN — только в ядре kit |
|
||||
| `TS_FORCE_NOISE_443=true` в `/etc/init.d/nikki` | провайдер ломает control-соединение Tailscale на порту 80, вход зависает |
|
||||
| убрать `100.64.0.0/10`, `172.16.0.0/12` из `nikki.proxy.reserved_ip` | иначе nikki пускает Tailscale и внутренние сети VPN (172.16/12) мимо mihomo |
|
||||
| `ts.net` в `rebind_domain` dnsmasq | иначе защита от DNS rebinding отбрасывает адреса 100.x тейлнета |
|
||||
@ -601,15 +555,6 @@ RU-адреса, без OpenVPN, Tailscale, торрентов и `PUSH`; сво
|
||||
`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`. Такое имя сниффер пропускает
|
||||
@ -624,7 +569,7 @@ MAC надёжнее IP: адрес по DHCP может смениться (и
|
||||
он открывает UDP-сокет без адреса назначения, и любой прокси mihomo падает на его
|
||||
резолве (`magicsock: Rebind IPv4 failed: failed to bind any ports`,
|
||||
[MetaCubeX/mihomo#3142](https://github.com/MetaCubeX/mihomo/issues/3142)). Поэтому kit
|
||||
ставит своё ядро `v1.19.34-ts8` — официальный v1.19.34 с правкой
|
||||
ставит своё ядро `v1.19.33-ts7` — официальный v1.19.33 с правкой
|
||||
`tools/core/tailscale-packet-listener.patch`: UDP-сокет открывается на роутере, а
|
||||
control-сервер и DERP идут по TCP через `dialer-proxy`. На белых списках прямой UDP не
|
||||
проходит, и Tailscale работает через DERP — медленнее прямого соединения, но работает.
|
||||
@ -722,8 +667,7 @@ router/
|
||||
luci/ страница LuCI «Службы → mihomo-kit»: rpcd.sh (бэкенд), view, ACL, меню,
|
||||
servers.js (ссылки и YAML своих серверов), qrcode.js
|
||||
tools/ push.sh, test.sh, test-servers.js, servers-ref.sh + servers-ref/ (эталоны
|
||||
для servers.js из Go-кода mihomo), core/ (ядро kit),
|
||||
nikki-mirror.sh (зеркало пакетов nikki в релизах)
|
||||
для servers.js из Go-кода mihomo), core/ (ядро kit)
|
||||
tests/fixtures/ профили для test.sh (фиктивные секреты), own.servers
|
||||
tests/expected/ эталонный YAML каждого профиля
|
||||
tests/links/, yaml/ ссылки и YAML с выводом Go-кода mihomo для luci/servers.js
|
||||
@ -748,10 +692,10 @@ tests/links/, yaml/ ссылки и YAML с выводом Go-кода mihomo д
|
||||
Официальный mihomo плюс правки из `tools/core/*.patch` (Tailscale через `dialer-proxy`,
|
||||
маскировка OpenVPN, версия клиента REALITY). Нужны git и Go.
|
||||
|
||||
1. `tools/core/build.sh v1.19.34 ts8` — клонирует mihomo `v1.19.34`, накладывает патчи и
|
||||
собирает `tools/core/dist/mihomo-linux-<arch>-v1.19.34-ts8.gz` для arm64, amd64, armv7,
|
||||
1. `tools/core/build.sh v1.19.33 ts7` — клонирует mihomo `v1.19.33`, накладывает патчи и
|
||||
собирает `tools/core/dist/mihomo-linux-<arch>-v1.19.33-ts7.gz` для arm64, amd64, armv7,
|
||||
mips-softfloat, mipsle-softfloat.
|
||||
2. В репозитории kit создать релиз с тегом `core-v1.19.34-ts8` и приложить все `.gz`, не
|
||||
2. В репозитории kit создать релиз с тегом `core-v1.19.33-ts7` и приложить все `.gz`, не
|
||||
переименовывая: роутер качает `$MIHOMO_BASE/mihomo-linux-<arch>-<версия>.gz`.
|
||||
3. `CORE_KIT` в `router/mihomo-kit.sh` — та же версия. Пушить кит только после релиза:
|
||||
роутеры берут кит из `main` и иначе не найдут ядро.
|
||||
@ -760,27 +704,9 @@ tests/links/, yaml/ ссылки и YAML с выводом Go-кода mihomo д
|
||||
`ovpn.sh refresh` (провайдер OpenVPN с новыми полями). Проверить:
|
||||
`mihomo-kit.sh core-info`, `ovpn.sh status`.
|
||||
|
||||
Новая версия mihomo или новая правка — следующий суффикс (`ts9`) в шагах 1–3. Патчи
|
||||
Новая версия mihomo или новая правка — следующий суффикс (`ts8`) в шагах 1–3. Патчи
|
||||
применяются по алфавиту; если не накладываются, поправить их на новом теге.
|
||||
|
||||
### Зеркало nikki
|
||||
|
||||
Роутер ставит nikki из релиза `nikki-<NIKKI_VERSION>` репозитория kit (GitHub из России
|
||||
часто недоступен). Обновить зеркало на новый релиз nikki (нужны curl, jq; токен Gitea с
|
||||
правом `write:repository`):
|
||||
|
||||
```sh
|
||||
GITEA_TOKEN=... tools/nikki-mirror.sh latest # все архитектуры, OpenWrt 24.10
|
||||
GITEA_TOKEN=... tools/nikki-mirror.sh v1.26.2 aarch64_cortex-a53 mipsel_24kc # только эти
|
||||
```
|
||||
|
||||
Скрипт создаёт релиз `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
|
||||
|
||||
60
TODO.md
60
TODO.md
@ -1,60 +0,0 @@
|
||||
# Технический долг и планы
|
||||
|
||||
Что стоит сделать в kit дальше. Сверху — то, что страхует от поломок, ниже — новые возможности.
|
||||
|
||||
## Надёжность кода
|
||||
|
||||
- **`local` в функциях `router/mihomo-kit.sh`.** Переменные в sh глобальные, и функции затирают
|
||||
их друг другу. Уже было: `pool_vars` перезаписывал `_n` у `own_entries_check`, и проверка
|
||||
петли молча не срабатывала. ash в busybox понимает `local` — перевести на него хотя бы функции,
|
||||
которые вызывают другие (`pool_vars`, `variant_members`, `sub_vars`, `*_vars`).
|
||||
- **Тесты роутерной части.** `tools/test.sh` проверяет только рендер. Миграции
|
||||
(`migrate_openvpn`, `migrate_profiles`), `bypass_uci`, `nikki_defaults`, `opkg_fit`, cron,
|
||||
`ovpn.sh` (пароль с TOTP и без, шифры из `.ovpn`, `routes_set`) проверялись руками. Добавить
|
||||
прогоны с поддельными `uci`, `opkg`, `curl`, `/etc/init.d/*` в `PATH`, которые пишут вызовы в
|
||||
лог, и сравнивать лог с эталоном.
|
||||
- **Проверка JS.** Страницы LuCI правились без запуска: `node --check luci/*.js` в
|
||||
`tools/test.sh` (когда есть node) и тесты `tools/test-*.js` в CI.
|
||||
- **CI на Gitea Actions.** `tools/test.sh` с node и `MIHOMO=…` (`mihomo -t` по всем профилям)
|
||||
на каждый пуш: роутеры берут kit прямо из `main`.
|
||||
- **Разбить `luci/mihomo-kit.js`.** `renderSettings` — одна функция на сотни строк. После вкладок
|
||||
естественно резать её по вкладке на функцию (подписки, правила, свои серверы, OpenVPN, …).
|
||||
|
||||
## Известные слабые места
|
||||
|
||||
- **OpenVPN сразу после старта nikki.** Имя сервера резолвится через DNS mihomo (`respect-rules`,
|
||||
через `MAIN`); пока он не готов, туннель не находит сервер и поднимается только через
|
||||
`DOWN_GRACE` (5 минут). Узнавать IP сервера в `ovpn.sh` при записи провайдера напрямую
|
||||
(77.88.8.8) и писать IP вместо имени.
|
||||
- **`MAIN = DIRECT` переезжает между профилями** (`cache.db` по имени группы): выбрал дома —
|
||||
на whitelist нет интернета. Хотя бы предупреждение на «Обзоре», а лучше сброс `MAIN` при
|
||||
смене профиля или отдельный профиль `behind` (за другим роутером: только OpenVPN и Tailscale,
|
||||
остальное `DIRECT`).
|
||||
- **`OVPN-EXIT` только из RU-нод** — рассчитано на VPN-сервер в России. Дать выбор страны или
|
||||
любой ноды.
|
||||
- **OpenVPN:** профили только с сертификатом (без `auth-user-pass`) сейчас требуют логин;
|
||||
внутренние домены за VPN не резолвятся через DNS самого VPN.
|
||||
- **Ноды `[MY]` с входом ищутся по точному имени:** переименовали в подписке — вход молча
|
||||
перестаёт действовать. Показывать в LuCI заданные входы, для которых ноды больше нет.
|
||||
- **`opkg_fit`** не проверен на живом маленьком роутере: печатает ли `opkg --noaction` строки
|
||||
`Installing …` (иначе откатывается к обычному `opkg install`).
|
||||
|
||||
## Порт на OpenWrt 25.12
|
||||
|
||||
opkg заменён на apk: `cmd_install`, `opkg_fit`, `pkg-install` (`.ipk` → `.apk`, нет
|
||||
`--force-space`, свой подсчёт места), `lite_intercept`. Определять менеджер пакетов и держать
|
||||
обе ветки. Генерация конфигов, LuCI, `use`, `fix`, ядро от этого не зависят.
|
||||
|
||||
## Новые возможности
|
||||
|
||||
- **Автоопределение белых списков:** роутер раз в N минут проверяет, открываются ли зарубежные
|
||||
адреса напрямую, и сам переключает `main` ↔ `whitelist` (с гистерезисом, чтобы не прыгать).
|
||||
- **Маршрут по устройству:** развитие `BYPASS_CLIENTS` — не только «мимо mihomo», но и «это
|
||||
устройство всегда через FOREIGN / MY / пул» (`SRC-IP-CIDR` в начале правил; MAC → IP по
|
||||
DHCP-арендам).
|
||||
- **Выбор из DHCP-клиентов** в LuCI для `BYPASS_CLIENTS` и маршрутов по устройству, а не ввод MAC
|
||||
руками.
|
||||
- **Уведомления в Telegram:** OpenVPN не поднимается, обновление kit упало, подписка не
|
||||
скачивается, ядро откатилось.
|
||||
- **Откат обновления kit:** сохранять предыдущую версию перед `update`, кнопка «вернуть
|
||||
предыдущую».
|
||||
@ -762,9 +762,9 @@
|
||||
// each returning a promise: select(group, name), unfix(group), delay(group, url) -> {name: ms},
|
||||
// refresh() - poll now; saveServices(services, pools) - the kit's services and pools (SERVICES,
|
||||
// POOLS), then the page shows the rebuilt profile (only on the router)
|
||||
// show(cfg, meta): meta.services [{name, geosite, domains, ips, hostlist, via}], meta.pools [{name, type,
|
||||
// show(cfg, meta): meta.services [{name, geosite, domains, ips, via}], meta.pools [{name, type,
|
||||
// servers, subs, filter, exclude}] - which groups are services / pools; meta.servers, meta.subs -
|
||||
// own server names and providers a pool can take; meta.hostlists [{path, lines}] - zapret's lists
|
||||
// own server names and providers a pool can take
|
||||
function view(container, act) {
|
||||
if (!document.getElementById('mkg-style'))
|
||||
document.head.appendChild(el('style', { id: 'mkg-style', text: CSS }));
|
||||
@ -1162,48 +1162,17 @@
|
||||
});
|
||||
};
|
||||
};
|
||||
// zapret hostlists (meta.hostlists [{path, lines}]) as buttons under the service's
|
||||
// hostlist field: a click adds the file to it or takes it out
|
||||
var hostlistPicker = function(inp) {
|
||||
var files = meta.hostlists || [];
|
||||
if (!files.length)
|
||||
return null;
|
||||
var words = function() { return inp.value.trim().split(/\s+/).filter(Boolean); };
|
||||
var buttons = files.map(function(fl) {
|
||||
var b = el('button', { 'class': 'btn cbi-button', title: fl.path, onclick: function(ev) {
|
||||
ev.preventDefault();
|
||||
var w = words(), i = w.indexOf(fl.path);
|
||||
if (i < 0) w.push(fl.path); else w.splice(i, 1);
|
||||
inp.value = w.join(' ');
|
||||
mark();
|
||||
} });
|
||||
b.mkFile = fl;
|
||||
return b;
|
||||
});
|
||||
var mark = function() {
|
||||
var w = words();
|
||||
buttons.forEach(function(b) {
|
||||
var on = w.indexOf(b.mkFile.path) >= 0;
|
||||
b.textContent = (on ? '✓ ' : '+ ') + b.mkFile.path.replace(/^.*\//, '') + ' (' + b.mkFile.lines + ')';
|
||||
b.className = 'btn cbi-button' + (on ? ' cbi-button-positive' : '');
|
||||
});
|
||||
};
|
||||
inp.addEventListener('input', mark);
|
||||
mark();
|
||||
return el('div', { 'class': 'acts' }, [ 'из zapret:' ].concat(buttons));
|
||||
};
|
||||
var editor = function(svc) {
|
||||
var key = svc ? 'svc:' + svc.name : 'new';
|
||||
if (editors[key])
|
||||
return editors[key];
|
||||
svc = svc || { name: '', geosite: '', domains: '', ips: '', hostlist: '', via: 'MY', chain: '', server: '', provider: '' };
|
||||
svc = svc || { name: '', geosite: '', domains: '', ips: '', via: 'MY', chain: '', server: '', provider: '' };
|
||||
var input = function(v, ph) { return el('input', { type: 'text', value: v || '', placeholder: ph }); };
|
||||
var f = {
|
||||
name: input(svc.name, 'claude'),
|
||||
geosite: input(svc.geosite, 'anthropic'),
|
||||
domains: input(svc.domains, 'example.com'),
|
||||
ips: input(svc.ips, '1.2.3.0/24'),
|
||||
hostlist: input(svc.hostlist, '/opt/zapret2/ipset/zapret_hosts_youtube.txt'),
|
||||
mode: el('select', {}, [ [ '', 'Группа / автовыбор' ], [ 'fixed', 'Фиксированный сервер' ] ]
|
||||
.map(function(o) { return el('option', { value: o[0] }, [ o[1] ]); })),
|
||||
provider: el('select', {}, [ [ '', 'Свои серверы' ] ].concat((meta.subs || []).map(function(id) {
|
||||
@ -1250,7 +1219,7 @@
|
||||
var buttons = [], save = saver(say, buttons);
|
||||
var saveBtn = el('button', { 'class': 'btn cbi-button cbi-button-apply', onclick: function() {
|
||||
var v = { name: f.name.value.trim().toLowerCase(), geosite: f.geosite.value.trim(), domains: f.domains.value.trim(),
|
||||
ips: f.ips.value.trim(), hostlist: f.hostlist.value.trim(), via: f.via.value, chain: f.chain.value,
|
||||
ips: f.ips.value.trim(), via: f.via.value, chain: f.chain.value,
|
||||
server: f.mode.value ? f.server.value.trim() : '', provider: f.mode.value ? f.provider.value : '' };
|
||||
var others = services.filter(function(x) { return !svc.name || x.name != svc.name; });
|
||||
var bad = nameError(v.name, svcOf);
|
||||
@ -1258,8 +1227,8 @@
|
||||
return say(bad, true);
|
||||
if (others.some(function(x) { return x.name == v.name; }))
|
||||
return say('сервис ' + v.name + ' уже есть', true);
|
||||
if (!v.geosite && !v.domains && !v.ips && !v.hostlist)
|
||||
return say('нужен geosite, домены, IP или список доменов', true);
|
||||
if (!v.geosite && !v.domains && !v.ips)
|
||||
return say('нужен geosite, домены или IP', true);
|
||||
if (f.mode.value && !v.server)
|
||||
return say('выбери или введи имя фиксированного сервера', true);
|
||||
if (v.chain && !v.server && v.via != 'MY' && !poolOf[v.via])
|
||||
@ -1284,8 +1253,6 @@
|
||||
el('label', {}, [ 'geosite (MetaCubeX/meta-rules-dat, через пробел)', f.geosite ]),
|
||||
el('label', {}, [ 'домены (с поддоменами)', f.domains ]),
|
||||
el('label', {}, [ 'IP / подсети', f.ips ]),
|
||||
el('label', {}, [ 'списки доменов: файлы, по домену в строке (хостлисты zapret), через пробел', f.hostlist ]),
|
||||
hostlistPicker(f.hostlist),
|
||||
el('label', {}, [ 'выход сервиса', f.mode ]),
|
||||
fixedBox,
|
||||
el('label', {}, [ 'через что (или потяни от группы к MY / FOREIGN / RU / MAIN / DIRECT / пулу)', f.via ]),
|
||||
|
||||
@ -97,7 +97,7 @@ return view.extend({
|
||||
}
|
||||
try {
|
||||
this.graph.show(window.mkServers.yamlLoad(g.yaml),
|
||||
{ services: g.services || [], pools: g.pools || [], servers: g.servers || [], subs: g.subs || [], hostlists: g.hostlists || [] });
|
||||
{ services: g.services || [], pools: g.pools || [], servers: g.servers || [], subs: g.subs || [] });
|
||||
} catch (e) {
|
||||
dom.content(this.state, E('p', { 'class': 'alert-message warning' }, 'Не разобрал профиль: ' + e.message));
|
||||
return;
|
||||
|
||||
@ -19,7 +19,6 @@ var callTsCheck = rpc.declare({ object: 'mihomo-kit', method: 'ts_check', nobatc
|
||||
var callUpdateCheck = rpc.declare({ object: 'mihomo-kit', method: 'update_check', nobatch: true, expect: { '': {} } });
|
||||
var callExport = rpc.declare({ object: 'mihomo-kit', method: 'export', expect: { '': {} } });
|
||||
var callImport = rpc.declare({ object: 'mihomo-kit', method: 'import', params: [ 'data', 'keep_local' ], expect: { '': {} } });
|
||||
var callApi = rpc.declare({ object: 'mihomo-kit', method: 'api', params: [ 'path' ], nobatch: true, expect: { '': {} } });
|
||||
var callConfigGet = rpc.declare({ object: 'mihomo-kit', method: 'config_get', expect: { '': {} } });
|
||||
var callConfigSet = rpc.declare({ object: 'mihomo-kit', method: 'config_set', params: [ 'data' ], expect: { '': {} } });
|
||||
|
||||
@ -113,36 +112,6 @@ function check(value) {
|
||||
return c;
|
||||
}
|
||||
|
||||
// zapret hostlists (cfg.hostlists [{path, lines}]) as buttons under the service's hostlist
|
||||
// field: a click adds the file to it or takes it out; nothing when zapret has no lists
|
||||
function hostlistPicker(input, files) {
|
||||
if (!files || !files.length)
|
||||
return [];
|
||||
var words = function() { return input.value.trim().split(/\s+/).filter(Boolean); };
|
||||
var buttons = files.map(function(f) {
|
||||
var b = E('button', { 'class': 'btn cbi-button', 'title': f.path, 'style': 'margin:.2em .3em 0 0', 'click': function(ev) {
|
||||
ev.preventDefault();
|
||||
var w = words(), i = w.indexOf(f.path);
|
||||
if (i < 0) w.push(f.path); else w.splice(i, 1);
|
||||
input.value = w.join(' ');
|
||||
mark();
|
||||
} });
|
||||
b.mkFile = f;
|
||||
return b;
|
||||
});
|
||||
var mark = function() {
|
||||
var w = words();
|
||||
buttons.forEach(function(b) {
|
||||
var on = w.indexOf(b.mkFile.path) >= 0;
|
||||
b.textContent = (on ? '✓ ' : '+ ') + b.mkFile.path.replace(/^.*\//, '') + ' (' + b.mkFile.lines + ')';
|
||||
b.className = 'btn cbi-button' + (on ? ' cbi-button-positive' : '');
|
||||
});
|
||||
};
|
||||
input.addEventListener('input', mark);
|
||||
mark();
|
||||
return [ E('div', {}, [ E('small', {}, 'из zapret: ') ].concat(buttons)) ];
|
||||
}
|
||||
|
||||
function field(title, el, desc) {
|
||||
return E('div', { 'class': 'cbi-value' }, [
|
||||
E('label', { 'class': 'cbi-value-title' }, title),
|
||||
@ -606,7 +575,6 @@ return view.extend({
|
||||
foreign_domains: text(cfg.foreign_domains, 'example.com *.example.org'),
|
||||
my_domains: text(cfg.my_domains, 'example.com *.example.org'),
|
||||
local_hosts: text(cfg.local_hosts, 'example.com=192.168.1.10'),
|
||||
bypass_clients: text(cfg.bypass_clients, '192.168.1.50 aa:bb:cc:dd:ee:ff'),
|
||||
openvpn: check(cfg.openvpn),
|
||||
csqtt: check(cfg.csqtt),
|
||||
ovpn: E('input', { 'type': 'file', 'accept': '.ovpn,.conf' }),
|
||||
@ -708,8 +676,7 @@ return view.extend({
|
||||
provider: text(v.provider || '', 'пусто — свои серверы; иначе ID провайдера'),
|
||||
geosite: text(v.geosite || '', 'anthropic'),
|
||||
domains: text(v.domains || '', 'example.com'),
|
||||
ips: text(v.ips || '', '1.2.3.0/24'),
|
||||
hostlist: text(v.hostlist || '', '/opt/zapret2/ipset/zapret_hosts_youtube.txt')
|
||||
ips: text(v.ips || '', '1.2.3.0/24')
|
||||
};
|
||||
e.name.style.width = '9em';
|
||||
viaOptions(e.via);
|
||||
@ -731,9 +698,6 @@ return view.extend({
|
||||
field('geosite', e.geosite, 'списки MetaCubeX/meta-rules-dat через пробел: anthropic, openai, youtube…'),
|
||||
field('Домены', e.domains, 'ещё домены, с поддоменами'),
|
||||
field('IP', e.ips, 'ещё адреса, без маски = /32'),
|
||||
field('Списки доменов', [ e.hostlist ].concat(hostlistPicker(e.hostlist, cfg.hostlists)),
|
||||
'файлы со списком доменов, по одному в строке (хостлисты zapret), через пробел; читаются при каждой ' +
|
||||
'сборке профиля — изменился список в zapret: «Применить»'),
|
||||
field('Фиксированный сервер', e.server, 'точное имя; выбор сохраняется во всех профилях. Удобнее выбирать на графе'),
|
||||
field('Источник сервера', e.provider, 'для подписки — ID провайдера, например sam_hub-my; для своего сервера оставить пустым'),
|
||||
field('Вход', e.chain, 'для фиксированного сервера, MY или пула: через что подключаться к его серверам (например, ' +
|
||||
@ -754,39 +718,17 @@ return view.extend({
|
||||
servers.forEach(function(e) { t[e.name.value.trim()] = true; });
|
||||
return t;
|
||||
};
|
||||
// "Вход" of an own server (its own dialer-proxy): what it dials through in every
|
||||
// profile instead of what the kit puts in front (MY-EXIT, UPLINK, directly)
|
||||
var entryOptions = function(sel) {
|
||||
var cur = sel.value || sel.getAttribute('data-entry') || '';
|
||||
var names = pools.map(function(p) { return p.name.value.trim().toUpperCase(); }).filter(Boolean);
|
||||
var opts = [ [ '', 'вход: как обычно' ], [ 'FOREIGN', 'вход: через FOREIGN' ], [ 'RU', 'вход: через RU' ],
|
||||
[ 'DIRECT', 'вход: напрямую' ] ].concat(names.map(function(n) { return [ n, 'вход: через пул ' + n ]; }));
|
||||
if (cur && !opts.some(function(o) { return o[0] == cur; }))
|
||||
opts.push([ cur, 'вход: ' + cur + ' (такого нет)' ]);
|
||||
dom.content(sel, opts.map(function(o) { return E('option', { 'value': o[0] }, o[1]); }));
|
||||
sel.value = cur;
|
||||
};
|
||||
var addServer = function(p, open) {
|
||||
var e = { proxy: {}, error: null };
|
||||
Object.keys(p).forEach(function(k) {
|
||||
if (k != 'name' && k != 'dialer-proxy')
|
||||
e.proxy[k] = p[k];
|
||||
});
|
||||
e.entry = E('select', { 'class': 'cbi-input-select', 'data-entry': p['dialer-proxy'] || '',
|
||||
'title': 'через что подключаться к этому серверу, во всех профилях и на телефоне: например, через FOREIGN, ' +
|
||||
'если сам сервер напрямую недоступен. «Как обычно» — как остальные свои серверы' });
|
||||
entryOptions(e.entry);
|
||||
e.entry.addEventListener('focus', function() { entryOptions(e.entry); });
|
||||
e.entry.addEventListener('mousedown', function() { entryOptions(e.entry); });
|
||||
// "как обычно" is an empty value: keep the choice for the next rebuild of the list
|
||||
e.entry.addEventListener('change', function() { e.entry.setAttribute('data-entry', e.entry.value); });
|
||||
e.name = text(S.freeName(p.name, taken()), 'имя в дашборде');
|
||||
e.name.style.width = '16em';
|
||||
e.get = function() {
|
||||
var o = { name: e.name.value.trim() };
|
||||
Object.keys(e.proxy).forEach(function(k) { o[k] = e.proxy[k]; });
|
||||
if (e.entry.value)
|
||||
o['dialer-proxy'] = e.entry.value;
|
||||
return o;
|
||||
};
|
||||
var info = E('code', {}, S.summary(e.proxy));
|
||||
@ -802,12 +744,6 @@ return view.extend({
|
||||
if (!v.type || v.server === undefined || v.server === null || v.server === '')
|
||||
throw new Error('нужны type и server');
|
||||
delete v.name;
|
||||
// dialer-proxy typed in the YAML: the same as the entry select
|
||||
if (v['dialer-proxy']) {
|
||||
e.entry.setAttribute('data-entry', v['dialer-proxy']);
|
||||
e.entry.value = '';
|
||||
entryOptions(e.entry);
|
||||
}
|
||||
delete v['dialer-proxy'];
|
||||
e.proxy = v;
|
||||
e.error = null;
|
||||
@ -821,7 +757,7 @@ return view.extend({
|
||||
});
|
||||
var el = E('div', { 'style': 'border:1px solid #8884;border-radius:4px;padding:.5em;margin-bottom:.5em' }, [
|
||||
E('div', { 'style': 'display:flex;gap:.5em;align-items:center;flex-wrap:wrap' }, [
|
||||
e.name, info, e.entry,
|
||||
e.name, info,
|
||||
E('button', { 'class': 'btn cbi-button', 'click': function() {
|
||||
e.yaml.style.display = e.yaml.style.display == 'none' ? '' : 'none';
|
||||
} }, 'Настройки (YAML)'),
|
||||
@ -850,49 +786,6 @@ return view.extend({
|
||||
srvList.appendChild(el);
|
||||
};
|
||||
S.fromLines(cfg.servers_text).forEach(function(p) { addServer(p); });
|
||||
|
||||
// [MY] nodes of the subscriptions (providers <id>-my): the same "Вход" per node
|
||||
// (MY_NODE_ENTRIES). The names come from the running mihomo; saved entries show
|
||||
// even when it does not run.
|
||||
var myNodes = [], myNodeBox = E('div', E('em', 'загружаю ноды [MY] из подписок…'));
|
||||
var addMyNode = function(provider, name, entry) {
|
||||
if (myNodes.some(function(n) { return n.provider == provider && n.name == name; }))
|
||||
return;
|
||||
var n = { provider: provider, name: name,
|
||||
entry: E('select', { 'class': 'cbi-input-select', 'data-entry': entry || '' }) };
|
||||
entryOptions(n.entry);
|
||||
n.entry.addEventListener('focus', function() { entryOptions(n.entry); });
|
||||
n.entry.addEventListener('mousedown', function() { entryOptions(n.entry); });
|
||||
n.entry.addEventListener('change', function() { n.entry.setAttribute('data-entry', n.entry.value); });
|
||||
myNodes.push(n);
|
||||
};
|
||||
String(cfg.my_node_entries || '').split('\n').forEach(function(l) {
|
||||
var m = /^([^|]*)\|([^|]*)\|(.+)$/.exec(l);
|
||||
if (m)
|
||||
addMyNode(m[2], m[3], m[1]);
|
||||
});
|
||||
var drawMyNodes = function(note) {
|
||||
dom.content(myNodeBox, [ note ? E('p', { 'class': 'cbi-value-description' }, note) : '' ].concat(myNodes.length
|
||||
? myNodes.map(function(n) {
|
||||
return E('div', { 'style': 'display:flex;gap:.5em;align-items:center;flex-wrap:wrap;margin-bottom:.3em' },
|
||||
[ E('code', n.name), E('span', { 'class': 'cbi-value-description' }, n.provider), n.entry ]);
|
||||
})
|
||||
: [ E('em', 'нод [MY] в подписках нет') ]));
|
||||
};
|
||||
callApi('/providers/proxies').then(function(r) {
|
||||
if (r.error)
|
||||
throw new Error(r.error);
|
||||
Object.keys(r.providers || {}).sort().forEach(function(pn) {
|
||||
// <id>-my and <id>-my-via-<entry> (nodes with an entry already); not the chains' <id>-my@<entry>
|
||||
var m = /^(.+-my)(-via-.+)?$/.exec(pn);
|
||||
if (!m || pn.indexOf('@') >= 0)
|
||||
return;
|
||||
(r.providers[pn].proxies || []).forEach(function(p) { addMyNode(m[1], p.name, ''); });
|
||||
});
|
||||
drawMyNodes('');
|
||||
}).catch(function() {
|
||||
drawMyNodes('nikki сейчас не работает: видны только ноды, у которых вход уже задан. Запусти профиль, чтобы увидеть все.');
|
||||
});
|
||||
// the old settings: hysteria2 by fields (HY2_*) and links (MY_LINKS) become cards,
|
||||
// the save writes them as own servers and drops the old keys
|
||||
var moved = 0;
|
||||
@ -1094,7 +987,7 @@ return view.extend({
|
||||
var svcNames = {};
|
||||
var svcData = services.map(function(e) {
|
||||
return { name: e.name.value.trim().toLowerCase(), via: e.via.value, chain: e.chain.value, geosite: e.geosite.value.trim(),
|
||||
domains: e.domains.value.trim(), ips: e.ips.value.trim(), hostlist: e.hostlist.value.trim(), server: e.server.value.trim(), provider: e.server.value.trim() ? e.provider.value.trim() : '' };
|
||||
domains: e.domains.value.trim(), ips: e.ips.value.trim(), server: e.server.value.trim(), provider: e.server.value.trim() ? e.provider.value.trim() : '' };
|
||||
});
|
||||
svcData.forEach(function(v) {
|
||||
if (!/^[a-z0-9][a-z0-9_-]*$/.test(v.name))
|
||||
@ -1104,8 +997,8 @@ return view.extend({
|
||||
else if (taken.test(v.name) || poolNames[v.name])
|
||||
errors.push('Сервис «' + v.name + '»: такая группа уже есть, возьми другое имя');
|
||||
svcNames[v.name] = true;
|
||||
if (!v.geosite && !v.domains && !v.ips && !v.hostlist)
|
||||
errors.push('Сервис «' + v.name + '»: нужен geosite, домены, IP или список доменов');
|
||||
if (!v.geosite && !v.domains && !v.ips)
|
||||
errors.push('Сервис «' + v.name + '»: нужен geosite, домены или IP');
|
||||
var builtin = /^(MY|FOREIGN|RU|DIRECT|MAIN|MY-EXIT)$/;
|
||||
if (!v.server && !builtin.test(v.via) && !poolNames[v.via.toLowerCase()])
|
||||
errors.push('Сервис «' + v.name + '»: пула ' + v.via + ' больше нет');
|
||||
@ -1116,10 +1009,6 @@ return view.extend({
|
||||
else if (v.chain && !v.server && v.chain == v.via)
|
||||
errors.push('Сервис «' + v.name + '»: вход и выход — одно и то же');
|
||||
});
|
||||
f.bypass_clients.value.split(/\s+/).filter(Boolean).forEach(function(c) {
|
||||
if (!/^\d{1,3}(\.\d{1,3}){3}(\/\d{1,2})?$/.test(c) && !/^[0-9a-f]{2}([:-][0-9a-f]{2}){5}$/i.test(c))
|
||||
errors.push('Клиенты мимо mihomo: ' + c + ' — не IPv4-адрес, подсеть или MAC');
|
||||
});
|
||||
if (f.lite_gomemlimit.value.trim() && !/^[1-9][0-9]*(B|KiB|MiB|GiB)?$/.test(f.lite_gomemlimit.value.trim()))
|
||||
errors.push('Лимит памяти: число с единицей, например 64MiB');
|
||||
var names = {}, srvLines = [];
|
||||
@ -1134,25 +1023,8 @@ return view.extend({
|
||||
errors.push('Свой сервер ' + n + ': ' + e.error);
|
||||
else if (e.proxy.server === undefined || e.proxy.server === null || e.proxy.server === '')
|
||||
errors.push('Свой сервер ' + n + ': пустой server (открой «Настройки (YAML)»)');
|
||||
// the entry: a pool that exists and does not hold the server itself (a loop)
|
||||
var en = e.entry.value, ep = poolData.filter(function(v) { return v.name.toUpperCase() == en; })[0];
|
||||
if (en && !/^(FOREIGN|RU|DIRECT)$/.test(en) && !ep)
|
||||
errors.push('Свой сервер ' + n + ': вход через пул ' + en + ', а такого пула нет');
|
||||
else if (ep && ep.servers.split(';').map(function(x) { return x.trim(); }).indexOf(n) >= 0)
|
||||
errors.push('Свой сервер ' + n + ': вход через пул ' + en + ', в который он сам входит — так нельзя');
|
||||
srvLines.push(S.toLine(e.get()));
|
||||
});
|
||||
var nodeLines = [];
|
||||
myNodes.forEach(function(n) {
|
||||
var en = n.entry.value, ep = poolData.filter(function(v) { return v.name.toUpperCase() == en; })[0];
|
||||
if (!en)
|
||||
return;
|
||||
if (!/^(FOREIGN|RU|DIRECT)$/.test(en) && !ep)
|
||||
errors.push('Нода ' + n.name + ': вход через пул ' + en + ', а такого пула нет');
|
||||
else if (ep && ep.subs.split(/\s+/).indexOf(n.provider) >= 0)
|
||||
errors.push('Нода ' + n.name + ': вход через пул ' + en + ', который сам берёт ноды ' + n.provider + ' — так нельзя');
|
||||
nodeLines.push(en + '|' + n.provider + '|' + n.name);
|
||||
});
|
||||
if (errors.length) {
|
||||
ui.addNotification(null, errors.map(function(e) { return E('p', e); }), 'danger');
|
||||
return;
|
||||
@ -1172,7 +1044,6 @@ return view.extend({
|
||||
foreign_domains: f.foreign_domains.value.trim(),
|
||||
my_domains: f.my_domains.value.trim(),
|
||||
local_hosts: f.local_hosts.value.trim(),
|
||||
bypass_clients: f.bypass_clients.value.trim(),
|
||||
my_links: '',
|
||||
openvpn: f.openvpn.checked,
|
||||
csqtt: f.csqtt.checked,
|
||||
@ -1194,8 +1065,7 @@ return view.extend({
|
||||
hy2: [],
|
||||
services: svcData,
|
||||
pools: poolData,
|
||||
servers_text: srvLines.join('\n'),
|
||||
my_node_entries: nodeLines.join('\n')
|
||||
servers_text: srvLines.join('\n')
|
||||
});
|
||||
}, this)).then(L.bind(function(r) {
|
||||
if (r.error) {
|
||||
@ -1287,11 +1157,7 @@ return view.extend({
|
||||
field('Доп. IP через MY', f.my_ips, 'свои серверы (вкладка «Свои серверы») и [MY] из подписок'),
|
||||
field('Локальные адреса', f.local_hosts, 'домен=IP в локальной сети (с поддоменами): роутер и клиенты ' +
|
||||
'ходят к серверу напрямую по LAN, а не через белый IP и обратно. Только для этого роутера (не телефон, ' +
|
||||
'при импорте не переносится)'),
|
||||
field('Клиенты мимо mihomo', f.bypass_clients, 'IP-адреса (или подсети) и MAC-адреса устройств в локальной сети ' +
|
||||
'через пробел: их трафик и DNS идут напрямую, без обхода. Например, второй роутер со своим kit за этим — иначе ' +
|
||||
'его трафик дважды идёт через прокси. MAC надёжнее: IP может смениться (или закрепи IP в Сеть → DHCP и DNS). ' +
|
||||
'Только для этого роутера')
|
||||
'при импорте не переносится)')
|
||||
]);
|
||||
put('servers', [
|
||||
E('p', { 'class': 'cbi-value-description' }, 'Собираются в группу MY (автовыбор самого быстрого, в дашборде можно закрепить один). MY — пункт в MAIN ' +
|
||||
@ -1310,12 +1176,7 @@ return view.extend({
|
||||
E('button', { 'class': 'btn cbi-button', 'click': function() {
|
||||
addServer({ name: 'new', type: 'hysteria2', server: '', port: 443, password: '' }, true);
|
||||
} }, 'Добавить вручную')
|
||||
]),
|
||||
E('h4', 'Из подписок ([MY])'),
|
||||
E('p', { 'class': 'cbi-value-description' }, 'Серверы, которые ты держишь в своей подписке с [MY] в имени: их настройки ' +
|
||||
'приходят из подписки, но вход можно задать здесь — для каждого отдельно, как у своих серверов выше. ' +
|
||||
'Нода ищется по точному имени: если в подписке её переименуют, вход перестанет действовать.'),
|
||||
myNodeBox
|
||||
])
|
||||
]);
|
||||
// one button for every tab: the settings are saved and applied together
|
||||
dom.content(this.saveBox, E('div', { 'class': 'cbi-page-actions' }, [
|
||||
|
||||
55
luci/rpcd.sh
55
luci/rpcd.sh
@ -16,10 +16,9 @@
|
||||
# config_get settings for the form (secrets: only whether they are set)
|
||||
# config_set save the form (via "mihomo-kit.sh configure") as the job
|
||||
# graph {profile}: the built profile's YAML for the graph page (default: the running one)
|
||||
# and the services and pools of the settings (+ servers, subs: what a pool can take;
|
||||
# hostlists: the zapret lists a service can take)
|
||||
# and the services and pools of the settings (+ servers, subs: what a pool 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,
|
||||
# services_set {services: [{name, geosite, domains, ips, via, chain}], 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),
|
||||
@ -293,19 +292,8 @@ m_config_get() {
|
||||
json_add_string foreign_domains "${FOREIGN_DOMAINS:-}"
|
||||
json_add_string my_domains "${MY_DOMAINS:-}"
|
||||
json_add_string local_hosts "${LOCAL_HOSTS:-}"
|
||||
json_add_string bypass_clients "${BYPASS_CLIENTS:-}"
|
||||
# [MY] nodes of the subscriptions with an entry of their own: "<ENTRY>|<id>-my|<name>" lines
|
||||
# (MY_NODE_1, MY_NODE_2, ... in common.env)
|
||||
json_add_string my_node_entries "$(
|
||||
_mk=1
|
||||
while eval "[ -n \"\${MY_NODE_$_mk+x}\" ]"; do
|
||||
eval "printf '%s\n' \"\$MY_NODE_$_mk\""
|
||||
_mk=$((_mk + 1))
|
||||
done
|
||||
)"
|
||||
blocks_json services "${SERVICES:-}" SVC geosite domains ips via chain server provider hostlist
|
||||
blocks_json services "${SERVICES:-}" SVC geosite domains ips via chain server provider
|
||||
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)"
|
||||
@ -351,7 +339,7 @@ m_config_get() {
|
||||
|
||||
# {"data": {boot_links (one per line), subs: [{url, via, hwid}], hwid_*, torrent, push, ru_ips,
|
||||
# foreign_ips, my_ips, ru_domains, foreign_domains, my_domains, local_hosts, my_links (one per line),
|
||||
# services: [{name, geosite, domains, ips, via, chain, server, provider, hostlist}], pools: [{name, type, servers, subs, filter, exclude, uplink}],
|
||||
# services: [{name, geosite, domains, ips, via, chain}], pools: [{name, type, servers, subs, filter, exclude, uplink}],
|
||||
# servers_text (own servers, one JSON proxy per line: written to /etc/nikki/my-servers),
|
||||
# openvpn, csqtt, ovpn (file text, optional), vpn_username, vpn_password, totp_secret,
|
||||
# totp_clear (1: no codes any more), pass_format, ovpn_routes (only from a page that has it),
|
||||
@ -431,17 +419,7 @@ m_config_set() {
|
||||
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
|
||||
# an old cached page does not send it: the saved one stays
|
||||
json_get_type _rt ovpn_routes
|
||||
if [ -n "$_rt" ]; then
|
||||
json_get_var ovpn_routes ovpn_routes ""
|
||||
@ -476,7 +454,7 @@ m_config_set() {
|
||||
json_select ..
|
||||
fi
|
||||
echo "HY2=$(q "$hy2")"
|
||||
blocks_env services SERVICES SVC geosite domains ips via chain server provider hostlist
|
||||
blocks_env services SERVICES SVC geosite domains ips via chain server provider
|
||||
blocks_env pools POOLS POOL type servers subs filter exclude uplink
|
||||
} > "$env"
|
||||
umask 022
|
||||
@ -530,22 +508,6 @@ blocks_env() {
|
||||
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
|
||||
@ -583,9 +545,8 @@ m_graph() {
|
||||
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 services "${SERVICES:-}" SVC geosite domains ips via chain server provider
|
||||
blocks_json pools "${POOLS:-}" POOL type servers subs filter exclude uplink
|
||||
hostlist_files
|
||||
pool_sources
|
||||
json_dump
|
||||
}
|
||||
@ -596,7 +557,7 @@ m_services_set() {
|
||||
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 services SERVICES SVC geosite domains ips via chain server provider
|
||||
blocks_env pools POOLS POOL type servers subs filter exclude uplink
|
||||
} > "$env"
|
||||
umask 022
|
||||
|
||||
@ -297,10 +297,6 @@
|
||||
case 'ws':
|
||||
case 'httpupgrade':
|
||||
var ws = { path: query.get('path'), headers: { 'User-Agent': USER_AGENT, Host: query.get('host') } };
|
||||
if (network == 'httpupgrade') {
|
||||
proxy.network = 'ws';
|
||||
ws['v2ray-http-upgrade'] = true;
|
||||
}
|
||||
if (query.get('ed')) {
|
||||
if (!/^[+-]?[0-9]+$/.test(query.get('ed')))
|
||||
return 'bad WebSocket max early data size';
|
||||
@ -599,13 +595,8 @@
|
||||
var net = q.get('type').toLowerCase();
|
||||
if (net)
|
||||
p.network = net;
|
||||
if (net == 'ws' || net == 'httpupgrade') {
|
||||
if (net == 'ws')
|
||||
p['ws-opts'] = { path: q.get('path'), headers: { 'User-Agent': USER_AGENT } };
|
||||
if (net == 'httpupgrade') {
|
||||
p.network = 'ws';
|
||||
p['ws-opts']['v2ray-http-upgrade'] = true;
|
||||
}
|
||||
}
|
||||
else if (net == 'grpc')
|
||||
p['grpc-opts'] = { 'grpc-service-name': q.get('serviceName') };
|
||||
p['client-fingerprint'] = q.get('fp') || 'chrome';
|
||||
@ -687,10 +678,6 @@
|
||||
case 'ws':
|
||||
case 'httpupgrade':
|
||||
var wo = { path: '/' }, hd = {};
|
||||
if (network == 'httpupgrade') {
|
||||
p.network = 'ws';
|
||||
wo['v2ray-http-upgrade'] = true;
|
||||
}
|
||||
if (host)
|
||||
hd.Host = host;
|
||||
if (path) {
|
||||
@ -1654,14 +1641,13 @@
|
||||
return { servers: servers, errors: errors };
|
||||
}
|
||||
|
||||
// one stored line: JSON with "name" first (mihomo-kit.sh reads it with sed), a
|
||||
// dialer-proxy only as the server's own entry (LuCI "Вход"; otherwise the kit sets
|
||||
// it per profile), "$" as \u0024 (no ${...} for the template engine; JSON and YAML
|
||||
// both read \u escapes)
|
||||
// one stored line: JSON with "name" first (mihomo-kit.sh reads it with sed), no
|
||||
// dialer-proxy (the kit sets it per profile), "$" as \u0024 (no ${...} for the
|
||||
// template engine; JSON and YAML both read \u escapes)
|
||||
function toLine(p) {
|
||||
var o = { name: String(p.name) };
|
||||
Object.keys(p).forEach(function (k) {
|
||||
if (k != 'name' && (k != 'dialer-proxy' || p[k]))
|
||||
if (k != 'name' && k != 'dialer-proxy')
|
||||
o[k] = p[k];
|
||||
});
|
||||
return JSON.stringify(o).replace(/\$/g, '\\u0024');
|
||||
|
||||
@ -48,11 +48,8 @@ PROFILES_OUT="$NIKKI_DIR/profiles"
|
||||
# kit own build CORE_KIT (official + tools/core/*.patch: Tailscale through dialer-proxy,
|
||||
# OpenVPN presenting as OpenVPN Connect)
|
||||
# An explicit MIHOMO_VERSION in kit.env wins (e.g. MIHOMO_VERSION=v1.19.29).
|
||||
CORE_OFFICIAL=v1.19.34
|
||||
CORE_KIT=v1.19.34-ts8
|
||||
# nikki packages (install): the OpenWrt-nikki release NIKKI_VERSION, mirrored into the
|
||||
# kit repo's releases (tools/nikki-mirror.sh) - GitHub is often unreachable from the router
|
||||
NIKKI_VERSION=v1.26.2
|
||||
CORE_OFFICIAL=v1.19.33
|
||||
CORE_KIT=v1.19.33-ts7
|
||||
STOCK_CORE=/usr/libexec/mihomo
|
||||
KIT_ENV=${KIT_ENV:-/etc/nikki/kit.env}
|
||||
[ -f "$KIT_ENV" ] && . "$KIT_ENV"
|
||||
@ -72,8 +69,6 @@ case "$MIHOMO_VERSION" in
|
||||
*) : "${MIHOMO_BASE:=https://github.com/MetaCubeX/mihomo/releases/download/$MIHOMO_VERSION}" ;;
|
||||
esac
|
||||
: "${KIT_URL:=https://git.sam-hub.net/sam/mihomo-kit/archive/main.tar.gz}"
|
||||
# where nikki_<arch>-<branch>.tar.gz is downloaded from, tried in this order
|
||||
: "${NIKKI_BASES:=https://git.sam-hub.net/sam/mihomo-kit/releases/download/nikki-$NIKKI_VERSION https://github.com/nikkinikki-org/OpenWrt-nikki/releases/download/$NIKKI_VERSION}"
|
||||
|
||||
log() { echo "$*" >&2; }
|
||||
die() { log "error: $*"; exit 1; }
|
||||
@ -183,8 +178,6 @@ compute_tags() {
|
||||
case "$TAGS" in *" router "*" whitelist "* | *" router "*" foreign "*) TAGS="$TAGS ovpn_exit " ;; esac
|
||||
# own servers through MY-EXIT: whitelist and the phone (often on whitelists)
|
||||
case "$TAGS" in *" whitelist "* | *" mobile "*) TAGS="$TAGS my_exit " ;; esac
|
||||
# MY_SUB_BASE: the same without the providers of nodes with an entry (my_node_vars)
|
||||
MY_SUB_BASE=$MY_SUB_LIST
|
||||
export SUB_LIST MY_SUB_LIST CSQTT_MAIN
|
||||
}
|
||||
|
||||
@ -365,8 +358,6 @@ sub_vars() {
|
||||
_h="x-device-os=$HWID_OS;x-ver-os=$HWID_OS_VER;x-device-model=$HWID_MODEL;x-hwid=$HWID_ID${_h:+;$_h}"
|
||||
fi
|
||||
SUB_PROXY=$_p
|
||||
SUB_MY_EXCLUDE=""
|
||||
[ -n "${MY_NODE_ENTRIES:-}" ] && SUB_MY_EXCLUDE=$(yq "$(my_node_re "$2")")
|
||||
SUB_UA=$(yq "${_ua:-mihomo}")
|
||||
SUB_HEADERS=""
|
||||
_old_ifs=$IFS
|
||||
@ -382,7 +373,7 @@ sub_vars() {
|
||||
done
|
||||
set +f
|
||||
IFS=$_old_ifs
|
||||
export SUB_NAME SUB_URL SUB_PROXY SUB_UA SUB_HEADERS SUB_MY_EXCLUDE
|
||||
export SUB_NAME SUB_URL SUB_PROXY SUB_UA SUB_HEADERS
|
||||
}
|
||||
|
||||
# hy2_json <name>: an old own hysteria2 server of the settings (HY2_<NAME>_SERVER, _PORT,
|
||||
@ -404,14 +395,12 @@ hy2_json() {
|
||||
}
|
||||
|
||||
# Own servers (LuCI "Свои серверы"): MY_SERVERS_FILE holds one JSON proxy per line
|
||||
# with "name" first (luci/servers.js), plus the old HY2_* keys -> OWN_PLAIN, the lines
|
||||
# without an entry of their own and without the leading "{" (templates/proxies puts the
|
||||
# kit's dialer-proxy in front), OWN_ENTRY, the lines with one (LuCI "Вход": their own
|
||||
# "dialer-proxy", kept in every profile), OWN_BODIES, all lines as OWN_PLAIN (for the
|
||||
# chains' copies, which dial through their entry), and OWN_LIST '"a", "b"' for group MY. "$" becomes \u0024: the template engine would read
|
||||
# with "name" first (luci/servers.js), plus the old HY2_* keys -> OWN_BODIES, the
|
||||
# lines without the leading "{" (templates/proxies puts dialer-proxy in front), and
|
||||
# OWN_LIST '"a", "b"' for group MY. "$" becomes \u0024: the template engine would read
|
||||
# ${...} in a password, JSON and YAML both read the escape.
|
||||
own_servers_vars() {
|
||||
OWN_BODIES="" OWN_PLAIN="" OWN_ENTRY="" OWN_LIST="" OWN_NAMES=""
|
||||
OWN_BODIES="" OWN_LIST="" OWN_NAMES=""
|
||||
_lines=$(
|
||||
[ -f "$MY_SERVERS_FILE" ] && grep -v '^[[:space:]]*$' "$MY_SERVERS_FILE"
|
||||
for _n in $HY2; do hy2_json "$_n"; done
|
||||
@ -423,96 +412,10 @@ own_servers_vars() {
|
||||
_dup=$(printf '%s\n' "$_names" | sort | uniq -d | head -n 1)
|
||||
[ -z "$_dup" ] || die "own servers: the name $_dup repeats"
|
||||
OWN_NAMES=$_names
|
||||
OWN_BODIES=$(printf '%s\n' "$_lines" | sed 's/^{//; s/,"dialer-proxy":"[^"]*"//; s/\$/\\u0024/g')
|
||||
OWN_PLAIN=$(printf '%s\n' "$_lines" | grep -v '"dialer-proxy":' | sed 's/^{//; s/\$/\\u0024/g')
|
||||
OWN_ENTRY=$(printf '%s\n' "$_lines" | grep '"dialer-proxy":' | sed 's/^/- /; s/\$/\\u0024/g')
|
||||
OWN_BODIES=$(printf '%s\n' "$_lines" | sed 's/^{//; s/\$/\\u0024/g')
|
||||
OWN_LIST=$(printf '%s\n' "$_names" | sed 's/\$/\\u0024/g' | awk '{ printf "%s%s", (NR > 1 ? ", " : ""), $0 }')
|
||||
}
|
||||
|
||||
# [MY] nodes of the subscriptions with an entry of their own (LuCI «Свои серверы» →
|
||||
# «Вход»): MY_NODE_ENTRIES, one "<ENTRY>|<id>-my|<exact node name>" per line, stored in
|
||||
# common.env as MY_NODE_1, MY_NODE_2, ... (one line each: my_nodes_join). Such a node
|
||||
# leaves the provider <id>-my (its exclude-filter, SUB_MY_EXCLUDE) for <id>-my-via-<ENTRY>
|
||||
# (providers/16-myvia: the same file, only these nodes, dialer-proxy <ENTRY> in every
|
||||
# profile), which goes wherever <id>-my goes (my_via_expand). MYVIA_ITEMS "<id>|<ENTRY>".
|
||||
my_node_vars() {
|
||||
MYVIA_ITEMS=""
|
||||
: "${MY_NODE_ENTRIES:=$(my_nodes_join)}"
|
||||
[ -n "$MY_NODE_ENTRIES" ] || return 0
|
||||
MYVIA_ITEMS=$(printf '%s\n' "$MY_NODE_ENTRIES" | while IFS='|' read -r _me _mp _mn; do
|
||||
[ -n "$_me" ] && [ -n "$_mn" ] || continue
|
||||
case "$_mp" in *-my) ;; *) die "MY_NODE_ENTRIES: $_mp is not a provider of [MY] nodes (<id>-my)" ;; esac
|
||||
# a subscription that is off: its nodes are not in the profile
|
||||
case ", $MY_SUB_BASE, " in *", $_mp, "*) echo "${_mp%-my}|$_me" ;; esac
|
||||
done | awk '!seen[$0]++') || exit 1
|
||||
[ -n "$MYVIA_ITEMS" ] || return 0
|
||||
TAGS="$TAGS myvia "
|
||||
MY_SUB_LIST=$(my_via_expand "$MY_SUB_BASE")
|
||||
export MY_SUB_LIST
|
||||
}
|
||||
|
||||
# my_nodes_join: MY_NODE_1, MY_NODE_2, ... of the settings, one per line
|
||||
my_nodes_join() {
|
||||
_mk=1
|
||||
while eval "[ -n \"\${MY_NODE_$_mk+x}\" ]"; do
|
||||
eval "printf '%s\\n' \"\$MY_NODE_$_mk\""
|
||||
_mk=$((_mk + 1))
|
||||
done
|
||||
}
|
||||
|
||||
# my_via_expand "a-my, b, ...": the list with <id>-my-via-<ENTRY> after each <id>-my
|
||||
my_via_expand() {
|
||||
[ -n "$MYVIA_ITEMS" ] || { printf '%s' "$1"; return; }
|
||||
printf '%s\n' "$1" | tr ',' '\n' | sed 's/^ *//' | while read -r _vp; do
|
||||
[ -n "$_vp" ] || continue
|
||||
echo "$_vp"
|
||||
case "$_vp" in *-my) printf '%s\n' "$MYVIA_ITEMS" | awk -F'|' -v id="${_vp%-my}" '$1 == id { print $1 "-my-via-" $2 }' ;; esac
|
||||
done | awk '{ printf "%s%s", (NR > 1 ? ", " : ""), $0 }'
|
||||
}
|
||||
|
||||
# my_node_re <id> [ENTRY]: the exact names of its [MY] nodes with an entry (that one) as
|
||||
# one anchored regex, literal (backtick separates filters in mihomo: encoded); nothing if none
|
||||
my_node_re() {
|
||||
printf '%s\n' "${MY_NODE_ENTRIES:-}" | awk -F'|' -v p="$1-my" -v e="${2:-}" '
|
||||
$2 == p && (e == "" || $1 == e) { n = $0; sub(/^[^|]*\|[^|]*\|/, "", n); if (n != "") print n }' |
|
||||
sed 's/[][\\.^$*+?(){}|]/\\&/g; s/`/\\x60/g' | awk '{ printf "%s%s", (NR > 1 ? "|" : "^("), $0 } END { if (NR) print ")$" }'
|
||||
}
|
||||
|
||||
# myvia_vars "<id>|<ENTRY>": MV_NAME MV_ENTRY MV_FILTER (+ the subscription's SUB_* for the phone)
|
||||
myvia_vars() {
|
||||
_mid=${1%%|*} MV_ENTRY=${1#*|}
|
||||
MV_NAME="$_mid-my-via-$MV_ENTRY"
|
||||
MV_FILTER=$(yq "$(my_node_re "$_mid" "$MV_ENTRY")")
|
||||
_i=0
|
||||
for _pr in $SUB_PAIRS; do
|
||||
[ "${_pr%%=*}" = "$_mid" ] && sub_vars "$_i" "$_mid" "${_pr#*=}"
|
||||
_i=$((_i + 1))
|
||||
done
|
||||
export MV_NAME MV_ENTRY MV_FILTER
|
||||
}
|
||||
|
||||
# own_entries_check (after pools_vars): an own server's entry is FOREIGN, RU, DIRECT
|
||||
# or a pool that does not hold the server itself (that would be a loop)
|
||||
own_entries_check() {
|
||||
printf '%s\n' "$OWN_ENTRY" | sed -nE 's/^- \{"name":("([^"\\]|\\.)*"),.*"dialer-proxy":"([^"]*)".*/\3 \1/p' |
|
||||
while read -r _oe _on; do
|
||||
case " FOREIGN RU DIRECT$POOL_GROUPS" in *" $_oe "*) ;; *) die "own server $_on: entry $_oe is not FOREIGN, RU, DIRECT or a pool" ;; esac
|
||||
case "$_oe" in FOREIGN | RU | DIRECT) continue ;; esac
|
||||
# pool_vars sets _n, _e and others of its own
|
||||
pool_vars "$(printf '%s' "$_oe" | tr 'A-Z' 'a-z')"
|
||||
printf '%s\n' "$POOL_JSON" | grep -qxF "$_on" && die "own server $_on: its entry is the pool $_oe that holds it (a loop)"
|
||||
true
|
||||
done || exit 1
|
||||
# [MY] nodes: the same entries; a pool with their subscription's [MY] nodes would be a loop
|
||||
printf '%s\n' "$MYVIA_ITEMS" | while IFS='|' read -r _mi _oe; do
|
||||
[ -n "$_mi" ] || continue
|
||||
case " FOREIGN RU DIRECT$POOL_GROUPS" in *" $_oe "*) ;; *) die "[MY] nodes of $_mi: entry $_oe is not FOREIGN, RU, DIRECT or a pool" ;; esac
|
||||
case "$_oe" in FOREIGN | RU | DIRECT) continue ;; esac
|
||||
pool_vars "$(printf '%s' "$_oe" | tr 'A-Z' 'a-z')"
|
||||
case ", $POOL_USE_BASE, " in *", $_mi-my, "*) die "[MY] nodes of $_mi: their entry is the pool $_oe that takes them (a loop)" ;; esac
|
||||
done || exit 1
|
||||
}
|
||||
|
||||
# Services (SERVICES="claude ..."): a site or app that always takes its own way, with
|
||||
# a group of its own in the dashboard. Per service, keys SVC_<NAME>_* (upper case, - -> _):
|
||||
# _GEOSITE geosite lists of MetaCubeX/meta-rules-dat (GEOSITE_URL), e.g. "anthropic"
|
||||
@ -563,14 +466,11 @@ pool_vars() {
|
||||
done
|
||||
IFS=$_old_ifs
|
||||
for _p in $_su; do
|
||||
case ", $SUB_LIST, $MY_SUB_BASE, " in
|
||||
case ", $SUB_LIST, $MY_SUB_LIST, " in
|
||||
*", $_p, "*) POOL_USE="${POOL_USE:+$POOL_USE, }$_p" ;;
|
||||
*) POOL_DROPPED="${POOL_DROPPED:+$POOL_DROPPED, }$_p" ;;
|
||||
esac
|
||||
done
|
||||
# the chains' copies take every [MY] node from <id>-my@<entry>: without the via providers
|
||||
POOL_USE_BASE=$POOL_USE
|
||||
POOL_USE=$(my_via_expand "$POOL_USE")
|
||||
if [ -z "$POOL_PROXIES$POOL_USE" ]; then
|
||||
POOL_PROXIES=REJECT
|
||||
POOL_TYPE=select
|
||||
@ -635,10 +535,10 @@ variant_add() {
|
||||
variant_members() {
|
||||
_pfixed=0
|
||||
if [ "$1" = MY ]; then
|
||||
_vm_json=$OWN_NAMES _vm_use=$MY_SUB_BASE _vm_type=fallback _vm_filter="" _vm_exclude=""
|
||||
_vm_json=$OWN_NAMES _vm_use=$MY_SUB_LIST _vm_type=fallback _vm_filter="" _vm_exclude=""
|
||||
else
|
||||
pool_vars "$(printf '%s' "$1" | tr 'A-Z' 'a-z')"
|
||||
_vm_json=$POOL_JSON _vm_use=$POOL_USE_BASE _vm_type=$POOL_TYPE _vm_filter=$POOL_FILTER _vm_exclude=$POOL_EXCLUDE
|
||||
_vm_json=$POOL_JSON _vm_use=$POOL_USE _vm_type=$POOL_TYPE _vm_filter=$POOL_FILTER _vm_exclude=$POOL_EXCLUDE
|
||||
if [ "$_pfixed" = 1 ] && [ -n "$_fi" ] && [ -n "${VM_ENTRY:-}" ]; then
|
||||
_vm_filter=$(yq "${_fi%\$} ⟶ $VM_ENTRY\$")
|
||||
fi
|
||||
@ -775,38 +675,13 @@ services_fixed_vars() {
|
||||
set +f
|
||||
}
|
||||
|
||||
# hostlist_payload <files>: zapret-style hostlists (a domain per line, "# comment", ".gz" too)
|
||||
# -> the payload of an inline rule-provider (behavior: domain), deduplicated: "+.a.com"
|
||||
# (with subdomains, as zapret matches), "^b.com" -> "b.com" (zapret: this domain only);
|
||||
# IP lines and junk are dropped; files that are not there are skipped (services_vars warns)
|
||||
hostlist_payload() {
|
||||
set -f
|
||||
for _f in $1; do
|
||||
[ -f "$_f" ] && [ -r "$_f" ] || continue
|
||||
case "$_f" in *.gz) gzip -dc "$_f" 2>/dev/null ;; *) cat "$_f" ;; esac
|
||||
echo
|
||||
done | awk '{
|
||||
sub(/#.*/, ""); gsub(/[ \t\r]/, ""); $0 = tolower($0)
|
||||
exact = sub(/^\^/, "")
|
||||
sub(/^\*/, ""); sub(/^\+/, ""); sub(/^\./, ""); sub(/\.$/, "")
|
||||
if ($0 !~ /^[a-z0-9_-]+(\.[a-z0-9_-]+)*$/ || $0 ~ /^[0-9.]+$/) next
|
||||
d = (exact ? "" : "+.") $0
|
||||
if (!(d in seen)) { seen[d] = 1; print d }
|
||||
}'
|
||||
set +f
|
||||
}
|
||||
|
||||
# svc_vars <name>: SVC_NAME SVC_GROUP SVC_GEOSITE SVC_DOMAINS SVC_IPS SVC_VIA SVC_PROXIES
|
||||
# SVC_HOSTLIST (the payload of hostlist-<name>, hostlist_payload) for the svc templates;
|
||||
# ITEM_TAGS " svc_my " when the service goes through own servers, + " svc_hostlist "
|
||||
# for the svc templates; ITEM_TAGS " svc_my " when the service goes through own servers
|
||||
svc_vars() {
|
||||
_k=$(svc_key "$1")
|
||||
SVC_NAME=$1
|
||||
SVC_GROUP=$(printf '%s' "$1" | tr 'a-z' 'A-Z')
|
||||
eval "SVC_GEOSITE=\${${_k}_GEOSITE:-} SVC_DOMAINS=\${${_k}_DOMAINS:-} SVC_IPS=\${${_k}_IPS:-} SVC_VIA=\${${_k}_VIA:-MY} SVC_CHAIN=\${${_k}_CHAIN:-}"
|
||||
eval "SVC_HOSTLIST_FILES=\${${_k}_HOSTLIST:-}"
|
||||
SVC_HOSTLIST=""
|
||||
[ -z "$SVC_HOSTLIST_FILES" ] || SVC_HOSTLIST=$(hostlist_payload "$SVC_HOSTLIST_FILES")
|
||||
eval "SVC_SERVER=\${${_k}_SERVER:-}"
|
||||
[ -z "$SVC_SERVER" ] || SVC_VIA="SVC-FIXED-$(printf '%s' "$1" | tr 'a-z' 'A-Z')"
|
||||
SVC_DOMAINS=$(norm_list dom "$SVC_DOMAINS")
|
||||
@ -826,8 +701,7 @@ svc_vars() {
|
||||
SVC_PROXIES="\"$SVC_VIA\""
|
||||
[ -z "$SVC_CHAIN" ] || SVC_PROXIES="\"$SVC_VIA ⟶ $SVC_CHAIN\""
|
||||
fi
|
||||
[ -z "$SVC_HOSTLIST" ] || ITEM_TAGS="${ITEM_TAGS:- }svc_hostlist "
|
||||
export SVC_NAME SVC_GROUP SVC_GEOSITE SVC_DOMAINS SVC_IPS SVC_PROXIES SVC_HOSTLIST
|
||||
export SVC_NAME SVC_GROUP SVC_GEOSITE SVC_DOMAINS SVC_IPS SVC_PROXIES
|
||||
}
|
||||
|
||||
# check SERVICES and their keys; GEOSITE_ITEMS: the geosite lists of all services, once each
|
||||
@ -845,12 +719,7 @@ services_vars() {
|
||||
*" $SVC_VIA "*) ;;
|
||||
*) die "$(svc_key "$_s")_VIA: MY, FOREIGN, RU, DIRECT, MAIN or a pool${POOL_GROUPS% }, not '$SVC_VIA'" ;;
|
||||
esac
|
||||
[ -n "$SVC_GEOSITE$SVC_DOMAINS$SVC_IPS$SVC_HOSTLIST_FILES" ] || die "service $_s: no GEOSITE, DOMAINS, IPS or HOSTLIST"
|
||||
for _f in $SVC_HOSTLIST_FILES; do
|
||||
[ -f "$_f" ] && [ -r "$_f" ] || log "warning: $(svc_key "$_s")_HOSTLIST: no file $_f, skipped"
|
||||
done
|
||||
[ -z "$SVC_HOSTLIST_FILES" ] || [ -n "$SVC_HOSTLIST" ] ||
|
||||
log "warning: $(svc_key "$_s")_HOSTLIST: no domains in $SVC_HOSTLIST_FILES"
|
||||
[ -n "$SVC_GEOSITE$SVC_DOMAINS$SVC_IPS" ] || die "service $_s: no GEOSITE, DOMAINS or IPS"
|
||||
if [ -n "$SVC_CHAIN" ]; then
|
||||
case " MY$POOL_GROUPS" in *" $SVC_VIA "*) ;; *) die "$(svc_key "$_s")_CHAIN: only for _VIA = MY or a pool" ;; esac
|
||||
_entries=" DIRECT FOREIGN RU MY${POOL_GROUPS% }"
|
||||
@ -968,11 +837,6 @@ render_section() {
|
||||
done
|
||||
IFS=$_old_ifs
|
||||
ITEM_TAGS=""
|
||||
elif [ "$EACH" = 1 ] && [ "$_mod" = myvia ]; then
|
||||
for _it in $MYVIA_ITEMS; do
|
||||
myvia_vars "$_it"
|
||||
render_part "$f"
|
||||
done
|
||||
elif [ "$EACH" = 1 ] && [ "$_mod" = svc ]; then
|
||||
for _it in $SERVICES; do
|
||||
svc_vars "$_it"
|
||||
@ -1061,10 +925,8 @@ render() {
|
||||
for _l in RU_IPS FOREIGN_IPS MY_IPS; do eval "$_l=\$(norm_list ip \"\$$_l\")"; done
|
||||
for _l in RU_DOMAINS FOREIGN_DOMAINS MY_DOMAINS; do eval "$_l=\$(norm_list dom \"\$$_l\")"; done
|
||||
# after compute_tags: pools use SUB_LIST / MY_SUB_LIST
|
||||
my_node_vars
|
||||
services_fixed_vars
|
||||
pools_vars
|
||||
own_entries_check
|
||||
services_vars
|
||||
[ -n "$GEOSITE_ITEMS" ] && TAGS="$TAGS geosite "
|
||||
variants_build
|
||||
@ -1073,7 +935,7 @@ render() {
|
||||
BOOT_PBK BOOT_SID TS_HOSTNAME TS_DOMAINS OVPN_PROVIDER OVPN_GROUP OVPN_SERVER_HOST \
|
||||
OVPN_SERVER_IPS OVPN_ROUTES OVPN_CHECK_URL TS_CHECK_URL CSQTT_IFACE CSQTT_PROCESS \
|
||||
RU_IPS FOREIGN_IPS MY_IPS RU_DOMAINS FOREIGN_DOMAINS MY_DOMAINS LOCAL_DOMAINS LOCAL_HOSTS_YAML \
|
||||
OWN_PLAIN OWN_ENTRY OWN_LIST GEOSITE_URL
|
||||
OWN_BODIES OWN_LIST GEOSITE_URL
|
||||
_first=1
|
||||
for s in head proxies:proxies providers:proxy-providers rule-providers:rule-providers sniffer dns \
|
||||
groups:proxy-groups rules:rules; do
|
||||
@ -1358,33 +1220,6 @@ lite_check() {
|
||||
return 0
|
||||
}
|
||||
|
||||
# BYPASS_CLIENTS (common.env): LAN clients by IPv4 (or a subnet) and MAC that nikki leaves
|
||||
# alone, neither their traffic nor their DNS reaches mihomo: e.g. another router with its
|
||||
# own kit behind this one, whose traffic would go through a proxy twice. nikki's own
|
||||
# lan_access_control: a section of the kit's, first among them (the first match wins).
|
||||
BYPASS_SECTION=mihomo_kit_bypass
|
||||
bypass_uci() {
|
||||
_bc=$(sed -n 's/^BYPASS_CLIENTS=//p' "$PROFILES_D/common.env" 2>/dev/null | tail -n 1 | tr -d "'\"")
|
||||
_was=$(uci -q get "nikki.$BYPASS_SECTION.ip" ; uci -q get "nikki.$BYPASS_SECTION.mac")
|
||||
uci -q delete "nikki.$BYPASS_SECTION"
|
||||
if [ -z "$_bc" ]; then
|
||||
[ -z "$_was" ] || log "nikki: no clients bypass mihomo any more"
|
||||
return 0
|
||||
fi
|
||||
uci set "nikki.$BYPASS_SECTION=lan_access_control"
|
||||
uci set "nikki.$BYPASS_SECTION.enabled=1"
|
||||
uci set "nikki.$BYPASS_SECTION.proxy=0"
|
||||
uci set "nikki.$BYPASS_SECTION.dns=0"
|
||||
for _c in $_bc; do
|
||||
case "$_c" in
|
||||
*[:-]*[:-]*[:-]*[:-]*[:-]*) uci add_list "nikki.$BYPASS_SECTION.mac=$(printf '%s' "$_c" | tr 'A-F-' 'a-f:')" ;;
|
||||
*) uci add_list "nikki.$BYPASS_SECTION.ip=$_c" ;;
|
||||
esac
|
||||
done
|
||||
uci reorder "nikki.$BYPASS_SECTION=0"
|
||||
log "nikki: past mihomo: $_bc"
|
||||
}
|
||||
|
||||
# A new router (no settings yet): interception without TUN, as LITE does (TCP
|
||||
# redirect, UDP tproxy), and no IPv6 anywhere in nikki. Once the settings are
|
||||
# saved, nikki's own settings are left to the user.
|
||||
@ -1408,7 +1243,6 @@ cmd_use() {
|
||||
lite_uci "$1"
|
||||
csqtt_match_process "$1"
|
||||
ipv6_proxy_off
|
||||
bypass_uci
|
||||
uci commit nikki
|
||||
mem_env "$1"
|
||||
/etc/init.d/nikki restart
|
||||
@ -1934,18 +1768,9 @@ install_luci() {
|
||||
rm -rf /tmp/luci-indexcache* /tmp/luci-modulecache
|
||||
log "LuCI page installed: Services -> mihomo-kit"
|
||||
[ "$_rpcd" = 1 ] || return 0
|
||||
# rpcd loads plugins and ACLs only on start. Not "rpcd restart": run from a job LuCI
|
||||
# started (kit update) this shell is rpcd's descendant, and the stop can take it down
|
||||
# before the start - rpcd stays dead, LuCI says "Object not found" and rejects the
|
||||
# password until a reboot. SIGHUP (through procd: to rpcd itself, not its plugins)
|
||||
# makes rpcd re-exec in place and keep the LuCI sessions; then make sure it runs.
|
||||
# Delayed so the job gets to finish first.
|
||||
(
|
||||
sleep 5
|
||||
ubus call service signal '{"name":"rpcd","signal":1}' || kill -HUP "$(pidof rpcd | cut -d' ' -f1)"
|
||||
sleep 5
|
||||
pidof rpcd || /etc/init.d/rpcd start
|
||||
) < /dev/null > /dev/null 2>&1 &
|
||||
# rpcd loads plugins only on start; delayed so a job started from LuCI
|
||||
# (kit update) gets to finish first
|
||||
(sleep 5; /etc/init.d/rpcd restart) < /dev/null > /dev/null 2>&1 &
|
||||
}
|
||||
|
||||
enable_otp_cron() {
|
||||
@ -1964,130 +1789,37 @@ enable_otp_cron() {
|
||||
opkg_fit() {
|
||||
_new=$(opkg --noaction --force-space install "$@" 2>/dev/null | sed -n 's/^Installing \([^ ]*\) (.*/\1/p')
|
||||
if [ -z "$_new" ]; then
|
||||
opkg_q install "$@"
|
||||
opkg install "$@"
|
||||
return
|
||||
fi
|
||||
_field=Installed-Size
|
||||
case "$(awk '$2 == "/overlay" {print $3; exit}' /proc/mounts)" in ubifs | jffs2) _field=Size ;; esac
|
||||
_new=$(echo $_new)
|
||||
# the sizes straight from the feeds' lists, one pass (not "opkg info" per package:
|
||||
# it parses every list each time); a package listed by several feeds counts once
|
||||
_need=$(opkg_lists | awk -v want=" $_new " -v f="$_field:" '
|
||||
$1 == "Package:" { p = $2 }
|
||||
$1 == f && index(want, " " p " ") && !(p in seen) { seen[p] = 1; s += int(($2 + 1023) / 1024) }
|
||||
END { print s + 0 }')
|
||||
_need=0
|
||||
for _p in $_new; do
|
||||
_b=$(opkg info "$_p" | sed -n "s/^$_field: *//p" | head -n 1)
|
||||
case "$_b" in '' | *[!0-9]*) _b=0 ;; esac
|
||||
_need=$((_need + (_b + 1023) / 1024))
|
||||
done
|
||||
_free=$(df -k / 2>/dev/null | awk 'NR==2 {print $4}')
|
||||
_new=$(echo $_new)
|
||||
log "packages $_new: about $_need KB on flash ($_field), free ${_free:-?} KB"
|
||||
[ $((${_free:-0} - _need)) -ge "$PKG_RESERVE_KB" ] ||
|
||||
die "not enough flash for $_new: free $((PKG_RESERVE_KB + _need - ${_free:-0})) KB more"
|
||||
opkg_q install --force-space "$@"
|
||||
}
|
||||
|
||||
# opkg_lists: the package lists of all feeds as text (opkg keeps them gzipped in lists_dir)
|
||||
opkg_lists() {
|
||||
_ld=$(awk '$1 == "lists_dir" { print $3; exit }' /etc/opkg.conf 2>/dev/null)
|
||||
for _lf in "${_ld:-/var/opkg-lists}"/*; do
|
||||
case "$_lf" in *.sig) continue ;; esac
|
||||
[ -f "$_lf" ] || continue
|
||||
gunzip -c "$_lf" 2>/dev/null || cat "$_lf"
|
||||
done
|
||||
}
|
||||
|
||||
# opkg_q <args>: opkg without its "ERROR: truncating field N <0x...> to M byte" noise. opkg-lede
|
||||
# prints it (without a newline, once per field) when several feeds list the same package -
|
||||
# e.g. firmwares with nikki in their own feeds (Routerich) plus the kit's - and it is harmless.
|
||||
# The exit code is opkg's.
|
||||
opkg_q() {
|
||||
_qrc=/tmp/mihomo-kit-opkg.rc.$$
|
||||
{ opkg "$@" 2>&1; echo "$?" > "$_qrc"; } |
|
||||
sed 's/ERROR: truncating field [0-9]* <0x[0-9a-fA-F]*> to [0-9]* byte//g' | grep -v '^[[:space:]]*$'
|
||||
_rc=$(cat "$_qrc" 2>/dev/null || echo 1)
|
||||
rm -f "$_qrc"
|
||||
return "$_rc"
|
||||
}
|
||||
|
||||
# --- nikki from its release bundle ------------------------------------------
|
||||
# A release of OpenWrt-nikki has one nikki_<arch>-<branch>.tar.gz per router type, and
|
||||
# each is a whole opkg feed: Packages(.gz) signed with nikki's key + the .ipk files.
|
||||
# nikki_feed unpacks the one for this router into RAM and adds it as a temporary feed,
|
||||
# so opkg checks the signature (key from the kit: router/nikki-key-build.pub), takes
|
||||
# the dependencies from the OpenWrt feeds and opkg_fit counts the flash as usual.
|
||||
# The bundle comes from NIKKI_BASES (the kit's mirror first, then GitHub), or from
|
||||
# the file NIKKI_TGZ copied to the router by hand.
|
||||
NIKKI_FEED=/tmp/nikki-feed
|
||||
NIKKI_FEED_CONF=/etc/opkg/nikki-kit.conf
|
||||
|
||||
# nikki_bundle: the bundle name for this router (after . /etc/openwrt_release)
|
||||
nikki_bundle() {
|
||||
case "${DISTRIB_RELEASE:-}" in
|
||||
*24.10*) echo "nikki_${DISTRIB_ARCH:-?}-openwrt-24.10.tar.gz" ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
nikki_feed_drop() {
|
||||
rm -rf "$NIKKI_FEED" "$NIKKI_FEED_CONF" /var/opkg-lists/nikki_kit
|
||||
}
|
||||
|
||||
nikki_feed() {
|
||||
[ -f /etc/openwrt_release ] && . /etc/openwrt_release
|
||||
_bundle=$(nikki_bundle) ||
|
||||
die "nikki: OpenWrt ${DISTRIB_RELEASE:-?} не поддерживается (нужна 24.10 с opkg)"
|
||||
nikki_feed_drop
|
||||
mkdir -p "$NIKKI_FEED"
|
||||
if [ -n "${NIKKI_TGZ:-}" ]; then
|
||||
log "nikki: unpacking $NIKKI_TGZ"
|
||||
tar xzf "$NIKKI_TGZ" -C "$NIKKI_FEED" || die "nikki: $NIKKI_TGZ is not a nikki bundle"
|
||||
else
|
||||
for _b in $NIKKI_BASES; do
|
||||
log "nikki: downloading $_b/$_bundle"
|
||||
wget -T 30 -qO- "$_b/$_bundle" | tar xzf - -C "$NIKKI_FEED" 2>/dev/null &&
|
||||
[ -f "$NIKKI_FEED/Packages.gz" ] && break
|
||||
log "nikki: not available there"
|
||||
rm -rf "$NIKKI_FEED"
|
||||
mkdir -p "$NIKKI_FEED"
|
||||
done
|
||||
fi
|
||||
if [ ! -f "$NIKKI_FEED/Packages.gz" ]; then
|
||||
nikki_feed_drop
|
||||
die "nikki не скачался ($_bundle). На компьютере скачай его из
|
||||
${NIKKI_BASES%% *}/$_bundle
|
||||
(или https://github.com/nikkinikki-org/OpenWrt-nikki/releases/tag/$NIKKI_VERSION),
|
||||
скопируй на роутер: scp -O $_bundle root@<роутер>:/tmp/
|
||||
и запусти установку снова с NIKKI_TGZ=/tmp/$_bundle перед sh, например:
|
||||
NIKKI_TGZ=/tmp/$_bundle sh /etc/nikki/kit/install.sh"
|
||||
fi
|
||||
# not needed by the kit, only takes RAM (upstream bundles have them)
|
||||
rm -f "$NIKKI_FEED"/mihomo-alpha_*.ipk "$NIKKI_FEED"/luci-i18n-nikki-zh-*.ipk
|
||||
opkg-key add "$KIT_DIR/router/nikki-key-build.pub" >/dev/null 2>&1 ||
|
||||
log "warning: nikki: key not added, opkg may reject the feed signature"
|
||||
echo "src/gz nikki_kit file://$NIKKI_FEED" > "$NIKKI_FEED_CONF"
|
||||
# the feed points into RAM: never leave it behind, also after die
|
||||
trap nikki_feed_drop EXIT
|
||||
opkg install --force-space "$@"
|
||||
}
|
||||
|
||||
cmd_install() {
|
||||
command -v opkg >/dev/null 2>&1 || die "нет opkg: OpenWrt 25.12+ (apk) kit пока не поддерживает"
|
||||
_nikki_new=
|
||||
if [ ! -x /etc/init.d/nikki ]; then
|
||||
nikki_feed
|
||||
_nikki_new=1
|
||||
fi
|
||||
opkg update
|
||||
if [ -n "$_nikki_new" ]; then
|
||||
# mihomo-meta named: nikki needs a "mihomo", and the feed also lists mihomo-alpha
|
||||
_luci=
|
||||
[ -d /www/luci-static/resources ] && _luci="luci-app-nikki luci-i18n-nikki-ru"
|
||||
opkg_fit mihomo-meta nikki $_luci
|
||||
nikki_feed_drop
|
||||
trap - EXIT
|
||||
[ -x /etc/init.d/nikki ] || die "nikki не установился, ошибки opkg выше"
|
||||
if [ ! -x /etc/init.d/nikki ]; then
|
||||
# feed.sh saves the feed key to the current directory
|
||||
(cd /tmp && wget -O - https://github.com/nikkinikki-org/OpenWrt-nikki/raw/refs/heads/main/feed.sh | ash)
|
||||
opkg_fit nikki luci-app-nikki
|
||||
fi
|
||||
for p in curl oath-toolkit; do
|
||||
opkg list-installed | grep -q "^$p " || opkg_fit "$p"
|
||||
done
|
||||
# curl newer than libcurl -> "Error relocating ... symbol not found"
|
||||
curl --version >/dev/null 2>&1 || opkg_q install --force-reinstall libcurl4 curl
|
||||
curl --version >/dev/null 2>&1 || opkg install --force-reinstall libcurl4 curl
|
||||
nikki_defaults
|
||||
install_files
|
||||
cmd_fix
|
||||
@ -2147,7 +1879,7 @@ cmd_pkg_install() {
|
||||
die "not enough flash, nothing installed (free $((PKG_RESERVE_KB - _left)) KB more)"
|
||||
/etc/init.d/nikki stop 2>/dev/null
|
||||
_rc=0
|
||||
opkg_q install --force-space "$@" || _rc=$?
|
||||
opkg install --force-space "$@" || _rc=$?
|
||||
# a nikki upgrade replaces /etc/init.d/nikki (the kit's lines are gone): fix puts
|
||||
# them back, checks the core and starts nikki - also after a failed install
|
||||
cmd_fix
|
||||
@ -2330,7 +2062,7 @@ common_other_keys() {
|
||||
write_config() {
|
||||
umask 077
|
||||
_any_hwid=0
|
||||
[ "${FORM:-0}" = 1 ] && COMMON_KEYS="$COMMON_KEYS|HY2|HY2_[A-Z0-9_]+|MY_IPS|MY_DOMAINS|LOCAL_HOSTS|MY_LINKS|LITE|LITE_GOMEMLIMIT|OVPN_CHECK_URL|TS_CHECK_URL|MOBILE|BYPASS_CLIENTS|MY_NODE_[0-9]+|SERVICES|SVC_[A-Z0-9_]+|POOLS|POOL_[A-Z0-9_]+"
|
||||
[ "${FORM:-0}" = 1 ] && COMMON_KEYS="$COMMON_KEYS|HY2|HY2_[A-Z0-9_]+|MY_IPS|MY_DOMAINS|LOCAL_HOSTS|MY_LINKS|LITE|LITE_GOMEMLIMIT|OVPN_CHECK_URL|TS_CHECK_URL|MOBILE|SERVICES|SVC_[A-Z0-9_]+|POOLS|POOL_[A-Z0-9_]+"
|
||||
_others=$(common_other_keys)
|
||||
sub_pairs
|
||||
{
|
||||
@ -2375,11 +2107,7 @@ write_config() {
|
||||
[ -n "${MY_IPS:-}" ] && echo "MY_IPS=$(q "$MY_IPS")"
|
||||
[ -n "${MY_DOMAINS:-}" ] && echo "MY_DOMAINS=$(q "$MY_DOMAINS")"
|
||||
[ -n "${LOCAL_HOSTS:-}" ] && echo "LOCAL_HOSTS=$(q "$LOCAL_HOSTS")"
|
||||
[ -n "${BYPASS_CLIENTS:-}" ] && echo "BYPASS_CLIENTS=$(q "$BYPASS_CLIENTS")"
|
||||
[ -n "${MY_LINKS:-}" ] && echo "MY_LINKS=$(q "$MY_LINKS")"
|
||||
printf '%s\n' "${MY_NODE_ENTRIES:-}" | grep . | awk '{ print NR "\t" $0 }' | while IFS=' ' read -r _mk _ml; do
|
||||
echo "MY_NODE_$_mk=$(q "$_ml")"
|
||||
done
|
||||
[ -n "${POOLS:-}" ] && echo "POOLS=$(q "$POOLS")"
|
||||
for _s in ${POOLS:-}; do
|
||||
_k=$(pool_key "$_s")
|
||||
@ -2448,10 +2176,8 @@ cmd_configure() {
|
||||
[ -f "${1:-}" ] || die "usage: configure <env>"
|
||||
# saved OpenVPN secrets stay unless the form sends new ones
|
||||
[ -f "$NIKKI_DIR/openvpn.env" ] && . "$NIKKI_DIR/openvpn.env"
|
||||
# the saved networks, [MY] node entries and clients past mihomo unless the form sends them
|
||||
BYPASS_CLIENTS=$(sed -n "s/^BYPASS_CLIENTS=//p" "$PROFILES_D/common.env" 2>/dev/null | tail -n 1 | tr -d "'\"")
|
||||
# the saved networks unless the form sends them
|
||||
OVPN_ROUTES=$(sed -n "s/^OVPN_ROUTES=//p" "$PROFILES_D/common.env" 2>/dev/null | tail -n 1 | tr -d "'\"")
|
||||
MY_NODE_ENTRIES=$( (. "$PROFILES_D/common.env" 2>/dev/null; my_nodes_join) )
|
||||
. "$1"
|
||||
rm -f "$1"
|
||||
BOOT=0 BOOT_LINKS=${BOOT_LINKS:-}
|
||||
@ -2560,14 +2286,14 @@ cmd_import() {
|
||||
case "${_f#profiles.d/}" in */* | *[!A-Za-z0-9_.-]*) die "bad file name: $_f" ;; esac
|
||||
done
|
||||
# _drop: keys of the bundle replaced by this router's ones (LOCAL_HOSTS always)
|
||||
_keep="" _drop="LOCAL_HOSTS|BYPASS_CLIENTS"
|
||||
_keep="" _drop=LOCAL_HOSTS
|
||||
if [ "${2:-}" = --keep-local ]; then
|
||||
for _k in TS_HOSTNAME HWID_ID LOCAL_HOSTS BYPASS_CLIENTS; do
|
||||
for _k in TS_HOSTNAME HWID_ID LOCAL_HOSTS; do
|
||||
_l=$(grep "^$_k=" "$PROFILES_D/common.env" 2>/dev/null | tail -n 1)
|
||||
[ -n "$_l" ] || continue
|
||||
_keep="$_keep$_l
|
||||
"
|
||||
case "$_k" in LOCAL_HOSTS | BYPASS_CLIENTS) ;; *) _drop="$_drop|$_k" ;; esac
|
||||
[ "$_k" = LOCAL_HOSTS ] || _drop="$_drop|$_k"
|
||||
done
|
||||
fi
|
||||
_tmp=$(mktemp -d)
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
untrusted comment: Nikki
|
||||
RWSrAXyIqregizvXvG9kJI/JoTkaCCPDy6CQrrVQ4IZ8Qgu+iWMql0UW
|
||||
|
||||
@ -77,10 +77,6 @@ RU_IPS="194.190.191.112/32"
|
||||
#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
|
||||
#OVPN_ROUTES="10.0.0.0/8 192.168.50.0/24" # what goes through the VPN (LuCI: the .ovpn's route lines)
|
||||
|
||||
@ -3,8 +3,7 @@
|
||||
# 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).
|
||||
# so the subscription is fetched once more.
|
||||
${SUB_NAME}-my:
|
||||
type: file #@router
|
||||
path: ./providers/${SUB_NAME}.yaml #@router
|
||||
@ -14,7 +13,6 @@
|
||||
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
|
||||
|
||||
@ -1,24 +0,0 @@
|
||||
# [MY] nodes of ${SUB_NAME} with an entry of their own (LuCI «Свои серверы» → «Вход»):
|
||||
# out of ${SUB_NAME}-my, dialing through ${MV_ENTRY} in every profile
|
||||
${MV_NAME}:
|
||||
type: file #@router
|
||||
path: ./providers/${SUB_NAME}.yaml #@router
|
||||
type: http #@mobile
|
||||
url: "${SUB_URL}" #@mobile
|
||||
path: ./providers/${MV_NAME}.yaml #@mobile
|
||||
interval: 3600 #@mobile
|
||||
proxy: ${@SUB_PROXY} #@mobile
|
||||
filter: "${MV_FILTER}"
|
||||
override:
|
||||
dialer-proxy: ${MV_ENTRY}
|
||||
header: #@mobile
|
||||
User-Agent: ["${SUB_UA}"] #@mobile
|
||||
${@@SUB_HEADERS} #@mobile
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300 #@!lite
|
||||
interval: 600 #@lite
|
||||
timeout: 3000
|
||||
lazy: false #@!lite
|
||||
lazy: true #@lite
|
||||
@ -1,8 +1,6 @@
|
||||
# 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}
|
||||
# front: whitelist and the phone through MY-EXIT, else with UPLINK (CSQTT, pools) through it
|
||||
- {"dialer-proxy": "MY-EXIT", ${@@OWN_BODIES} #@my_exit
|
||||
- {"dialer-proxy": "UPLINK", ${@@OWN_BODIES} #@uplink,!my_exit
|
||||
- {${@@OWN_BODIES} #@!my_exit,!uplink
|
||||
|
||||
@ -1,7 +0,0 @@
|
||||
# service ${SVC_NAME}: domains of its hostlists (SVC_<NAME>_HOSTLIST, e.g. zapret's #@svc_hostlist
|
||||
# /opt/zapret2/ipset/*.txt), read when the profile is built: rebuild to pick up changes #@svc_hostlist
|
||||
hostlist-${SVC_NAME}: #@svc_hostlist
|
||||
type: inline #@svc_hostlist
|
||||
behavior: domain #@svc_hostlist
|
||||
payload: #@svc_hostlist
|
||||
- "${@SVC_HOSTLIST}" #@svc_hostlist
|
||||
@ -2,4 +2,3 @@
|
||||
- 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
|
||||
|
||||
@ -16,14 +16,12 @@ proxies:
|
||||
|
||||
# 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
|
||||
# front: whitelist and the phone through MY-EXIT, else with UPLINK (CSQTT, pools) through it
|
||||
- {"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>")
|
||||
@ -73,8 +71,7 @@ proxy-providers:
|
||||
# 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).
|
||||
# so the subscription is fetched once more.
|
||||
example-my:
|
||||
type: http
|
||||
url: "https://sub.example.com/sub/aaa"
|
||||
@ -98,8 +95,7 @@ proxy-providers:
|
||||
# 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).
|
||||
# so the subscription is fetched once more.
|
||||
example2-my:
|
||||
type: http
|
||||
url: "https://sub2.example.com/x?a=1&b=2"
|
||||
@ -264,7 +260,7 @@ proxy-groups:
|
||||
# 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"]
|
||||
proxies: ["🇩🇪 de 1", "tr \"q\"", "hy-own", "awg-own", "m1"]
|
||||
use: [example-my, example2-my]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
|
||||
@ -73,8 +73,7 @@ proxy-providers:
|
||||
# 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).
|
||||
# so the subscription is fetched once more.
|
||||
example-my:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
@ -93,8 +92,7 @@ proxy-providers:
|
||||
# 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).
|
||||
# so the subscription is fetched once more.
|
||||
example2-my:
|
||||
type: file
|
||||
path: ./providers/example2.yaml
|
||||
|
||||
@ -17,14 +17,12 @@ proxies:
|
||||
|
||||
# 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
|
||||
# front: whitelist and the phone through MY-EXIT, else with UPLINK (CSQTT, pools) through it
|
||||
- {"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)
|
||||
@ -81,8 +79,7 @@ proxy-providers:
|
||||
# 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).
|
||||
# so the subscription is fetched once more.
|
||||
example-my:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
@ -101,8 +98,7 @@ proxy-providers:
|
||||
# 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).
|
||||
# so the subscription is fetched once more.
|
||||
example2-my:
|
||||
type: file
|
||||
path: ./providers/example2.yaml
|
||||
@ -234,7 +230,7 @@ proxy-groups:
|
||||
# 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"]
|
||||
proxies: ["🇩🇪 de 1", "tr \"q\"", "hy-own", "awg-own", "nl-1"]
|
||||
use: [example-my, example2-my]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
|
||||
@ -17,13 +17,11 @@ proxies:
|
||||
|
||||
# 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
|
||||
# front: whitelist and the phone through MY-EXIT, else with UPLINK (CSQTT, pools) through it
|
||||
- {"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)
|
||||
@ -80,8 +78,7 @@ proxy-providers:
|
||||
# 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).
|
||||
# so the subscription is fetched once more.
|
||||
example-my:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
@ -100,8 +97,7 @@ proxy-providers:
|
||||
# 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).
|
||||
# so the subscription is fetched once more.
|
||||
example2-my:
|
||||
type: file
|
||||
path: ./providers/example2.yaml
|
||||
@ -236,7 +232,7 @@ proxy-groups:
|
||||
# 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"]
|
||||
proxies: ["🇩🇪 de 1", "tr \"q\"", "hy-own", "awg-own"]
|
||||
use: [example-my, example2-my]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
|
||||
@ -27,8 +27,7 @@ proxies:
|
||||
|
||||
# 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
|
||||
# front: whitelist and the phone through MY-EXIT, else with UPLINK (CSQTT, pools) through it
|
||||
- {"name":"nl-1","type":"hysteria2","server":"vpn.example.com","port":443,"password":"p","udp":true}
|
||||
|
||||
proxy-providers:
|
||||
@ -75,8 +74,7 @@ proxy-providers:
|
||||
# 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).
|
||||
# so the subscription is fetched once more.
|
||||
example-my:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
@ -93,8 +91,7 @@ proxy-providers:
|
||||
# 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).
|
||||
# so the subscription is fetched once more.
|
||||
example2-my:
|
||||
type: file
|
||||
path: ./providers/example2.yaml
|
||||
|
||||
@ -64,8 +64,7 @@ proxy-providers:
|
||||
# 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).
|
||||
# so the subscription is fetched once more.
|
||||
example-my:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
@ -82,8 +81,7 @@ proxy-providers:
|
||||
# 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).
|
||||
# so the subscription is fetched once more.
|
||||
example2-my:
|
||||
type: file
|
||||
path: ./providers/example2.yaml
|
||||
|
||||
@ -82,8 +82,7 @@ proxy-providers:
|
||||
# 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).
|
||||
# so the subscription is fetched once more.
|
||||
kitty-my:
|
||||
type: file
|
||||
path: ./providers/kitty.yaml
|
||||
@ -100,8 +99,7 @@ proxy-providers:
|
||||
# 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).
|
||||
# so the subscription is fetched once more.
|
||||
vpn_host-my:
|
||||
type: file
|
||||
path: ./providers/vpn_host.yaml
|
||||
@ -118,8 +116,7 @@ proxy-providers:
|
||||
# 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).
|
||||
# so the subscription is fetched once more.
|
||||
sub3-my:
|
||||
type: file
|
||||
path: ./providers/sub3.yaml
|
||||
|
||||
@ -77,8 +77,7 @@ proxy-providers:
|
||||
# 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).
|
||||
# so the subscription is fetched once more.
|
||||
example-my:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
@ -97,8 +96,7 @@ proxy-providers:
|
||||
# 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).
|
||||
# so the subscription is fetched once more.
|
||||
example2-my:
|
||||
type: file
|
||||
path: ./providers/example2.yaml
|
||||
|
||||
@ -24,8 +24,7 @@ proxies:
|
||||
|
||||
# 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
|
||||
# front: whitelist and the phone through MY-EXIT, else with UPLINK (CSQTT, pools) through it
|
||||
- {"dialer-proxy": "MY-EXIT", "name":"nl-1","type":"hysteria2","server":"vpn.example.com","port":443,"password":"p","udp":true}
|
||||
|
||||
proxy-providers:
|
||||
@ -72,8 +71,7 @@ proxy-providers:
|
||||
# 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).
|
||||
# so the subscription is fetched once more.
|
||||
example-my:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
@ -92,8 +90,7 @@ proxy-providers:
|
||||
# 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).
|
||||
# so the subscription is fetched once more.
|
||||
example2-my:
|
||||
type: file
|
||||
path: ./providers/example2.yaml
|
||||
|
||||
@ -27,14 +27,12 @@ proxies:
|
||||
|
||||
# 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
|
||||
# front: whitelist and the phone through MY-EXIT, else with UPLINK (CSQTT, pools) through it
|
||||
- {"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:
|
||||
@ -80,8 +78,7 @@ proxy-providers:
|
||||
# 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).
|
||||
# so the subscription is fetched once more.
|
||||
example-my:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
@ -98,8 +95,7 @@ proxy-providers:
|
||||
# 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).
|
||||
# so the subscription is fetched once more.
|
||||
example2-my:
|
||||
type: file
|
||||
path: ./providers/example2.yaml
|
||||
@ -272,7 +268,7 @@ proxy-groups:
|
||||
# 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"]
|
||||
proxies: ["🇩🇪 de 1", "tr \"q\"", "hy-own", "awg-own", "home-hy"]
|
||||
use: [example-my, example2-my]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
|
||||
@ -42,8 +42,7 @@ proxy-providers:
|
||||
# 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).
|
||||
# so the subscription is fetched once more.
|
||||
example-my:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
@ -60,8 +59,7 @@ proxy-providers:
|
||||
# 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).
|
||||
# so the subscription is fetched once more.
|
||||
example2-my:
|
||||
type: file
|
||||
path: ./providers/example2.yaml
|
||||
|
||||
@ -1,366 +0,0 @@
|
||||
proxies:
|
||||
- name: seed
|
||||
type: vless
|
||||
server: 1.2.3.4
|
||||
port: 443
|
||||
uuid: 00000000-0000-0000-0000-000000000000
|
||||
network: tcp
|
||||
udp: true
|
||||
tls: true
|
||||
flow: xtls-rprx-vision
|
||||
servername: eh.vk.ru
|
||||
client-fingerprint: firefox
|
||||
reality-opts:
|
||||
public-key: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
short-id: a1b2
|
||||
|
||||
proxy-providers:
|
||||
example:
|
||||
type: http
|
||||
url: "https://sub.example.com/sub/aaa"
|
||||
path: ./providers/example.yaml
|
||||
interval: 3600
|
||||
proxy: BOOT-AUTO
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
example2:
|
||||
type: http
|
||||
url: "https://sub2.example.com/x?a=1&b=2"
|
||||
path: ./providers/example2.yaml
|
||||
interval: 3600
|
||||
proxy: BOOT-AUTO
|
||||
exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]"
|
||||
header:
|
||||
User-Agent: ["mihomo"]
|
||||
# one check per provider: the groups over it (use:) only add their URLs to it,
|
||||
# so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.
|
||||
# lite: every 10 min and skipped while no traffic used the provider
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
example-my:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
exclude-filter: "^(\\[MY\\] 🇩🇪 de-1 \\(a\\)|\\[MY\\] nl\\.2)$"
|
||||
override:
|
||||
dialer-proxy: MY-EXIT
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# own servers kept in the subscription, named "[MY] ...", for group MY (the main
|
||||
# provider leaves them out); a provider of its own because on whitelist and the
|
||||
# phone they go through MY-EXIT. Router: not a second download, reads the file the
|
||||
# main provider saves (mihomo watches it; ./providers exists before the start,
|
||||
# ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,
|
||||
# so the subscription is fetched once more. Nodes with an entry of their own
|
||||
# (MY_NODE_ENTRIES) are left out here for <id>-my-via-<entry> (providers/16-myvia).
|
||||
example2-my:
|
||||
type: file
|
||||
path: ./providers/example2.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
exclude-filter: "^(\\[MY\\] fi\\x603)$"
|
||||
override:
|
||||
dialer-proxy: MY-EXIT
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# [MY] nodes of example with an entry of their own (LuCI «Свои серверы» → «Вход»):
|
||||
# out of example-my, dialing through FOREIGN in every profile
|
||||
example-my-via-FOREIGN:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
filter: "^(\\[MY\\] 🇩🇪 de-1 \\(a\\)|\\[MY\\] nl\\.2)$"
|
||||
override:
|
||||
dialer-proxy: FOREIGN
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# [MY] nodes of example2 with an entry of their own (LuCI «Свои серверы» → «Вход»):
|
||||
# out of example2-my, dialing through DE in every profile
|
||||
example2-my-via-DE:
|
||||
type: file
|
||||
path: ./providers/example2.yaml
|
||||
filter: "^(\\[MY\\] fi\\x603)$"
|
||||
override:
|
||||
dialer-proxy: DE
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
# example-my for the chains through RU: the same nodes, named "... ⟶ RU"
|
||||
example-my@RU:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
filter: "(?i)\\[MY\\]"
|
||||
override:
|
||||
additional-suffix: " ⟶ RU"
|
||||
dialer-proxy: RU
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 3000
|
||||
lazy: false
|
||||
|
||||
rule-providers:
|
||||
# Russian services (geosite ru-inside of russia-only, as .mrs): an ordinary
|
||||
# http rule-set, so every client fetches it with the config, no geodata setup
|
||||
ru-inside:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/ru-inside.mrs"
|
||||
path: ./ruleset/ru-inside.mrs
|
||||
interval: 86400
|
||||
# Russian services outside ru-inside and outside .ru/.su/.рф (russia-only ru-services):
|
||||
# not on the whitelist, so through RU everywhere but main
|
||||
ru-services:
|
||||
type: http
|
||||
behavior: domain
|
||||
format: mrs
|
||||
url: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/ru-services.mrs"
|
||||
path: ./ruleset/ru-services.mrs
|
||||
interval: 86400
|
||||
|
||||
sniffer:
|
||||
enable: true
|
||||
force-dns-mapping: true
|
||||
parse-pure-ip: true
|
||||
override-destination: false
|
||||
# ECH: browsers show the outer name cloudflare-ech.com instead of the site behind
|
||||
# Cloudflare; the sniffed name wins in the rules, so .ru / own lists would miss the
|
||||
# site. Skipped: the rules see the name from mihomo's DNS (fake-ip / DNS mapping).
|
||||
skip-domain:
|
||||
- "+.cloudflare-ech.com"
|
||||
sniff:
|
||||
HTTP:
|
||||
ports: [80, 8080-8880]
|
||||
TLS:
|
||||
ports: [443, 8443]
|
||||
# lite: no QUIC (fake-ip already gives the domain; pure-IP QUIC goes by IP)
|
||||
QUIC:
|
||||
ports: [443, 8443]
|
||||
|
||||
dns:
|
||||
enable: true
|
||||
ipv6: false
|
||||
respect-rules: true
|
||||
enhanced-mode: fake-ip
|
||||
fake-ip-range: 198.18.0.1/16
|
||||
fake-ip-filter:
|
||||
- '*.lan'
|
||||
- '*.local'
|
||||
- '+.ru'
|
||||
- '+.xn--p1ai'
|
||||
- rule-set:ru-inside
|
||||
|
||||
default-nameserver:
|
||||
- 77.88.8.8
|
||||
- 1.1.1.1
|
||||
|
||||
proxy-server-nameserver:
|
||||
- https://77.88.8.8/dns-query
|
||||
|
||||
direct-nameserver:
|
||||
- 77.88.8.8
|
||||
- 77.88.8.1
|
||||
|
||||
nameserver:
|
||||
- https://1.1.1.1/dns-query
|
||||
- https://dns.google/dns-query
|
||||
|
||||
proxy-groups:
|
||||
# BOOT: whitelisted entry nodes (BOOT_LINKS), the first alive one
|
||||
- name: BOOT
|
||||
type: fallback
|
||||
proxies: [seed]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
# default for downloading subscriptions: BOOT (if set), else the nodes of the
|
||||
# saved subscriptions (providers are cached on disk), else direct. FOREIGN goes
|
||||
# before DIRECT: the health check of DIRECT (gstatic) passes in Russia even when
|
||||
# the subscription site itself is blocked.
|
||||
- name: BOOT-AUTO
|
||||
type: fallback
|
||||
proxies: [BOOT, FOREIGN, DIRECT]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
- name: RU
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
# lite: the provider's URL, so RU nodes are not tested a second time
|
||||
url: "https://ya.ru"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
- name: FOREIGN
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
exclude-filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
- name: TORRENT
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
filter: "(?i)torrent|\\[tor\\]"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
timeout: 6000
|
||||
tolerance: 500
|
||||
max-failed-times: 5
|
||||
lazy: false
|
||||
|
||||
# pool de (POOLS, POOL_*): own servers and subscription nodes picked in the settings;
|
||||
# filter / exclude-filter apply to the subscriptions' nodes only
|
||||
- name: DE
|
||||
type: fallback
|
||||
use: [example]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
# pool mix (POOLS, POOL_*): own servers and subscription nodes picked in the settings;
|
||||
# filter / exclude-filter apply to the subscriptions' nodes only
|
||||
- name: MIX
|
||||
type: fallback
|
||||
use: [example-my, example-my-via-FOREIGN]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
lazy: false
|
||||
|
||||
# pool svc-fixed-claude (POOLS, POOL_*): own servers and subscription nodes picked in the settings;
|
||||
# filter / exclude-filter apply to the subscriptions' nodes only
|
||||
- name: SVC-FIXED-CLAUDE
|
||||
type: select
|
||||
empty-fallback: REJECT
|
||||
use: [example-my, example-my-via-FOREIGN]
|
||||
filter: "^\\[MY\\] nl\\.2$"
|
||||
|
||||
# own servers: those of the settings (proxies/30-own_srv) and the "[MY] ..." nodes of
|
||||
# the subscriptions (providers <id>-my); the fastest alive one; pin one in the dashboard if needed
|
||||
- name: MY
|
||||
type: url-test
|
||||
use: [example-my, example-my-via-FOREIGN, example2-my, example2-my-via-DE]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
lazy: false
|
||||
|
||||
# whitelist and mobile (my_exit): what own servers are reached through; switches only when the node is
|
||||
# clearly worse or dead (each switch breaks everything going through MY)
|
||||
- name: MY-EXIT
|
||||
type: url-test
|
||||
use: [example, example2]
|
||||
exclude-filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск"
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
tolerance: 300
|
||||
lazy: false
|
||||
|
||||
# service claude (SERVICES, SVC_*): its own way, whatever MAIN is
|
||||
- name: CLAUDE
|
||||
type: select
|
||||
proxies: ["SVC-FIXED-CLAUDE ⟶ RU"]
|
||||
|
||||
# SVC-FIXED-CLAUDE through RU (SVC_<NAME>_CHAIN, POOL_<NAME>_UPLINK): its servers and
|
||||
# nodes, each dialing through RU
|
||||
- name: "SVC-FIXED-CLAUDE ⟶ RU"
|
||||
type: select
|
||||
empty-fallback: REJECT
|
||||
use: [example-my@RU]
|
||||
filter: "^\\[MY\\] nl\\.2 ⟶ RU$"
|
||||
|
||||
- name: MAIN
|
||||
type: select
|
||||
proxies: [FOREIGN, MY, RU, DIRECT]
|
||||
|
||||
- name: TORRENT-SEL
|
||||
type: select
|
||||
proxies: [TORRENT, FOREIGN, DIRECT]
|
||||
|
||||
- name: PUSH
|
||||
type: select
|
||||
# no own servers in the settings: MY may be empty (no [MY] nodes in the subscriptions)
|
||||
proxies: [FOREIGN, MY, DIRECT]
|
||||
|
||||
rules:
|
||||
- IP-CIDR,192.168.0.0/16,DIRECT,no-resolve
|
||||
- IP-CIDR,10.0.0.0/8,DIRECT,no-resolve
|
||||
- IP-CIDR,172.16.0.0/12,DIRECT,no-resolve
|
||||
|
||||
# push notifications (Apple APNs, Google FCM): long-lived connections on a
|
||||
# stable path - group PUSH (main/foreign: DIRECT, whitelist: MY)
|
||||
- DOMAIN-SUFFIX,push.apple.com,PUSH
|
||||
- IP-CIDR,17.249.0.0/16,PUSH,no-resolve
|
||||
- IP-CIDR,17.252.0.0/16,PUSH,no-resolve
|
||||
- IP-CIDR,17.57.144.0/22,PUSH,no-resolve
|
||||
- IP-CIDR,17.188.128.0/18,PUSH,no-resolve
|
||||
- IP-CIDR,17.188.20.0/23,PUSH,no-resolve
|
||||
- DOMAIN-REGEX,^(alt[0-9]+-)?mtalk[0-9]*\.google\.com$,PUSH
|
||||
- DST-PORT,5228-5230,PUSH
|
||||
|
||||
# service claude: above the own lists, below the tunnels, LAN and push
|
||||
- DOMAIN-SUFFIX,claude.ai,CLAUDE
|
||||
|
||||
# own lists from the settings: above torrents, ru-inside, .ru and MATCH; below the
|
||||
# tunnels, LAN and push. Domains (DOMAIN-SUFFIX: the domain and all subdomains)
|
||||
# before IPs; first match wins: MY, then FOREIGN, then RU.
|
||||
# RU on main (home, own white IP): reachable directly; whitelist/abroad: through RU
|
||||
- IP-CIDR,194.190.191.112/32,RU
|
||||
|
||||
- SRC-PORT,20000-20199,TORRENT-SEL
|
||||
|
||||
- RULE-SET,ru-inside,DIRECT
|
||||
# main (home, own white IP): ru-services and .ru/.su/.рф directly; elsewhere through RU
|
||||
- RULE-SET,ru-services,RU
|
||||
- DOMAIN-SUFFIX,ru,RU
|
||||
- DOMAIN-SUFFIX,su,RU
|
||||
- DOMAIN-SUFFIX,xn--p1ai,RU
|
||||
- MATCH,MAIN
|
||||
@ -32,13 +32,11 @@ proxies:
|
||||
|
||||
# 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
|
||||
# front: whitelist and the phone through MY-EXIT, else with UPLINK (CSQTT, pools) through it
|
||||
- {"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>")
|
||||
@ -48,7 +46,6 @@ proxies:
|
||||
- {"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:
|
||||
@ -98,8 +95,7 @@ proxy-providers:
|
||||
# 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).
|
||||
# so the subscription is fetched once more.
|
||||
example-my:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
@ -118,8 +114,7 @@ proxy-providers:
|
||||
# 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).
|
||||
# so the subscription is fetched once more.
|
||||
example2-my:
|
||||
type: file
|
||||
path: ./providers/example2.yaml
|
||||
@ -276,20 +271,6 @@ rule-providers:
|
||||
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
|
||||
@ -426,7 +407,7 @@ proxy-groups:
|
||||
# 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"]
|
||||
proxies: ["🇩🇪 de 1", "tr \"q\"", "hy-own", "awg-own"]
|
||||
use: [example-my, example2-my, my-links]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
@ -454,11 +435,6 @@ proxy-groups:
|
||||
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"
|
||||
@ -486,7 +462,7 @@ proxy-groups:
|
||||
# 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"]
|
||||
proxies: ["🇩🇪 de 1 ⟶ FOREIGN", "tr \"q\" ⟶ FOREIGN", "hy-own ⟶ FOREIGN", "awg-own ⟶ FOREIGN"]
|
||||
use: [example-my@FOREIGN, example2-my@FOREIGN, my-links@FOREIGN]
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300
|
||||
@ -549,9 +525,6 @@ rules:
|
||||
- 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.
|
||||
|
||||
@ -31,8 +31,7 @@ proxies:
|
||||
|
||||
# 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
|
||||
# front: whitelist and the phone through MY-EXIT, else with UPLINK (CSQTT, pools) through it
|
||||
- {"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}
|
||||
|
||||
@ -80,8 +79,7 @@ proxy-providers:
|
||||
# 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).
|
||||
# so the subscription is fetched once more.
|
||||
example-my:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
@ -100,8 +98,7 @@ proxy-providers:
|
||||
# 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).
|
||||
# so the subscription is fetched once more.
|
||||
example2-my:
|
||||
type: file
|
||||
path: ./providers/example2.yaml
|
||||
|
||||
@ -28,8 +28,7 @@ proxies:
|
||||
|
||||
# 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
|
||||
# front: whitelist and the phone through MY-EXIT, else with UPLINK (CSQTT, pools) through it
|
||||
- {"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}
|
||||
|
||||
@ -77,8 +76,7 @@ proxy-providers:
|
||||
# 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).
|
||||
# so the subscription is fetched once more.
|
||||
example-my:
|
||||
type: file
|
||||
path: ./providers/example.yaml
|
||||
@ -97,8 +95,7 @@ proxy-providers:
|
||||
# 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).
|
||||
# so the subscription is fetched once more.
|
||||
example2-my:
|
||||
type: file
|
||||
path: ./providers/example2.yaml
|
||||
|
||||
1
tests/fixtures/own.servers
vendored
1
tests/fixtures/own.servers
vendored
@ -2,4 +2,3 @@
|
||||
{"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"}
|
||||
|
||||
13
tests/fixtures/router-myvia.env
vendored
13
tests/fixtures/router-myvia.env
vendored
@ -1,13 +0,0 @@
|
||||
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'
|
||||
4
tests/fixtures/router-whitelist-ts-my.env
vendored
4
tests/fixtures/router-whitelist-ts-my.env
vendored
@ -3,7 +3,7 @@ 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"
|
||||
SERVICES="claude chat"
|
||||
SVC_CLAUDE_GEOSITE=anthropic
|
||||
SVC_CLAUDE_VIA=DE
|
||||
SVC_CLAUDE_CHAIN=WL
|
||||
@ -12,8 +12,6 @@ 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'
|
||||
|
||||
Binary file not shown.
@ -1,11 +0,0 @@
|
||||
# zapret hostlist
|
||||
youtube.com
|
||||
YouTu.be
|
||||
googlevideo.com # video
|
||||
|
||||
^exact.example
|
||||
*.wild.example
|
||||
.dot.example
|
||||
youtube.com
|
||||
bad domain!
|
||||
1.2.3.4
|
||||
@ -233,7 +233,7 @@
|
||||
},
|
||||
{
|
||||
"name": "hu",
|
||||
"network": "ws",
|
||||
"network": "httpupgrade",
|
||||
"port": "443",
|
||||
"server": "example.com",
|
||||
"type": "vless",
|
||||
@ -246,7 +246,6 @@
|
||||
"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
|
||||
@ -456,7 +455,7 @@
|
||||
"alterId": 0,
|
||||
"cipher": "auto",
|
||||
"name": "hu-01",
|
||||
"network": "ws",
|
||||
"network": "httpupgrade",
|
||||
"port": "443",
|
||||
"server": "v.example.com",
|
||||
"skip-cert-verify": false,
|
||||
@ -468,7 +467,6 @@
|
||||
"early-data-header-name": "X",
|
||||
"headers": {},
|
||||
"path": "/u?eh=X",
|
||||
"v2ray-http-upgrade": true,
|
||||
"v2ray-http-upgrade-fast-open": true
|
||||
},
|
||||
"xudp": true
|
||||
@ -530,24 +528,6 @@
|
||||
"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",
|
||||
|
||||
@ -28,7 +28,6 @@ vmess://eyJ2IjoiMiIsImFkZCI6Im5vbmFtZS5leGFtcGxlLmNvbSIsInBvcnQiOiI0NDMiLCJpZCI6
|
||||
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
|
||||
|
||||
@ -1,103 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Mirror an OpenWrt-nikki release into the kit repo's releases: the router installs
|
||||
# nikki from there (router/mihomo-kit.sh nikki_feed), GitHub is often unreachable.
|
||||
# GITEA_TOKEN=... tools/nikki-mirror.sh [v1.26.2|latest] [arch...]
|
||||
# Each nikki_<arch>-openwrt-24.10.tar.gz is a signed opkg feed; it is repacked without
|
||||
# mihomo-alpha and the zh translations (less RAM on the router, Packages and its
|
||||
# signature unchanged) and uploaded to the release nikki-<version>, made if missing.
|
||||
# No arch = all of the release. Assets already there are skipped.
|
||||
# Then set NIKKI_VERSION in router/mihomo-kit.sh and push the kit.
|
||||
# Needs curl, jq, tar, gzip.
|
||||
set -eu
|
||||
ver=${1:-latest}
|
||||
[ $# -gt 0 ] && shift
|
||||
: "${GITEA_TOKEN:?set GITEA_TOKEN (Settings -> Applications, scope write:repository)}"
|
||||
GITEA=${GITEA:-https://git.sam-hub.net}
|
||||
REPO=${REPO:-sam/mihomo-kit}
|
||||
UPSTREAM=nikkinikki-org/OpenWrt-nikki
|
||||
BRANCH=openwrt-24.10
|
||||
cd "$(dirname "$0")"
|
||||
work=$(pwd)/nikki-work
|
||||
rm -rf "$work"
|
||||
mkdir -p "$work"
|
||||
trap 'rm -rf "$work"' EXIT
|
||||
|
||||
if [ "$ver" = latest ]; then
|
||||
api=https://api.github.com/repos/$UPSTREAM/releases/latest
|
||||
else
|
||||
api=https://api.github.com/repos/$UPSTREAM/releases/tags/$ver
|
||||
fi
|
||||
curl -fsSL "$api" > "$work/upstream.json"
|
||||
ver=$(jq -r .tag_name "$work/upstream.json")
|
||||
tag=nikki-$ver
|
||||
echo "upstream $ver -> $GITEA/$REPO release $tag"
|
||||
|
||||
# the token through a config file, not argv (ps); timeouts: an upload may stall
|
||||
umask 077
|
||||
printf 'header = "Authorization: token %s"\n' "$GITEA_TOKEN" > "$work/curlrc"
|
||||
gitea() { curl -K "$work/curlrc" -fsS --connect-timeout 20 "$@"; }
|
||||
api=$GITEA/api/v1/repos/$REPO
|
||||
|
||||
if ! gitea -m 60 "$api/releases/tags/$tag" > "$work/release.json" 2>/dev/null; then
|
||||
jq -n --arg t "$tag" --arg v "$ver" '{tag_name: $t, name: $t, target_commitish: "main",
|
||||
body: ("Зеркало https://github.com/nikkinikki-org/OpenWrt-nikki/releases/tag/" + $v +
|
||||
" для установки nikki на роутер (без mihomo-alpha и переводов zh).")}' |
|
||||
gitea -m 60 -X POST -H 'Content-Type: application/json' -d @- \
|
||||
"$api/releases" > "$work/release.json"
|
||||
echo "created release $tag"
|
||||
fi
|
||||
id=$(jq -r .id "$work/release.json")
|
||||
have=$(jq -r '.assets[]?.name' "$work/release.json")
|
||||
|
||||
jq -r --arg b "$BRANCH" '.assets[] | select(.name | endswith("-" + $b + ".tar.gz")) |
|
||||
"\(.name) \(.browser_download_url)"' "$work/upstream.json" > "$work/list"
|
||||
if [ $# -gt 0 ]; then
|
||||
for a in "$@"; do grep "^nikki_$a-$BRANCH.tar.gz " "$work/list" || echo "warning: no bundle for $a" >&2; done \
|
||||
> "$work/list.sel"
|
||||
mv "$work/list.sel" "$work/list"
|
||||
fi
|
||||
[ -s "$work/list" ] || { echo "nothing to mirror" >&2; exit 1; }
|
||||
|
||||
while read -r name url; do
|
||||
if printf '%s\n' "$have" | grep -qx "$name"; then
|
||||
echo "$name: already there"
|
||||
continue
|
||||
fi
|
||||
echo "$name: downloading"
|
||||
d=$work/b
|
||||
rm -rf "$d"
|
||||
mkdir -p "$d"
|
||||
curl -fSL --connect-timeout 20 -m 600 --retry 3 --progress-bar "$url" | tar xzf - -C "$d"
|
||||
[ -f "$d/Packages.gz" ] && [ -f "$d/Packages.sig" ] || { echo "$name: not a feed" >&2; exit 1; }
|
||||
rm -f "$d"/mihomo-alpha_*.ipk "$d"/luci-i18n-nikki-zh-*.ipk
|
||||
# ustar, no owner names: busybox tar on the router
|
||||
(cd "$d" && tar --format ustar --owner 0 --group 0 -cf - .) | gzip -9 > "$work/$name"
|
||||
size=$(wc -c < "$work/$name")
|
||||
ok=
|
||||
for try in 1 2 3; do
|
||||
echo "$name: uploading $(du -h "$work/$name" | cut -f1) (try $try)"
|
||||
# progress bar on the terminal, then the average speed
|
||||
curl -K "$work/curlrc" -fS --connect-timeout 20 -m 600 --progress-bar -o /dev/null \
|
||||
-w '%{time_total} %{speed_upload}\n' \
|
||||
-X POST -F "attachment=@$work/$name" "$api/releases/$id/assets?name=$name" |
|
||||
awk -v n="$name" '{printf "%s: sent in %ds, %.2f MB/s\n", n, $1, $2 / 1048576}' || true
|
||||
# what the server has now: right size = done, anything else = remove and retry
|
||||
gitea -m 60 "$api/releases/$id/assets" > "$work/assets.json" || continue
|
||||
jq -r --arg n "$name" --argjson s "$size" '.[] | select(.name == $n) |
|
||||
"\(.id) \(if .size == $s then "ok" else "bad" end)"' "$work/assets.json" > "$work/same"
|
||||
if grep -q ' ok$' "$work/same"; then
|
||||
# a stalled try may have landed too: keep one copy
|
||||
grep ' ok$' "$work/same" | tail -n +2 | while read -r a _; do
|
||||
gitea -m 60 -X DELETE "$api/releases/$id/assets/$a"; done
|
||||
ok=1
|
||||
break
|
||||
fi
|
||||
while read -r a _; do gitea -m 60 -X DELETE "$api/releases/$id/assets/$a"; done < "$work/same"
|
||||
done
|
||||
rm -f "$work/$name"
|
||||
[ -n "$ok" ] || { echo "$name: upload failed 3 times, run again later" >&2; exit 1; }
|
||||
done < "$work/list"
|
||||
|
||||
echo "done: $GITEA/$REPO/releases/tag/$tag"
|
||||
grep -q "^NIKKI_VERSION=$ver\$" ../router/mihomo-kit.sh ||
|
||||
echo "now set NIKKI_VERSION=$ver in router/mihomo-kit.sh and push the kit"
|
||||
@ -44,9 +44,9 @@ for (const f of fs.readdirSync(path.join(root, "amnezia"))) {
|
||||
check("amnezia/" + f, JSON.parse(fs.readFileSync(exp, "utf8")),
|
||||
s.parseText(fs.readFileSync(path.join(root, "amnezia", f), "utf8"), f.replace(/\.[^.]+$/, "")));
|
||||
}
|
||||
// a stored line reads back the same (dialer-proxy: the server's own entry), with no "$" left
|
||||
// a stored line reads back the same, without dialer-proxy, with no "$" left
|
||||
const p = { name: "a$b", type: "ss", server: "h", port: 1, password: "x${Y}", "dialer-proxy": "Z" };
|
||||
const line = s.toLine(p);
|
||||
check("toLine", { name: "a$b", type: "ss", server: "h", port: 1, password: "x${Y}", "dialer-proxy": "Z" },
|
||||
check("toLine", { name: "a$b", type: "ss", server: "h", port: 1, password: "x${Y}" },
|
||||
line.includes("$") || !line.startsWith('{"name":') ? null : JSON.parse(line));
|
||||
process.exit(fail);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user