Added auto update, added auto boot nodes, fixed push
This commit is contained in:
parent
9fcc2a6fca
commit
736ab15790
32
README.md
32
README.md
@ -22,7 +22,7 @@ ssh root@192.168.32.1 sh /etc/nikki/kit/install.sh
|
|||||||
Установщик ставит nikki (если нет), правильное ядро, фиксы и kit со страницей LuCI —
|
Установщик ставит nikki (если нет), правильное ядро, фиксы и kit со страницей LuCI —
|
||||||
ничего не спрашивает. Дальше всё в браузере: LuCI → **Службы → mihomo-kit → Настройка**
|
ничего не спрашивает. Дальше всё в браузере: LuCI → **Службы → mihomo-kit → Настройка**
|
||||||
(адрес установщик печатает в конце; если пункта нет — выйти из LuCI и войти снова).
|
(адрес установщик печатает в конце; если пункта нет — выйти из LuCI и войти снова).
|
||||||
Там подписки, vless-ссылка BOOT, торренты, OpenVPN (файл `.ovpn`, логин, пароль,
|
Там подписки, vless-ссылки BOOT, торренты, OpenVPN (файл `.ovpn`, логин, пароль,
|
||||||
TOTP-секрет), Tailscale; «Сохранить и применить» собирает профили `home` и `street`,
|
TOTP-секрет), Tailscale; «Сохранить и применить» собирает профили `home` и `street`,
|
||||||
включает профиль и, если включён Tailscale, показывает ссылку для входа — открыть её,
|
включает профиль и, если включён Tailscale, показывает ссылку для входа — открыть её,
|
||||||
войти, в админке Tailscale **Disable key expiry** для ноды.
|
войти, в админке Tailscale **Disable key expiry** для ноды.
|
||||||
@ -44,6 +44,12 @@ TOTP-секрет), Tailscale; «Сохранить и применить» со
|
|||||||
профиля, OpenVPN вкл/выкл/переподключить с текущим OTP, ссылка для входа в Tailscale,
|
профиля, OpenVPN вкл/выкл/переподключить с текущим OTP, ссылка для входа в Tailscale,
|
||||||
пересборка, обновление kit и `fix`; вывод команды показывается внизу страницы.
|
пересборка, обновление kit и `fix`; вывод команды показывается внизу страницы.
|
||||||
|
|
||||||
|
Автообновление — «Включить автообновление» там же (или `mihomo-kit.sh auto-update on|off`):
|
||||||
|
cron каждый день в 4:00 по времени роутера (часовой пояс — Система → Система) проверяет
|
||||||
|
коммит на сервере; если он новее — скачивает kit, пересобирает профили, при смене версии
|
||||||
|
ядра делает `fix` и перезапускает текущий профиль. Журнал — `/etc/nikki/kit/auto-update.log`,
|
||||||
|
последняя строка видна на странице.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
mihomo-kit.sh use street # уехал на белые списки
|
mihomo-kit.sh use street # уехал на белые списки
|
||||||
mihomo-kit.sh use home # вернулся
|
mihomo-kit.sh use home # вернулся
|
||||||
@ -84,19 +90,35 @@ mihomo-kit.sh build # после правки /etc/nikki/profiles.d/*.
|
|||||||
её настройки. Имя берётся из домена: `https://sub.kittyvpn.com/…` → `kittyvpn`
|
её настройки. Имя берётся из домена: `https://sub.kittyvpn.com/…` → `kittyvpn`
|
||||||
(`a.b.co.uk` → `b`, повтор домена → `kittyvpn2`); своё имя — словом `имя=https://…` в
|
(`a.b.co.uk` → `b`, повтор домена → `kittyvpn2`); своё имя — словом `имя=https://…` в
|
||||||
`SUBS`. Настройки — `SUB_<ИМЯ>_*` в `common.env` (имя заглавными, `-` → `_`): через что
|
`SUBS`. Настройки — `SUB_<ИМЯ>_*` в `common.env` (имя заглавными, `-` → `_`): через что
|
||||||
качать (`SUB_KITTYVPN_PROXY=DIRECT`, `BOOT` или `FOREIGN` — через ноды других подписок), User-Agent (`_UA`), доп. заголовки (`_HEADERS`) и
|
качать (`SUB_KITTYVPN_PROXY=`: по умолчанию `BOOT-AUTO`, ещё `BOOT`, `DIRECT`, `FOREIGN` — через
|
||||||
|
ноды других подписок), User-Agent (`_UA`), доп. заголовки (`_HEADERS`) и
|
||||||
HWID для подписок с лимитом устройств (`SUB_KITTYVPN_HWID=1` + общий блок `HWID_*`:
|
HWID для подписок с лимитом устройств (`SUB_KITTYVPN_HWID=1` + общий блок `HWID_*`:
|
||||||
x-device-os, x-ver-os, x-device-model, x-hwid). Порядок подписок в `SUBS` поэтому не
|
x-device-os, x-ver-os, x-device-model, x-hwid). Выключить, не удаляя:
|
||||||
|
`SUB_KITTYVPN_DISABLED=1` или галка «вкл» в форме — подписка с настройками остаётся в
|
||||||
|
списке, но в провайдеры и группы не попадает. Порядок подписок в `SUBS` поэтому не
|
||||||
важен. Старые ключи по номеру (`SUB1_UA`) ещё читаются; сохранение из LuCI или мастера
|
важен. Старые ключи по номеру (`SUB1_UA`) ещё читаются; сохранение из LuCI или мастера
|
||||||
переименовывает их по имени. Если провайдер сменит домен, сменится и имя — задай его
|
переименовывает их по имени. Если провайдер сменит домен, сменится и имя — задай его
|
||||||
явно, чтобы настройки не потерялись.
|
явно, чтобы настройки не потерялись.
|
||||||
|
|
||||||
|
BOOT — whitelisted seed-ноды для скачивания подписок: в форме vless-ссылки по одной на
|
||||||
|
строку (`BOOT_LINKS` в `common.env`; старые `BOOT_SERVER`/`_PBK`/… читаются как одна
|
||||||
|
нода). Из них собираются `seed`, `seed2`, …, группа `BOOT` (fallback) берёт первую живую.
|
||||||
|
`BOOT-AUTO` — то, через что подписки качаются по умолчанию: `BOOT`, если ни одна seed не
|
||||||
|
отвечает — ноды уже скачанных подписок (mihomo хранит их в
|
||||||
|
`/etc/nikki/run/providers/<имя>.yaml` и загружает при старте), в последнюю очередь напрямую.
|
||||||
|
|
||||||
|
Пуши (Apple `*.push.apple.com` и подсети 17.x, Google FCM `mtalk.google.com`, порты
|
||||||
|
5228–5230) идут через группу `PUSH`: на `home` по умолчанию `DIRECT`, на `street` — `MY`
|
||||||
|
(без своих серверов — `FOREIGN`); переключается в дашборде. Долгое соединение пушей
|
||||||
|
рвётся, когда меняется нода под ним, — отсюда пропадающие уведомления.
|
||||||
|
|
||||||
Свои серверы hysteria2 — LuCI → Настройка → «Свои серверы» (или `HY2="имя1 имя2"` и
|
Свои серверы hysteria2 — LuCI → Настройка → «Свои серверы» (или `HY2="имя1 имя2"` и
|
||||||
`HY2_<ИМЯ>_SERVER/_PORT/_PASSWORD/_OBFS_PASSWORD/_SNI/_INSECURE/_UP/_DOWN` в
|
`HY2_<ИМЯ>_SERVER/_PORT/_PASSWORD/_OBFS_PASSWORD/_SNI/_INSECURE/_UP/_DOWN` в
|
||||||
`common.env`). Они собираются в группу `MY` (url-test: самый быстрый живой; в дашборде
|
`common.env`). Они собираются в группу `MY` (url-test: самый быстрый живой; в дашборде
|
||||||
можно закрепить конкретный). `MY` — пункт в `MAIN` рядом с `FOREIGN` (переключать
|
можно закрепить конкретный). `MY` — пункт в `MAIN` рядом с `FOREIGN` (переключать
|
||||||
вручную). К самим серверам на `street` подключение через ноду `FOREIGN`
|
вручную). К самим серверам на `street` подключение через группу `MY-EXIT` (те же ноды,
|
||||||
(`dialer-proxy`), на `home` — напрямую.
|
что в `FOREIGN`, но с `tolerance: 300`: меняет ноду, только если текущая заметно хуже или
|
||||||
|
умерла — каждая смена рвёт всё, что идёт через `MY`), на `home` — напрямую.
|
||||||
|
|
||||||
Проверка туннелей: у групп `BMSTU` и `TAILSCALE` свой адрес проверки — LuCI → Настройка
|
Проверка туннелей: у групп `BMSTU` и `TAILSCALE` свой адрес проверки — LuCI → Настройка
|
||||||
(«Адрес для проверки» в блоках OpenVPN и Tailscale) или `OVPN_CHECK_URL` (по умолчанию
|
(«Адрес для проверки» в блоках OpenVPN и Tailscale) или `OVPN_CHECK_URL` (по умолчанию
|
||||||
|
|||||||
@ -273,6 +273,12 @@ return view.extend({
|
|||||||
E('table', { 'class': 'table' }, [
|
E('table', { 'class': 'table' }, [
|
||||||
row(this.button('Пересобрать профили', 'action', 'build'),
|
row(this.button('Пересобрать профили', 'action', 'build'),
|
||||||
'profiles.d/*.env → profiles/*.yaml (применится после «Включить» профиль)'),
|
'profiles.d/*.env → profiles/*.yaml (применится после «Включить» профиль)'),
|
||||||
|
row(st.auto_update
|
||||||
|
? this.button('Выключить автообновление', 'negative', 'autoupdate-off')
|
||||||
|
: this.button('Включить автообновление', 'positive', 'autoupdate-on'),
|
||||||
|
[ st.auto_update ? E('strong', 'включено') : 'выключено',
|
||||||
|
': каждый день в 4:00 (время роутера), если на сервере новый коммит — обновить kit и перезапустить профиль',
|
||||||
|
st.auto_update_last ? E('div', { 'class': 'cbi-value-description' }, 'последний запуск: ' + st.auto_update_last) : '' ]),
|
||||||
row(this.button('Обновить kit', 'action', 'update', null,
|
row(this.button('Обновить kit', 'action', 'update', null,
|
||||||
'Скачать свежий kit и пересобрать профили?'),
|
'Скачать свежий kit и пересобрать профили?'),
|
||||||
'шаблоны, скрипты и эта страница; после обновления LuCI может попросить войти заново'),
|
'шаблоны, скрипты и эта страница; после обновления LuCI может попросить войти заново'),
|
||||||
@ -301,7 +307,8 @@ return view.extend({
|
|||||||
var hwidBox = E('div'), ovpnBox = E('div'), tsBox = E('div');
|
var hwidBox = E('div'), ovpnBox = E('div'), tsBox = E('div');
|
||||||
|
|
||||||
var f = {
|
var f = {
|
||||||
boot: text(cfg.boot_link, 'vless://…'),
|
boot: E('textarea', { 'class': 'cbi-input-textarea', 'rows': 3, 'style': 'width:100%;font-family:monospace',
|
||||||
|
'placeholder': 'vless://…\nvless://… (по одной на строку)' }, cfg.boot_links || ''),
|
||||||
hwid_ua: text(cfg.hwid_ua), hwid_os: text(cfg.hwid_os), hwid_os_ver: text(cfg.hwid_os_ver),
|
hwid_ua: text(cfg.hwid_ua), hwid_os: text(cfg.hwid_os), hwid_os_ver: text(cfg.hwid_os_ver),
|
||||||
hwid_model: text(cfg.hwid_model), hwid_id: text(cfg.hwid_id),
|
hwid_model: text(cfg.hwid_model), hwid_id: text(cfg.hwid_id),
|
||||||
torrent: check(cfg.torrent),
|
torrent: check(cfg.torrent),
|
||||||
@ -325,18 +332,20 @@ return view.extend({
|
|||||||
};
|
};
|
||||||
|
|
||||||
var addSub = function(s) {
|
var addSub = function(s) {
|
||||||
var vias = [ 'BOOT', 'DIRECT', 'FOREIGN' ];
|
var vias = [ 'BOOT-AUTO', 'BOOT', 'DIRECT', 'FOREIGN' ];
|
||||||
if (s.via && vias.indexOf(s.via) < 0)
|
if (s.via && vias.indexOf(s.via) < 0)
|
||||||
vias.push(s.via);
|
vias.push(s.via);
|
||||||
var entry = {
|
var entry = {
|
||||||
url: E('input', { 'type': 'text', 'class': 'cbi-input-text', 'style': 'flex:1;min-width:16em',
|
url: E('input', { 'type': 'text', 'class': 'cbi-input-text', 'style': 'flex:1;min-width:16em',
|
||||||
'value': s.url || '', 'placeholder': 'https://…' }),
|
'value': s.url || '', 'placeholder': 'https://…' }),
|
||||||
via: E('select', { 'class': 'cbi-input-select' }, vias.map(function(v) { return E('option', { 'value': v }, v); })),
|
via: E('select', { 'class': 'cbi-input-select' }, vias.map(function(v) { return E('option', { 'value': v }, v); })),
|
||||||
hwid: check(s.hwid)
|
hwid: check(s.hwid),
|
||||||
|
enabled: check(s.enabled !== false)
|
||||||
};
|
};
|
||||||
entry.via.value = s.via || 'BOOT';
|
entry.via.value = s.via || 'BOOT-AUTO';
|
||||||
entry.hwid.addEventListener('change', update);
|
entry.hwid.addEventListener('change', update);
|
||||||
var el = E('div', { 'style': 'display:flex;gap:.5em;align-items:center;flex-wrap:wrap;margin-bottom:.4em' }, [
|
var el = E('div', { 'style': 'display:flex;gap:.5em;align-items:center;flex-wrap:wrap;margin-bottom:.4em' }, [
|
||||||
|
E('label', { 'title': 'выключенная остаётся в списке, но не попадает в профиль' }, [ entry.enabled, ' вкл' ]),
|
||||||
entry.url, E('code', { 'title': 'имя провайдера' }, s.id || 'новая'), 'через', entry.via,
|
entry.url, E('code', { 'title': 'имя провайдера' }, s.id || 'новая'), 'через', entry.via,
|
||||||
E('label', [ entry.hwid, ' HWID' ]),
|
E('label', [ entry.hwid, ' HWID' ]),
|
||||||
E('button', { 'class': 'btn cbi-button cbi-button-remove', 'click': function() {
|
E('button', { 'class': 'btn cbi-button cbi-button-remove', 'click': function() {
|
||||||
@ -452,13 +461,15 @@ return view.extend({
|
|||||||
'class': 'btn cbi-button cbi-button-save',
|
'class': 'btn cbi-button cbi-button-save',
|
||||||
'click': ui.createHandlerFn(this, function() {
|
'click': ui.createHandlerFn(this, function() {
|
||||||
var list = subs.map(function(s) {
|
var list = subs.map(function(s) {
|
||||||
return { url: s.url.value.trim(), via: s.via.value, hwid: s.hwid.checked };
|
return { url: s.url.value.trim(), via: s.via.value, hwid: s.hwid.checked, enabled: s.enabled.checked };
|
||||||
}).filter(function(s) { return s.url; });
|
}).filter(function(s) { return s.url; });
|
||||||
var errors = [];
|
var errors = [];
|
||||||
if (!list.length)
|
if (!list.some(function(s) { return s.enabled; }))
|
||||||
errors.push('нужна хотя бы одна подписка');
|
errors.push('нужна хотя бы одна включённая подписка');
|
||||||
if (f.boot.value.trim() && !/^vless:\/\//.test(f.boot.value.trim()))
|
f.boot.value.split(/\s+/).filter(Boolean).forEach(function(l) {
|
||||||
errors.push('BOOT: нужна ссылка vless://');
|
if (!/^vless:\/\/[^@]+@[^?]+\?.*\bpbk=/.test(l))
|
||||||
|
errors.push('BOOT: не похоже на vless-ссылку с reality (нужны host, pbk, sid): ' + l.slice(0, 40) + '…');
|
||||||
|
});
|
||||||
if (f.openvpn.checked) {
|
if (f.openvpn.checked) {
|
||||||
if (!cfg.ovpn_file && !f.ovpn.files.length)
|
if (!cfg.ovpn_file && !f.ovpn.files.length)
|
||||||
errors.push('OpenVPN: выбери файл .ovpn');
|
errors.push('OpenVPN: выбери файл .ovpn');
|
||||||
@ -490,7 +501,7 @@ return view.extend({
|
|||||||
}
|
}
|
||||||
return readFile(f.ovpn).then(L.bind(function(ovpn) {
|
return readFile(f.ovpn).then(L.bind(function(ovpn) {
|
||||||
return callConfigSet({
|
return callConfigSet({
|
||||||
boot_link: f.boot.value.trim(),
|
boot_links: f.boot.value.trim(),
|
||||||
subs: list,
|
subs: list,
|
||||||
hwid_ua: f.hwid_ua.value, hwid_os: f.hwid_os.value, hwid_os_ver: f.hwid_os_ver.value,
|
hwid_ua: f.hwid_ua.value, hwid_os: f.hwid_os.value, hwid_os_ver: f.hwid_os_ver.value,
|
||||||
hwid_model: f.hwid_model.value, hwid_id: f.hwid_id.value,
|
hwid_model: f.hwid_model.value, hwid_id: f.hwid_id.value,
|
||||||
@ -523,7 +534,8 @@ return view.extend({
|
|||||||
|
|
||||||
dom.content(this.settingsBox, [
|
dom.content(this.settingsBox, [
|
||||||
E('h3', 'Настройка'),
|
E('h3', 'Настройка'),
|
||||||
field('BOOT', f.boot, 'vless-ссылка seed-ноды, через неё качаются подписки; пусто — без BOOT'),
|
field('BOOT', f.boot, 'vless-ссылки seed-нод, по одной на строку: группа BOOT берёт первую живую, ' +
|
||||||
|
'через неё качаются подписки (BOOT-AUTO: BOOT, иначе сохранённые ноды подписок, иначе напрямую); пусто — без BOOT'),
|
||||||
field('Подписки', [ subList, E('button', {
|
field('Подписки', [ subList, E('button', {
|
||||||
'class': 'btn cbi-button cbi-button-add',
|
'class': 'btn cbi-button cbi-button-add',
|
||||||
'click': function() { addSub({}); update(); }
|
'click': function() { addSub({}); update(); }
|
||||||
|
|||||||
35
luci/rpcd.sh
35
luci/rpcd.sh
@ -70,6 +70,8 @@ m_status() {
|
|||||||
json_add_boolean tailscale "$(b test "$(envval TAILSCALE "$prof")" = 1)"
|
json_add_boolean tailscale "$(b test "$(envval TAILSCALE "$prof")" = 1)"
|
||||||
json_add_boolean ts_logged_in "$(b grep -q _current-profile "$NIKKI_DIR/run/tailscale/tailscaled.state")"
|
json_add_boolean ts_logged_in "$(b grep -q _current-profile "$NIKKI_DIR/run/tailscale/tailscaled.state")"
|
||||||
json_add_string kit_version "$(cat "$NIKKI_DIR/kit/VERSION" 2>/dev/null)"
|
json_add_string kit_version "$(cat "$NIKKI_DIR/kit/VERSION" 2>/dev/null)"
|
||||||
|
json_add_boolean auto_update "$(b grep -q 'mihomo-kit.sh auto-update' /etc/crontabs/root)"
|
||||||
|
json_add_string auto_update_last "$(tail -n 1 "$NIKKI_DIR/kit/auto-update.log" 2>/dev/null)"
|
||||||
l=$(uci -q get nikki.mixin.api_listen)
|
l=$(uci -q get nikki.mixin.api_listen)
|
||||||
port=${l##*:}
|
port=${l##*:}
|
||||||
case "$port" in '' | *[!0-9]*) port=9090 ;; esac
|
case "$port" in '' | *[!0-9]*) port=9090 ;; esac
|
||||||
@ -133,6 +135,8 @@ m_run() {
|
|||||||
ts-login) set -- mihomo-kit.sh ts-login ;;
|
ts-login) set -- mihomo-kit.sh ts-login ;;
|
||||||
ts-relogin) set -- mihomo-kit.sh ts-login -f ;;
|
ts-relogin) set -- mihomo-kit.sh ts-login -f ;;
|
||||||
build | update | fix) set -- mihomo-kit.sh "$cmd" ;;
|
build | update | fix) set -- mihomo-kit.sh "$cmd" ;;
|
||||||
|
autoupdate-on) set -- mihomo-kit.sh auto-update on ;;
|
||||||
|
autoupdate-off) set -- mihomo-kit.sh auto-update off ;;
|
||||||
*) reply_error "unknown command: $cmd" ;;
|
*) reply_error "unknown command: $cmd" ;;
|
||||||
esac
|
esac
|
||||||
start_job "$@"
|
start_job "$@"
|
||||||
@ -161,23 +165,31 @@ m_config_get() {
|
|||||||
[ -f /etc/openwrt_release ] && . /etc/openwrt_release
|
[ -f /etc/openwrt_release ] && . /etc/openwrt_release
|
||||||
json_init
|
json_init
|
||||||
json_add_boolean configured "$(b test -f "$PROFILES_D/common.env")"
|
json_add_boolean configured "$(b test -f "$PROFILES_D/common.env")"
|
||||||
link=
|
# BOOT_LINKS one per line; the old single BOOT_* as one link
|
||||||
[ "${BOOT:-0}" = 1 ] &&
|
links=
|
||||||
link="vless://$BOOT_UUID@$BOOT_SERVER:$BOOT_PORT?security=reality&sni=$BOOT_SNI&pbk=$BOOT_PBK&sid=$BOOT_SID"
|
if [ "${BOOT:-0}" = 1 ]; then
|
||||||
json_add_string boot_link "$link"
|
if [ -n "${BOOT_LINKS:-}" ]; then
|
||||||
|
links=$(printf '%s\n' $BOOT_LINKS)
|
||||||
|
elif [ -n "${BOOT_SERVER:-}" ]; then
|
||||||
|
links="vless://$BOOT_UUID@$BOOT_SERVER:${BOOT_PORT:-443}?security=reality&sni=$BOOT_SNI&pbk=$BOOT_PBK&sid=$BOOT_SID"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
json_add_string boot_links "$links"
|
||||||
json_add_array subs
|
json_add_array subs
|
||||||
i=0
|
i=0
|
||||||
# "<id> <SUBS word>"; keys SUB_<ID>_*, else the old SUB<index>_*
|
# "<id> <SUBS word>"; keys SUB_<ID>_*, else the old SUB<index>_*
|
||||||
SUBS=${SUBS:-} mihomo-kit.sh sub-ids > /tmp/mihomo-kit-ids.$$
|
SUBS=${SUBS:-} mihomo-kit.sh sub-ids > /tmp/mihomo-kit-ids.$$
|
||||||
while read -r id w; do
|
while read -r id w; do
|
||||||
K=$(echo "$id" | tr 'a-z' 'A-Z')
|
K=$(echo "$id" | tr 'a-z' 'A-Z')
|
||||||
eval "p=\${SUB_${K}_PROXY:-\${SUB${i}_PROXY:-}} h=\${SUB_${K}_HWID:-\${SUB${i}_HWID:-0}}"
|
eval "p=\${SUB_${K}_PROXY:-\${SUB${i}_PROXY:-}} h=\${SUB_${K}_HWID:-\${SUB${i}_HWID:-0}}
|
||||||
[ -n "$p" ] || { [ "${BOOT:-0}" = 1 ] && p=BOOT || p=DIRECT; }
|
off=\${SUB_${K}_DISABLED:-\${SUB${i}_DISABLED:-0}}"
|
||||||
|
[ -n "$p" ] || { [ "${BOOT:-0}" = 1 ] && p=BOOT-AUTO || p=DIRECT; }
|
||||||
json_add_object ""
|
json_add_object ""
|
||||||
json_add_string id "$id"
|
json_add_string id "$id"
|
||||||
json_add_string url "$w"
|
json_add_string url "$w"
|
||||||
json_add_string via "$p"
|
json_add_string via "$p"
|
||||||
json_add_boolean hwid "$h"
|
json_add_boolean hwid "$h"
|
||||||
|
json_add_boolean enabled "$([ "$off" = 1 ] && echo 0 || echo 1)"
|
||||||
json_close_object
|
json_close_object
|
||||||
i=$((i + 1))
|
i=$((i + 1))
|
||||||
done < /tmp/mihomo-kit-ids.$$
|
done < /tmp/mihomo-kit-ids.$$
|
||||||
@ -216,7 +228,7 @@ m_config_get() {
|
|||||||
json_dump
|
json_dump
|
||||||
}
|
}
|
||||||
|
|
||||||
# {"data": {boot_link, subs: [{url, via, hwid}], hwid_*, torrent, ru_ips,
|
# {"data": {boot_links (one per line), subs: [{url, via, hwid}], hwid_*, torrent, ru_ips,
|
||||||
# openvpn, ovpn (file text, optional), vpn_username, vpn_password, totp_secret,
|
# openvpn, ovpn (file text, optional), vpn_username, vpn_password, totp_secret,
|
||||||
# tailscale, ts_hostname, ts_domains, hy2: [{name, server, port, password,
|
# tailscale, ts_hostname, ts_domains, hy2: [{name, server, port, password,
|
||||||
# obfs_password, sni, insecure, up, down}]}}; empty OpenVPN secrets keep the saved ones
|
# obfs_password, sni, insecure, up, down}]}}; empty OpenVPN secrets keep the saved ones
|
||||||
@ -224,7 +236,7 @@ m_config_set() {
|
|||||||
json_load "$(cat)" || reply_error "bad request"
|
json_load "$(cat)" || reply_error "bad request"
|
||||||
json_select data || reply_error "no data"
|
json_select data || reply_error "no data"
|
||||||
job_running && reply_error "busy: $(cat "$JOB/cmd")"
|
job_running && reply_error "busy: $(cat "$JOB/cmd")"
|
||||||
for v in boot_link hwid_ua hwid_os hwid_os_ver hwid_model hwid_id torrent ru_ips openvpn ovpn \
|
for v in boot_links hwid_ua hwid_os hwid_os_ver hwid_model hwid_id torrent ru_ips openvpn ovpn \
|
||||||
vpn_username vpn_password totp_secret tailscale ts_hostname ts_domains ovpn_check_url ts_check_url; do
|
vpn_username vpn_password totp_secret tailscale ts_hostname ts_domains ovpn_check_url ts_check_url; do
|
||||||
json_get_var "$v" "$v" ""
|
json_get_var "$v" "$v" ""
|
||||||
done
|
done
|
||||||
@ -235,20 +247,21 @@ m_config_set() {
|
|||||||
umask 077
|
umask 077
|
||||||
env=$(mktemp /tmp/mihomo-kit-form.XXXXXX) || reply_error "mktemp failed"
|
env=$(mktemp /tmp/mihomo-kit-form.XXXXXX) || reply_error "mktemp failed"
|
||||||
{
|
{
|
||||||
echo "BOOT_LINK=$(q "$boot_link")"
|
echo "BOOT_LINKS=$(q "$(echo $boot_links)")"
|
||||||
subs= i=0
|
subs= i=0
|
||||||
if json_select subs; then
|
if json_select subs; then
|
||||||
json_get_keys keys
|
json_get_keys keys
|
||||||
for k in $keys; do
|
for k in $keys; do
|
||||||
url= via= hwid=
|
url= via= hwid= enabled=
|
||||||
json_select "$k"
|
json_select "$k"
|
||||||
json_get_vars url via hwid
|
json_get_vars url via hwid enabled
|
||||||
json_select ..
|
json_select ..
|
||||||
url=$(printf '%s' "$url" | tr -d ' \t\r\n')
|
url=$(printf '%s' "$url" | tr -d ' \t\r\n')
|
||||||
[ -n "$url" ] || continue
|
[ -n "$url" ] || continue
|
||||||
subs="${subs:+$subs }$url"
|
subs="${subs:+$subs }$url"
|
||||||
echo "SUB${i}_PROXY=$(q "$via")"
|
echo "SUB${i}_PROXY=$(q "$via")"
|
||||||
echo "SUB${i}_HWID=$(q "${hwid:-0}")"
|
echo "SUB${i}_HWID=$(q "${hwid:-0}")"
|
||||||
|
[ "$enabled" = 0 ] && echo "SUB${i}_DISABLED=1"
|
||||||
i=$((i + 1))
|
i=$((i + 1))
|
||||||
done
|
done
|
||||||
json_select ..
|
json_select ..
|
||||||
|
|||||||
@ -18,6 +18,8 @@
|
|||||||
# mihomo-kit.sh use <name> switch nikki to profiles/<name>.yaml and restart
|
# mihomo-kit.sh use <name> switch nikki to profiles/<name>.yaml and restart
|
||||||
# mihomo-kit.sh update download the latest kit (KIT_URL) and rebuild
|
# mihomo-kit.sh update download the latest kit (KIT_URL) and rebuild
|
||||||
# mihomo-kit.sh check-update latest commit on the server vs the installed one
|
# mihomo-kit.sh check-update latest commit on the server vs the installed one
|
||||||
|
# mihomo-kit.sh update --apply update, then restart the current profile (and fix the core)
|
||||||
|
# mihomo-kit.sh auto-update [on|off] daily 04:00 update via cron; no argument = run it now
|
||||||
# mihomo-kit.sh fix re-apply core version + fixes (after a nikki upgrade)
|
# mihomo-kit.sh fix re-apply core version + fixes (after a nikki upgrade)
|
||||||
# mihomo-kit.sh ts-login [-f] fresh Tailscale node, print its login URL
|
# mihomo-kit.sh ts-login [-f] fresh Tailscale node, print its login URL
|
||||||
# (-f: also when the node is already logged in)
|
# (-f: also when the node is already logged in)
|
||||||
@ -55,6 +57,7 @@ set_defaults() {
|
|||||||
: "${SUBS:=}" "${RU_IPS:=}" "${HY2:=}"
|
: "${SUBS:=}" "${RU_IPS:=}" "${HY2:=}"
|
||||||
: "${GEOIP_URL:=https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/geoip.dat}"
|
: "${GEOIP_URL:=https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/geoip.dat}"
|
||||||
: "${GEOSITE_URL:=https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/geosite.dat}"
|
: "${GEOSITE_URL:=https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/geosite.dat}"
|
||||||
|
: "${BOOT_LINKS:=}"
|
||||||
: "${BOOT_SERVER:=}" "${BOOT_PORT:=443}" "${BOOT_UUID:=}" "${BOOT_SNI:=}" "${BOOT_PBK:=}" "${BOOT_SID:=}"
|
: "${BOOT_SERVER:=}" "${BOOT_PORT:=443}" "${BOOT_UUID:=}" "${BOOT_SNI:=}" "${BOOT_PBK:=}" "${BOOT_SID:=}"
|
||||||
: "${TS_HOSTNAME:=mihomo}" "${TS_DOMAINS:=}"
|
: "${TS_HOSTNAME:=mihomo}" "${TS_DOMAINS:=}"
|
||||||
: "${HWID_UA:=v2rayN/9.99}" "${HWID_OS:=}" "${HWID_OS_VER:=}" "${HWID_MODEL:=}" "${HWID_ID:=}"
|
: "${HWID_UA:=v2rayN/9.99}" "${HWID_OS:=}" "${HWID_OS_VER:=}" "${HWID_MODEL:=}" "${HWID_ID:=}"
|
||||||
@ -76,9 +79,10 @@ compute_tags() {
|
|||||||
[ "$TS_EXIT" = 1 ] && TAGS="$TAGS ts_exit "
|
[ "$TS_EXIT" = 1 ] && TAGS="$TAGS ts_exit "
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
SUB_LIST=""
|
SUB_LIST="" _i=0
|
||||||
for _p in $SUB_PAIRS; do
|
for _p in $SUB_PAIRS; do
|
||||||
SUB_LIST="${SUB_LIST:+$SUB_LIST, }${_p%%=*}"
|
sub_off "$_i" "${_p%%=*}" || SUB_LIST="${SUB_LIST:+$SUB_LIST, }${_p%%=*}"
|
||||||
|
_i=$((_i + 1))
|
||||||
done
|
done
|
||||||
# own hysteria2 servers: HY2_LIST "a, b" (group MY), HY2_MAIN "MY, " (MAIN)
|
# own hysteria2 servers: HY2_LIST "a, b" (group MY), HY2_MAIN "MY, " (MAIN)
|
||||||
HY2_LIST="" HY2_MAIN=""
|
HY2_LIST="" HY2_MAIN=""
|
||||||
@ -89,6 +93,57 @@ compute_tags() {
|
|||||||
export SUB_LIST HY2_LIST HY2_MAIN
|
export SUB_LIST HY2_LIST HY2_MAIN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# vless_parse <vless://uuid@host:port?...&sni=..&pbk=..&sid=..#name>
|
||||||
|
# -> _vs_server _vs_port _vs_uuid _vs_sni _vs_pbk _vs_sid (empty when missing)
|
||||||
|
vless_parse() {
|
||||||
|
_l=${1#vless://}
|
||||||
|
_l=${_l%%#*}
|
||||||
|
_vs_uuid=${_l%%@*}
|
||||||
|
_hp=${_l#*@}
|
||||||
|
_hp=${_hp%%\?*}
|
||||||
|
_vs_server=${_hp%:*}
|
||||||
|
_vs_port=${_hp##*:}
|
||||||
|
case "$_vs_port" in '' | *[!0-9]*) _vs_port=443 ;; esac
|
||||||
|
_q="&${_l#*\?}&"
|
||||||
|
_vs_sni=$(vless_qv sni) _vs_pbk=$(vless_qv pbk) _vs_sid=$(vless_qv sid)
|
||||||
|
}
|
||||||
|
vless_qv() { _v=${_q#*&$1=}; [ "$_v" = "$_q" ] || echo "${_v%%&*}"; }
|
||||||
|
|
||||||
|
# BOOT seeds: BOOT_LINKS (vless links, space/newline separated) or the old single
|
||||||
|
# BOOT_SERVER/PORT/UUID/SNI/PBK/SID -> SEED_ITEMS "name|server|port|uuid|sni|pbk|sid ...",
|
||||||
|
# SEED_LIST "seed, seed2". Same as bootSeeds() in web/engine.js.
|
||||||
|
boot_seeds() {
|
||||||
|
SEED_ITEMS="" SEED_LIST="" _k=1
|
||||||
|
if [ -n "$BOOT_LINKS" ]; then
|
||||||
|
set -f
|
||||||
|
for _l in $BOOT_LINKS; do
|
||||||
|
vless_parse "$_l"
|
||||||
|
_n=seed
|
||||||
|
[ "$_k" -gt 1 ] && _n=seed$_k
|
||||||
|
SEED_ITEMS="${SEED_ITEMS:+$SEED_ITEMS }$_n|$_vs_server|$_vs_port|$_vs_uuid|$_vs_sni|$_vs_pbk|$_vs_sid"
|
||||||
|
_k=$((_k + 1))
|
||||||
|
done
|
||||||
|
set +f
|
||||||
|
elif [ -n "$BOOT_SERVER" ]; then
|
||||||
|
SEED_ITEMS="seed|$BOOT_SERVER|$BOOT_PORT|$BOOT_UUID|$BOOT_SNI|$BOOT_PBK|$BOOT_SID"
|
||||||
|
fi
|
||||||
|
for _it in $SEED_ITEMS; do
|
||||||
|
SEED_LIST="${SEED_LIST:+$SEED_LIST, }${_it%%|*}"
|
||||||
|
done
|
||||||
|
export SEED_LIST
|
||||||
|
}
|
||||||
|
|
||||||
|
# seed_vars <item>: variables for templates/proxies/*-boot.each.yaml
|
||||||
|
seed_vars() {
|
||||||
|
_old_ifs=$IFS
|
||||||
|
IFS='|'
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
set -- $1
|
||||||
|
IFS=$_old_ifs
|
||||||
|
SEED_NAME=$1 SEED_SERVER=${2:-} SEED_PORT=${3:-} SEED_UUID=${4:-} SEED_SNI=${5:-} SEED_PBK=${6:-} SEED_SID=${7:-}
|
||||||
|
export SEED_NAME SEED_SERVER SEED_PORT SEED_UUID SEED_SNI SEED_PBK SEED_SID
|
||||||
|
}
|
||||||
|
|
||||||
# Subscription ids (provider names, keys SUB_<ID>_*). A SUBS word is "url" or
|
# Subscription ids (provider names, keys SUB_<ID>_*). A SUBS word is "url" or
|
||||||
# "name=url"; without a name the id comes from the domain:
|
# "name=url"; without a name the id comes from the domain:
|
||||||
# https://sub.kittyvpn.com/x -> kittyvpn, https://a.b.co.uk/ -> b
|
# https://sub.kittyvpn.com/x -> kittyvpn, https://a.b.co.uk/ -> b
|
||||||
@ -137,19 +192,34 @@ sub_get() {
|
|||||||
eval "printf '%s' \"\${SUB_${_K}_$3:-\${SUB$1_$3:-}}\""
|
eval "printf '%s' \"\${SUB_${_K}_$3:-\${SUB$1_$3:-}}\""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# sub_off <index> <id>: SUB_<ID>_DISABLED=1 keeps the subscription (id, settings)
|
||||||
|
# but leaves it out of the profile
|
||||||
|
sub_off() { [ "$(sub_get "$1" "$2" DISABLED)" = 1 ]; }
|
||||||
|
|
||||||
check_vars() {
|
check_vars() {
|
||||||
[ -n "$SUBS" ] || die "SUBS is empty (subscription URLs)"
|
[ -n "$SUBS" ] || die "SUBS is empty (subscription URLs)"
|
||||||
case "$TARGET" in router | mobile) ;; *) die "TARGET must be router or mobile" ;; esac
|
case "$TARGET" in router | mobile) ;; *) die "TARGET must be router or mobile" ;; esac
|
||||||
case "$LOCATION" in home | street) ;; *) die "LOCATION must be home or street" ;; esac
|
case "$LOCATION" in home | street) ;; *) die "LOCATION must be home or street" ;; esac
|
||||||
if [ "$BOOT" = 1 ]; then
|
if [ "$BOOT" = 1 ]; then
|
||||||
for v in BOOT_SERVER BOOT_UUID BOOT_SNI BOOT_PBK BOOT_SID; do
|
[ -n "$SEED_ITEMS" ] || die "BOOT=1 but no BOOT_LINKS (vless links of the seed nodes)"
|
||||||
eval "[ -n \"\${$v}\" ]" || die "$v is empty (BOOT=1)"
|
for _it in $SEED_ITEMS; do
|
||||||
|
seed_vars "$_it"
|
||||||
|
for v in SERVER UUID SNI PBK SID; do
|
||||||
|
eval "[ -n \"\$SEED_$v\" ]" || die "BOOT $SEED_NAME: $v is empty (vless link needs host, uuid, sni, pbk, sid)"
|
||||||
|
done
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
i=0
|
i=0 _on=0
|
||||||
for _pr in $SUB_PAIRS; do
|
for _pr in $SUB_PAIRS; do
|
||||||
_id=${_pr%%=*}
|
_id=${_pr%%=*}
|
||||||
[ "$(sub_get "$i" "$_id" PROXY)" = BOOT ] && [ "$BOOT" != 1 ] && die "subscription $_id: PROXY=BOOT but BOOT=0"
|
if sub_off "$i" "$_id"; then
|
||||||
|
i=$((i + 1))
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
_on=1
|
||||||
|
case "$(sub_get "$i" "$_id" PROXY)" in
|
||||||
|
BOOT | BOOT-AUTO) [ "$BOOT" = 1 ] || die "subscription $_id: PROXY=BOOT but BOOT=0" ;;
|
||||||
|
esac
|
||||||
if [ "$(sub_get "$i" "$_id" HWID)" = 1 ]; then
|
if [ "$(sub_get "$i" "$_id" HWID)" = 1 ]; then
|
||||||
for v in HWID_OS HWID_OS_VER HWID_MODEL HWID_ID; do
|
for v in HWID_OS HWID_OS_VER HWID_MODEL HWID_ID; do
|
||||||
eval "[ -n \"\${$v}\" ]" || die "$v is empty (subscription $_id has HWID=1)"
|
eval "[ -n \"\${$v}\" ]" || die "$v is empty (subscription $_id has HWID=1)"
|
||||||
@ -157,6 +227,7 @@ check_vars() {
|
|||||||
fi
|
fi
|
||||||
i=$((i + 1))
|
i=$((i + 1))
|
||||||
done
|
done
|
||||||
|
[ "$_on" = 1 ] || die "all subscriptions are disabled (SUB_<ID>_DISABLED=1)"
|
||||||
for _n in $HY2; do
|
for _n in $HY2; do
|
||||||
case "$_n" in *[!A-Za-z0-9_-]*) die "HY2: bad server name $_n (letters, digits, _ -)" ;; esac
|
case "$_n" in *[!A-Za-z0-9_-]*) die "HY2: bad server name $_n (letters, digits, _ -)" ;; esac
|
||||||
_k=$(hy2_key "$_n")
|
_k=$(hy2_key "$_n")
|
||||||
@ -174,7 +245,7 @@ yq() { printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g'; }
|
|||||||
|
|
||||||
# per-subscription variables for the .each templates: sub_vars <index> <id> <url>
|
# per-subscription variables for the .each templates: sub_vars <index> <id> <url>
|
||||||
# (ID = id in upper case; the old SUB<index>_* keys still work)
|
# (ID = id in upper case; the old SUB<index>_* keys still work)
|
||||||
# SUB_<ID>_PROXY BOOT (default with BOOT=1) | DIRECT | any proxy/group | none
|
# SUB_<ID>_PROXY BOOT-AUTO (default with BOOT=1) | BOOT | DIRECT | FOREIGN | any proxy/group | none
|
||||||
# SUB_<ID>_UA User-Agent (default mihomo, with HWID: HWID_UA)
|
# SUB_<ID>_UA User-Agent (default mihomo, with HWID: HWID_UA)
|
||||||
# SUB_<ID>_HWID=1 send x-device-os / x-ver-os / x-device-model / x-hwid from HWID_*
|
# SUB_<ID>_HWID=1 send x-device-os / x-ver-os / x-device-model / x-hwid from HWID_*
|
||||||
# SUB_<ID>_HEADERS extra headers: "key=value; key2=value 2"
|
# SUB_<ID>_HEADERS extra headers: "key=value; key2=value 2"
|
||||||
@ -182,7 +253,7 @@ sub_vars() {
|
|||||||
SUB_NAME="$2" SUB_URL="$3"
|
SUB_NAME="$2" SUB_URL="$3"
|
||||||
_p=$(sub_get "$1" "$2" PROXY) _ua=$(sub_get "$1" "$2" UA) _hw=$(sub_get "$1" "$2" HWID)
|
_p=$(sub_get "$1" "$2" PROXY) _ua=$(sub_get "$1" "$2" UA) _hw=$(sub_get "$1" "$2" HWID)
|
||||||
_h=$(sub_get "$1" "$2" HEADERS)
|
_h=$(sub_get "$1" "$2" HEADERS)
|
||||||
[ -z "$_p" ] && [ "$BOOT" = 1 ] && _p=BOOT
|
[ -z "$_p" ] && [ "$BOOT" = 1 ] && _p=BOOT-AUTO
|
||||||
[ "$_p" = none ] && _p=""
|
[ "$_p" = none ] && _p=""
|
||||||
if [ "$_hw" = 1 ]; then
|
if [ "$_hw" = 1 ]; then
|
||||||
[ -n "$_ua" ] || _ua=$HWID_UA
|
[ -n "$_ua" ] || _ua=$HWID_UA
|
||||||
@ -296,7 +367,15 @@ render_section() {
|
|||||||
_name=${f##*/}
|
_name=${f##*/}
|
||||||
_name=${_name%.yaml}
|
_name=${_name%.yaml}
|
||||||
fragment_active "${_name#*-}" || continue
|
fragment_active "${_name#*-}" || continue
|
||||||
if [ "$EACH" = 1 ] && [ "$_mod" = hy2 ]; then
|
if [ "$EACH" = 1 ] && [ "$_mod" = boot ]; then
|
||||||
|
for _it in $SEED_ITEMS; do
|
||||||
|
seed_vars "$_it"
|
||||||
|
_part=$(render_file "$f")
|
||||||
|
[ -n "$_part" ] && _out="${_out:+$_out
|
||||||
|
|
||||||
|
}$_part"
|
||||||
|
done
|
||||||
|
elif [ "$EACH" = 1 ] && [ "$_mod" = hy2 ]; then
|
||||||
for _n in $HY2; do
|
for _n in $HY2; do
|
||||||
hy2_vars "$_n"
|
hy2_vars "$_n"
|
||||||
_part=$(render_file "$f")
|
_part=$(render_file "$f")
|
||||||
@ -307,11 +386,13 @@ render_section() {
|
|||||||
elif [ "$EACH" = 1 ]; then
|
elif [ "$EACH" = 1 ]; then
|
||||||
i=0
|
i=0
|
||||||
for _pr in $SUB_PAIRS; do
|
for _pr in $SUB_PAIRS; do
|
||||||
|
if ! sub_off "$i" "${_pr%%=*}"; then
|
||||||
sub_vars "$i" "${_pr%%=*}" "${_pr#*=}"
|
sub_vars "$i" "${_pr%%=*}" "${_pr#*=}"
|
||||||
_part=$(render_file "$f")
|
_part=$(render_file "$f")
|
||||||
[ -n "$_part" ] && _out="${_out:+$_out
|
[ -n "$_part" ] && _out="${_out:+$_out
|
||||||
|
|
||||||
}$_part"
|
}$_part"
|
||||||
|
fi
|
||||||
i=$((i + 1))
|
i=$((i + 1))
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
@ -329,6 +410,7 @@ render_section() {
|
|||||||
render() {
|
render() {
|
||||||
set_defaults
|
set_defaults
|
||||||
sub_pairs
|
sub_pairs
|
||||||
|
boot_seeds
|
||||||
check_vars
|
check_vars
|
||||||
compute_tags
|
compute_tags
|
||||||
export TARGET LOCATION GEOIP_URL GEOSITE_URL BOOT_SERVER BOOT_PORT BOOT_UUID BOOT_SNI \
|
export TARGET LOCATION GEOIP_URL GEOSITE_URL BOOT_SERVER BOOT_PORT BOOT_UUID BOOT_SNI \
|
||||||
@ -655,20 +737,15 @@ yesno() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# vless://uuid@host:port?...&sni=..&pbk=..&sid=..#name -> BOOT_* (empty on failure)
|
# check_boot_links: every BOOT_LINKS link parses (host, uuid, sni, pbk, sid)
|
||||||
parse_vless() {
|
check_boot_links() {
|
||||||
_l=${1#vless://}
|
set -f
|
||||||
_l=${_l%%#*}
|
for _l in $BOOT_LINKS; do
|
||||||
BOOT_UUID=${_l%%@*}
|
vless_parse "$_l"
|
||||||
_hp=${_l#*@}
|
[ -n "$_vs_server" ] && [ -n "$_vs_uuid" ] && [ -n "$_vs_sni" ] && [ -n "$_vs_pbk" ] && [ -n "$_vs_sid" ] ||
|
||||||
_hp=${_hp%%\?*}
|
die "не разобрал vless-ссылку (нужны host, uuid, sni, pbk, sid): ${_l%%\?*}"
|
||||||
BOOT_SERVER=${_hp%:*}
|
done
|
||||||
BOOT_PORT=${_hp##*:}
|
set +f
|
||||||
_q="&${_l#*\?}&"
|
|
||||||
qv() { _v=${_q#*&$1=}; [ "$_v" = "$_q" ] && return; echo "${_v%%&*}"; }
|
|
||||||
BOOT_SNI=$(qv sni)
|
|
||||||
BOOT_PBK=$(qv pbk)
|
|
||||||
BOOT_SID=$(qv sid)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
q() { printf "'%s'" "$(printf '%s' "$1" | sed "s/'/'\\\\''/g")"; }
|
q() { printf "'%s'" "$(printf '%s' "$1" | sed "s/'/'\\\\''/g")"; }
|
||||||
@ -681,11 +758,10 @@ wizard() {
|
|||||||
echo
|
echo
|
||||||
} > "$TTY_OUT"
|
} > "$TTY_OUT"
|
||||||
|
|
||||||
ask _vless "BOOT: vless:// ссылка seed-ноды (пусто = без BOOT)"
|
ask BOOT_LINKS "BOOT: vless:// ссылки seed-нод через пробел (пусто = без BOOT)"
|
||||||
BOOT=0
|
BOOT=0
|
||||||
if [ -n "$_vless" ]; then
|
if [ -n "$BOOT_LINKS" ]; then
|
||||||
parse_vless "$_vless"
|
check_boot_links
|
||||||
[ -n "$BOOT_SERVER" ] && [ -n "$BOOT_PBK" ] || die "не разобрал vless-ссылку: нужны host, pbk, sid"
|
|
||||||
BOOT=1
|
BOOT=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -696,7 +772,7 @@ wizard() {
|
|||||||
[ -n "$_u" ] || break
|
[ -n "$_u" ] || break
|
||||||
SUBS="${SUBS:+$SUBS }$_u"
|
SUBS="${SUBS:+$SUBS }$_u"
|
||||||
if [ "$BOOT" = 1 ]; then
|
if [ "$BOOT" = 1 ]; then
|
||||||
ask _p " качать через (BOOT/DIRECT/FOREIGN)" BOOT
|
ask _p " качать через (BOOT-AUTO/BOOT/DIRECT/FOREIGN)" BOOT-AUTO
|
||||||
else
|
else
|
||||||
_p=DIRECT
|
_p=DIRECT
|
||||||
fi
|
fi
|
||||||
@ -741,7 +817,7 @@ wizard() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# keys write_config owns; any other KEY=value lines (added by hand) are kept
|
# keys write_config owns; any other KEY=value lines (added by hand) are kept
|
||||||
COMMON_KEYS='TARGET|SUBS|SUB[0-9]*_[A-Z0-9_]*(PROXY|HWID)|HWID_[A-Z_]+|BOOT|BOOT_[A-Z]+|TORRENT|RU_IPS|OPENVPN|TAILSCALE|TS_HOSTNAME|TS_DOMAINS'
|
COMMON_KEYS='TARGET|SUBS|SUB[0-9]*_[A-Z0-9_]*(PROXY|HWID|DISABLED)|HWID_[A-Z_]+|BOOT|BOOT_[A-Z]+|TORRENT|RU_IPS|OPENVPN|TAILSCALE|TS_HOSTNAME|TS_DOMAINS'
|
||||||
VPN_KEYS='VPN_USERNAME|VPN_PASSWORD|TOTP_SECRET'
|
VPN_KEYS='VPN_USERNAME|VPN_PASSWORD|TOTP_SECRET'
|
||||||
|
|
||||||
# other_keys <file> <keys-regex>
|
# other_keys <file> <keys-regex>
|
||||||
@ -796,9 +872,10 @@ write_config() {
|
|||||||
for _pr in $SUB_PAIRS; do
|
for _pr in $SUB_PAIRS; do
|
||||||
_K=$(echo "${_pr%%=*}" | tr 'a-z' 'A-Z')
|
_K=$(echo "${_pr%%=*}" | tr 'a-z' 'A-Z')
|
||||||
_p=$(sub_get "$_i" "${_pr%%=*}" PROXY) _hw=$(sub_get "$_i" "${_pr%%=*}" HWID)
|
_p=$(sub_get "$_i" "${_pr%%=*}" PROXY) _hw=$(sub_get "$_i" "${_pr%%=*}" HWID)
|
||||||
[ "$BOOT" = 1 ] || [ "$_p" != BOOT ] || _p=DIRECT
|
case "$_p" in BOOT | BOOT-AUTO) [ "$BOOT" = 1 ] || _p=DIRECT ;; esac
|
||||||
[ -n "$_p" ] && [ "$_p" != BOOT ] && echo "SUB_${_K}_PROXY=$(q "$_p")"
|
[ -n "$_p" ] && [ "$_p" != BOOT-AUTO ] && echo "SUB_${_K}_PROXY=$(q "$_p")"
|
||||||
[ "$_hw" = 1 ] && echo "SUB_${_K}_HWID=1" && _any_hwid=1
|
[ "$_hw" = 1 ] && echo "SUB_${_K}_HWID=1" && _any_hwid=1
|
||||||
|
sub_off "$_i" "${_pr%%=*}" && echo "SUB_${_K}_DISABLED=1"
|
||||||
_i=$((_i + 1))
|
_i=$((_i + 1))
|
||||||
done
|
done
|
||||||
if [ "$_any_hwid" = 1 ]; then
|
if [ "$_any_hwid" = 1 ]; then
|
||||||
@ -807,11 +884,7 @@ write_config() {
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
echo "BOOT=$BOOT"
|
echo "BOOT=$BOOT"
|
||||||
if [ "$BOOT" = 1 ]; then
|
[ "$BOOT" = 1 ] && echo "BOOT_LINKS=$(q "$BOOT_LINKS")"
|
||||||
for v in BOOT_SERVER BOOT_PORT BOOT_UUID BOOT_SNI BOOT_PBK BOOT_SID; do
|
|
||||||
eval "echo \"$v=\$(q \"\$$v\")\""
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
echo "TORRENT=$TORRENT"
|
echo "TORRENT=$TORRENT"
|
||||||
echo "RU_IPS=$(q "$RU_IPS")"
|
echo "RU_IPS=$(q "$RU_IPS")"
|
||||||
echo "OPENVPN=$OPENVPN"
|
echo "OPENVPN=$OPENVPN"
|
||||||
@ -863,7 +936,7 @@ cmd_sub_ids() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Settings from the LuCI form: <env> holds BOOT_LINK, SUBS, SUB<i>_PROXY/HWID,
|
# Settings from the LuCI form: <env> holds BOOT_LINKS, SUBS, SUB<i>_PROXY/HWID,
|
||||||
# HWID_*, TORRENT, RU_IPS, OPENVPN, VPN_* (empty secrets = keep), TAILSCALE, TS_*,
|
# HWID_*, TORRENT, RU_IPS, OPENVPN, VPN_* (empty secrets = keep), TAILSCALE, TS_*,
|
||||||
# FORM=1, OVPN_CHECK_URL, TS_CHECK_URL, HY2 + HY2_<NAME>_*.
|
# FORM=1, OVPN_CHECK_URL, TS_CHECK_URL, HY2 + HY2_<NAME>_*.
|
||||||
# Validates, writes common.env/bmstu.env, builds and restarts the current profile.
|
# Validates, writes common.env/bmstu.env, builds and restarts the current profile.
|
||||||
@ -873,10 +946,9 @@ cmd_configure() {
|
|||||||
[ -f "$NIKKI_DIR/bmstu.env" ] && . "$NIKKI_DIR/bmstu.env"
|
[ -f "$NIKKI_DIR/bmstu.env" ] && . "$NIKKI_DIR/bmstu.env"
|
||||||
. "$1"
|
. "$1"
|
||||||
rm -f "$1"
|
rm -f "$1"
|
||||||
BOOT=0
|
BOOT=0 BOOT_LINKS=${BOOT_LINKS:-}
|
||||||
if [ -n "${BOOT_LINK:-}" ]; then
|
if [ -n "$BOOT_LINKS" ]; then
|
||||||
parse_vless "$BOOT_LINK"
|
check_boot_links
|
||||||
[ -n "$BOOT_SERVER" ] && [ -n "$BOOT_PBK" ] || die "не разобрал vless-ссылку: нужны host, pbk, sid"
|
|
||||||
BOOT=1
|
BOOT=1
|
||||||
fi
|
fi
|
||||||
[ -n "${SUBS:-}" ] || die "нужна хотя бы одна подписка"
|
[ -n "${SUBS:-}" ] || die "нужна хотя бы одна подписка"
|
||||||
@ -974,6 +1046,7 @@ cmd_check_update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmd_update() {
|
cmd_update() {
|
||||||
|
_apply=${1:-}
|
||||||
tmp=$(mktemp -d)
|
tmp=$(mktemp -d)
|
||||||
log "downloading $KIT_URL"
|
log "downloading $KIT_URL"
|
||||||
wget -qO "$tmp/kit.tgz" "$KIT_URL" || die "download failed"
|
wget -qO "$tmp/kit.tgz" "$KIT_URL" || die "download failed"
|
||||||
@ -989,14 +1062,60 @@ cmd_update() {
|
|||||||
rm -rf "$tmp"
|
rm -rf "$tmp"
|
||||||
log "kit version $(cat "$KIT_DIR/VERSION")"
|
log "kit version $(cat "$KIT_DIR/VERSION")"
|
||||||
# the rest runs from the new script: this one is the old version
|
# the rest runs from the new script: this one is the old version
|
||||||
exec sh "$KIT_DIR/router/mihomo-kit.sh" post-update
|
exec sh "$KIT_DIR/router/mihomo-kit.sh" post-update $_apply
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_post_update() {
|
cmd_post_update() {
|
||||||
install_files
|
install_files
|
||||||
cmd_build
|
cmd_build
|
||||||
cur=$(uci -q get nikki.config.profile)
|
cur=$(uci -q get nikki.config.profile)
|
||||||
log "kit updated; to apply: mihomo-kit.sh use $(basename "${cur#file:}" .yaml)"
|
cur=$(basename "${cur#file:}" .yaml)
|
||||||
|
if [ "${1:-}" != --apply ]; then
|
||||||
|
log "kit updated; to apply: mihomo-kit.sh use $cur"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
# a new kit may pin another core version
|
||||||
|
[ "$(mihomo -v 2>/dev/null | awk '{print $3; exit}')" = "$MIHOMO_VERSION" ] || cmd_fix
|
||||||
|
[ -f "$PROFILES_OUT/$cur.yaml" ] && cmd_use "$cur"
|
||||||
|
auto_log "updated to $(cut -d' ' -f1 "$KIT_DIR/VERSION"), profile $cur restarted"
|
||||||
|
}
|
||||||
|
|
||||||
|
AUTO_CRON='0 4 * * * /usr/bin/mihomo-kit.sh auto-update'
|
||||||
|
AUTO_LOG=$NIKKI_DIR/kit/auto-update.log
|
||||||
|
|
||||||
|
# auto_log <text>: last runs for the LuCI page (and syslog)
|
||||||
|
auto_log() {
|
||||||
|
logger -t mihomo-kit "auto-update: $*" 2>/dev/null
|
||||||
|
echo "$(date '+%Y-%m-%d %H:%M') $*" >> "$AUTO_LOG"
|
||||||
|
tail -n 20 "$AUTO_LOG" > "$AUTO_LOG.tmp" && mv "$AUTO_LOG.tmp" "$AUTO_LOG"
|
||||||
|
}
|
||||||
|
|
||||||
|
# auto-update on|off: the cron line; no argument: update if the server has a newer commit
|
||||||
|
cmd_auto_update() {
|
||||||
|
case "${1:-}" in
|
||||||
|
on | off)
|
||||||
|
sed -i '/mihomo-kit.sh auto-update/d' /etc/crontabs/root 2>/dev/null
|
||||||
|
[ "$1" = on ] && echo "$AUTO_CRON" >> /etc/crontabs/root
|
||||||
|
/etc/init.d/cron restart
|
||||||
|
log "auto-update $1"
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
export PATH=/usr/sbin:/usr/bin:/sbin:/bin:$PATH
|
||||||
|
if ! _out=$(cmd_check_update 2>&1); then
|
||||||
|
auto_log "check failed: $(echo "$_out" | tail -n 1)"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
_cur=$(echo "$_out" | sed -n 's/^installed //p')
|
||||||
|
_new=$(echo "$_out" | sed -n 's/^latest //p')
|
||||||
|
case "$_cur" in
|
||||||
|
"$_new"*)
|
||||||
|
auto_log "up to date ($_new)"
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
auto_log "updating $_cur -> $_new"
|
||||||
|
cmd_update --apply
|
||||||
}
|
}
|
||||||
|
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
@ -1006,11 +1125,12 @@ case "${1:-}" in
|
|||||||
setup) shift; cmd_setup "$@" ;;
|
setup) shift; cmd_setup "$@" ;;
|
||||||
configure) shift; cmd_configure "$@" ;;
|
configure) shift; cmd_configure "$@" ;;
|
||||||
sub-ids) cmd_sub_ids ;;
|
sub-ids) cmd_sub_ids ;;
|
||||||
update) cmd_update ;;
|
update) shift; cmd_update "$@" ;;
|
||||||
|
auto-update) shift; cmd_auto_update "$@" ;;
|
||||||
check-update) cmd_check_update ;;
|
check-update) cmd_check_update ;;
|
||||||
post-update) cmd_post_update ;;
|
post-update) shift; cmd_post_update "$@" ;;
|
||||||
install) cmd_install ;;
|
install) cmd_install ;;
|
||||||
fix) cmd_fix ;;
|
fix) cmd_fix ;;
|
||||||
ts-login) shift; cmd_ts_login "$@" ;;
|
ts-login) shift; cmd_ts_login "$@" ;;
|
||||||
*) sed -n '2,27p' "$SELF" >&2; exit 2 ;;
|
*) sed -n '2,29p' "$SELF" >&2; exit 2 ;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
@ -1,3 +1,16 @@
|
|||||||
|
# BOOT: whitelisted entry nodes (BOOT_LINKS), the first alive one
|
||||||
- name: BOOT
|
- name: BOOT
|
||||||
type: select
|
type: fallback
|
||||||
proxies: [seed]
|
proxies: [${SEED_LIST}]
|
||||||
|
url: "https://www.gstatic.com/generate_204"
|
||||||
|
interval: 300
|
||||||
|
lazy: false
|
||||||
|
|
||||||
|
# default for downloading subscriptions: BOOT, else the nodes of the saved
|
||||||
|
# subscriptions (providers are cached on disk), else direct
|
||||||
|
- name: BOOT-AUTO
|
||||||
|
type: fallback
|
||||||
|
proxies: [BOOT, FOREIGN, DIRECT]
|
||||||
|
url: "https://www.gstatic.com/generate_204"
|
||||||
|
interval: 300
|
||||||
|
lazy: false
|
||||||
|
|||||||
@ -6,3 +6,14 @@
|
|||||||
interval: 300
|
interval: 300
|
||||||
tolerance: 50
|
tolerance: 50
|
||||||
lazy: false
|
lazy: false
|
||||||
|
|
||||||
|
# street: 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 #@street
|
||||||
|
type: url-test #@street
|
||||||
|
use: [${SUB_LIST}] #@street
|
||||||
|
exclude-filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск" #@street
|
||||||
|
url: "https://www.gstatic.com/generate_204" #@street
|
||||||
|
interval: 300 #@street
|
||||||
|
tolerance: 300 #@street
|
||||||
|
lazy: false #@street
|
||||||
|
|||||||
4
templates/groups/92-base.router.yaml
Normal file
4
templates/groups/92-base.router.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
- name: PUSH
|
||||||
|
type: select
|
||||||
|
proxies: [DIRECT, ${HY2_MAIN}FOREIGN] #@home
|
||||||
|
proxies: [${HY2_MAIN}FOREIGN, DIRECT] #@street
|
||||||
14
templates/proxies/10-boot.each.yaml
Normal file
14
templates/proxies/10-boot.each.yaml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
- name: ${SEED_NAME}
|
||||||
|
type: vless
|
||||||
|
server: ${SEED_SERVER}
|
||||||
|
port: ${SEED_PORT}
|
||||||
|
uuid: ${SEED_UUID}
|
||||||
|
network: tcp
|
||||||
|
udp: true
|
||||||
|
tls: true
|
||||||
|
flow: xtls-rprx-vision
|
||||||
|
servername: ${SEED_SNI}
|
||||||
|
client-fingerprint: firefox
|
||||||
|
reality-opts:
|
||||||
|
public-key: ${SEED_PBK}
|
||||||
|
short-id: ${SEED_SID}
|
||||||
@ -1,15 +0,0 @@
|
|||||||
# BOOT: whitelisted entry node, used to download subscriptions
|
|
||||||
- name: seed
|
|
||||||
type: vless
|
|
||||||
server: ${BOOT_SERVER}
|
|
||||||
port: ${BOOT_PORT}
|
|
||||||
uuid: ${BOOT_UUID}
|
|
||||||
network: tcp
|
|
||||||
udp: true
|
|
||||||
tls: true
|
|
||||||
flow: xtls-rprx-vision
|
|
||||||
servername: ${BOOT_SNI}
|
|
||||||
client-fingerprint: firefox
|
|
||||||
reality-opts:
|
|
||||||
public-key: ${BOOT_PBK}
|
|
||||||
short-id: ${BOOT_SID}
|
|
||||||
@ -10,4 +10,4 @@
|
|||||||
up: "${@@HY2_UP}"
|
up: "${@@HY2_UP}"
|
||||||
down: "${@@HY2_DOWN}"
|
down: "${@@HY2_DOWN}"
|
||||||
udp: true
|
udp: true
|
||||||
dialer-proxy: FOREIGN #@street
|
dialer-proxy: MY-EXIT #@street
|
||||||
|
|||||||
10
templates/rules/35-base.router.yaml
Normal file
10
templates/rules/35-base.router.yaml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# push notifications (Apple APNs, Google FCM): long-lived connections on a
|
||||||
|
# stable path - group PUSH (home: DIRECT, street: MY)
|
||||||
|
- DOMAIN-SUFFIX,push.apple.com,PUSH
|
||||||
|
- IP-CIDR,17.249.0.0/16,PUSH,no-resolve
|
||||||
|
- IP-CIDR,17.252.0.0/16,PUSH,no-resolve
|
||||||
|
- 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
|
||||||
5
tests/fixtures/router-boots.env
vendored
Normal file
5
tests/fixtures/router-boots.env
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
TARGET=router
|
||||||
|
LOCATION=street
|
||||||
|
BOOT_LINKS="vless://11111111-1111-1111-1111-111111111111@1.2.3.4:443?type=tcp&security=reality&sni=eh.vk.ru&pbk=PBK1&sid=a1&flow=xtls-rprx-vision#one
|
||||||
|
vless://22222222-2222-2222-2222-222222222222@seed2.example.com:8443?security=reality&sni=ya.ru&pbk=PBK2&sid=b2"
|
||||||
|
SUB_EXAMPLE_PROXY=BOOT
|
||||||
1
tests/fixtures/router-ids.env
vendored
1
tests/fixtures/router-ids.env
vendored
@ -2,6 +2,7 @@ SUBS="kitty=https://a.example.com/x https://sub.vpn-host.co.uk/y?t=1 https://sub
|
|||||||
SUB_KITTY_HWID=1
|
SUB_KITTY_HWID=1
|
||||||
SUB_VPN_HOST_PROXY=DIRECT
|
SUB_VPN_HOST_PROXY=DIRECT
|
||||||
SUB_VPN_HOST2_UA='ua two'
|
SUB_VPN_HOST2_UA='ua two'
|
||||||
|
SUB_VPN_HOST2_DISABLED=1
|
||||||
SUB_SUB3_HEADERS="x-a=1"
|
SUB_SUB3_HEADERS="x-a=1"
|
||||||
HWID_OS=OpenWrt
|
HWID_OS=OpenWrt
|
||||||
HWID_OS_VER=24.10.3
|
HWID_OS_VER=24.10.3
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
SUBS: "", RU_IPS: "", HY2: "",
|
SUBS: "", RU_IPS: "", HY2: "",
|
||||||
GEOIP_URL: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/geoip.dat",
|
GEOIP_URL: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/geoip.dat",
|
||||||
GEOSITE_URL: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/geosite.dat",
|
GEOSITE_URL: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/geosite.dat",
|
||||||
|
BOOT_LINKS: "",
|
||||||
BOOT_SERVER: "", BOOT_PORT: "443", BOOT_UUID: "", BOOT_SNI: "", BOOT_PBK: "", BOOT_SID: "",
|
BOOT_SERVER: "", BOOT_PORT: "443", BOOT_UUID: "", BOOT_SNI: "", BOOT_PBK: "", BOOT_SID: "",
|
||||||
TS_HOSTNAME: "mihomo", TS_DOMAINS: "",
|
TS_HOSTNAME: "mihomo", TS_DOMAINS: "",
|
||||||
HWID_UA: "v2rayN/9.99", HWID_OS: "", HWID_OS_VER: "", HWID_MODEL: "", HWID_ID: "",
|
HWID_UA: "v2rayN/9.99", HWID_OS: "", HWID_OS_VER: "", HWID_MODEL: "", HWID_ID: "",
|
||||||
@ -72,6 +73,41 @@
|
|||||||
|
|
||||||
// SUB_<ID>_<key>, else the old SUB<index>_<key>
|
// SUB_<ID>_<key>, else the old SUB<index>_<key>
|
||||||
const subGet = (v, i, id, key) => v[`SUB_${id.toUpperCase()}_${key}`] || v[`SUB${i}_${key}`] || "";
|
const subGet = (v, i, id, key) => v[`SUB_${id.toUpperCase()}_${key}`] || v[`SUB${i}_${key}`] || "";
|
||||||
|
// SUB_<ID>_DISABLED=1: kept (id, settings) but left out of the profile
|
||||||
|
const subOff = (v, i, id) => subGet(v, i, id, "DISABLED") === "1";
|
||||||
|
|
||||||
|
// vless://uuid@host:port?...&sni=..&pbk=..&sid=..#name (see vless_parse in mihomo-kit.sh)
|
||||||
|
function parseVless(link) {
|
||||||
|
const l = link.replace(/^vless:\/\//, "").replace(/#.*$/, "");
|
||||||
|
const at = l.indexOf("@");
|
||||||
|
let hp = (at < 0 ? l : l.slice(at + 1)).replace(/\?.*$/, "");
|
||||||
|
const c = hp.lastIndexOf(":");
|
||||||
|
const server = c < 0 ? hp : hp.slice(0, c);
|
||||||
|
let port = c < 0 ? hp : hp.slice(c + 1);
|
||||||
|
if (!/^[0-9]+$/.test(port)) port = "443";
|
||||||
|
const qm = l.indexOf("?");
|
||||||
|
const q = "&" + (qm < 0 ? l : l.slice(qm + 1)) + "&";
|
||||||
|
const qv = (k) => {
|
||||||
|
const i = q.indexOf("&" + k + "=");
|
||||||
|
if (i < 0) return "";
|
||||||
|
const rest = q.slice(i + k.length + 2);
|
||||||
|
return rest.slice(0, rest.indexOf("&"));
|
||||||
|
};
|
||||||
|
return { server, port, uuid: at < 0 ? l : l.slice(0, at), sni: qv("sni"), pbk: qv("pbk"), sid: qv("sid") };
|
||||||
|
}
|
||||||
|
|
||||||
|
// BOOT seeds: BOOT_LINKS or the old single BOOT_* (see boot_seeds)
|
||||||
|
function bootSeeds(v) {
|
||||||
|
if (words(v.BOOT_LINKS).length)
|
||||||
|
return words(v.BOOT_LINKS).map((l, i) => ({ name: i ? `seed${i + 1}` : "seed", ...parseVless(l) }));
|
||||||
|
if (v.BOOT_SERVER)
|
||||||
|
return [{ name: "seed", server: v.BOOT_SERVER, port: v.BOOT_PORT, uuid: v.BOOT_UUID,
|
||||||
|
sni: v.BOOT_SNI, pbk: v.BOOT_PBK, sid: v.BOOT_SID }];
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
const seedVars = (s) => ({ SEED_NAME: s.name, SEED_SERVER: s.server, SEED_PORT: s.port, SEED_UUID: s.uuid,
|
||||||
|
SEED_SNI: s.sni, SEED_PBK: s.pbk, SEED_SID: s.sid });
|
||||||
|
|
||||||
// HY2_<NAME> prefix of an own hysteria2 server's keys (see hy2_key)
|
// HY2_<NAME> prefix of an own hysteria2 server's keys (see hy2_key)
|
||||||
const hy2Key = (name) => "HY2_" + name.replace(/[a-z]/g, (c) => c.toUpperCase()).replace(/-/g, "_");
|
const hy2Key = (name) => "HY2_" + name.replace(/[a-z]/g, (c) => c.toUpperCase()).replace(/-/g, "_");
|
||||||
@ -93,18 +129,26 @@
|
|||||||
if (!["router", "mobile"].includes(v.TARGET)) throw new Error("TARGET must be router or mobile");
|
if (!["router", "mobile"].includes(v.TARGET)) throw new Error("TARGET must be router or mobile");
|
||||||
if (!["home", "street"].includes(v.LOCATION)) throw new Error("LOCATION must be home or street");
|
if (!["home", "street"].includes(v.LOCATION)) throw new Error("LOCATION must be home or street");
|
||||||
if (v.BOOT === "1") {
|
if (v.BOOT === "1") {
|
||||||
for (const k of ["BOOT_SERVER", "BOOT_UUID", "BOOT_SNI", "BOOT_PBK", "BOOT_SID"]) {
|
const seeds = bootSeeds(v);
|
||||||
if (!v[k]) throw new Error(`${k} is empty (BOOT=1)`);
|
if (!seeds.length) throw new Error("BOOT=1 but no BOOT_LINKS (vless links of the seed nodes)");
|
||||||
|
for (const s of seeds) {
|
||||||
|
for (const k of ["server", "uuid", "sni", "pbk", "sid"]) {
|
||||||
|
if (!s[k]) throw new Error(`BOOT ${s.name}: ${k.toUpperCase()} is empty (vless link needs host, uuid, sni, pbk, sid)`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
let on = 0;
|
||||||
subPairs(v.SUBS).forEach(({ id }, i) => {
|
subPairs(v.SUBS).forEach(({ id }, i) => {
|
||||||
if (subGet(v, i, id, "PROXY") === "BOOT" && v.BOOT !== "1") throw new Error(`subscription ${id}: PROXY=BOOT but BOOT=0`);
|
if (subOff(v, i, id)) return;
|
||||||
|
on++;
|
||||||
|
if (/^BOOT(-AUTO)?$/.test(subGet(v, i, id, "PROXY")) && v.BOOT !== "1") throw new Error(`subscription ${id}: PROXY=BOOT but BOOT=0`);
|
||||||
if (subGet(v, i, id, "HWID") === "1") {
|
if (subGet(v, i, id, "HWID") === "1") {
|
||||||
for (const k of ["HWID_OS", "HWID_OS_VER", "HWID_MODEL", "HWID_ID"]) {
|
for (const k of ["HWID_OS", "HWID_OS_VER", "HWID_MODEL", "HWID_ID"]) {
|
||||||
if (!v[k]) throw new Error(`${k} is empty (subscription ${id} has HWID=1)`);
|
if (!v[k]) throw new Error(`${k} is empty (subscription ${id} has HWID=1)`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (!on) throw new Error("all subscriptions are disabled (SUB_<ID>_DISABLED=1)");
|
||||||
for (const name of words(v.HY2)) {
|
for (const name of words(v.HY2)) {
|
||||||
if (!/^[A-Za-z0-9_-]+$/.test(name)) throw new Error(`HY2: bad server name ${name} (letters, digits, _ -)`);
|
if (!/^[A-Za-z0-9_-]+$/.test(name)) throw new Error(`HY2: bad server name ${name} (letters, digits, _ -)`);
|
||||||
for (const key of ["SERVER", "PORT", "PASSWORD"]) {
|
for (const key of ["SERVER", "PORT", "PASSWORD"]) {
|
||||||
@ -118,7 +162,7 @@
|
|||||||
|
|
||||||
// per-subscription variables for the .each templates (see sub_vars in mihomo-kit.sh)
|
// per-subscription variables for the .each templates (see sub_vars in mihomo-kit.sh)
|
||||||
function subVars(v, i, id, url) {
|
function subVars(v, i, id, url) {
|
||||||
let proxy = subGet(v, i, id, "PROXY") || (v.BOOT === "1" ? "BOOT" : "");
|
let proxy = subGet(v, i, id, "PROXY") || (v.BOOT === "1" ? "BOOT-AUTO" : "");
|
||||||
if (proxy === "none") proxy = "";
|
if (proxy === "none") proxy = "";
|
||||||
let ua = subGet(v, i, id, "UA");
|
let ua = subGet(v, i, id, "UA");
|
||||||
let h = subGet(v, i, id, "HEADERS");
|
let h = subGet(v, i, id, "HEADERS");
|
||||||
@ -200,7 +244,9 @@
|
|||||||
check(v);
|
check(v);
|
||||||
const tags = computeTags(v);
|
const tags = computeTags(v);
|
||||||
const subs = subPairs(v.SUBS);
|
const subs = subPairs(v.SUBS);
|
||||||
v.SUB_LIST = subs.map((s) => s.id).join(", ");
|
v.SUB_LIST = subs.filter((s, i) => !subOff(v, i, s.id)).map((s) => s.id).join(", ");
|
||||||
|
const seeds = bootSeeds(v);
|
||||||
|
v.SEED_LIST = seeds.map((s) => s.name).join(", ");
|
||||||
const hy2 = words(v.HY2);
|
const hy2 = words(v.HY2);
|
||||||
v.HY2_LIST = hy2.join(", ");
|
v.HY2_LIST = hy2.join(", ");
|
||||||
v.HY2_MAIN = hy2.length ? "MY, " : "";
|
v.HY2_MAIN = hy2.length ? "MY, " : "";
|
||||||
@ -215,13 +261,19 @@
|
|||||||
const name = path.slice(dir.length + 1, -".yaml".length);
|
const name = path.slice(dir.length + 1, -".yaml".length);
|
||||||
const info = fragmentInfo(name.slice(name.indexOf("-") + 1), tags);
|
const info = fragmentInfo(name.slice(name.indexOf("-") + 1), tags);
|
||||||
if (!info.active) continue;
|
if (!info.active) continue;
|
||||||
if (info.each && info.mod === "hy2") {
|
if (info.each && info.mod === "boot") {
|
||||||
|
for (const s of seeds) {
|
||||||
|
const part = renderText(templates[path], { ...v, ...seedVars(s) }, tags);
|
||||||
|
if (part) parts.push(part);
|
||||||
|
}
|
||||||
|
} else if (info.each && info.mod === "hy2") {
|
||||||
for (const name of hy2) {
|
for (const name of hy2) {
|
||||||
const part = renderText(templates[path], { ...v, ...hy2Vars(v, name) }, tags);
|
const part = renderText(templates[path], { ...v, ...hy2Vars(v, name) }, tags);
|
||||||
if (part) parts.push(part);
|
if (part) parts.push(part);
|
||||||
}
|
}
|
||||||
} else if (info.each) {
|
} else if (info.each) {
|
||||||
subs.forEach((s, i) => {
|
subs.forEach((s, i) => {
|
||||||
|
if (subOff(v, i, s.id)) return;
|
||||||
const part = renderText(templates[path], { ...v, ...subVars(v, i, s.id, s.url) }, tags);
|
const part = renderText(templates[path], { ...v, ...subVars(v, i, s.id, s.url) }, tags);
|
||||||
if (part) parts.push(part);
|
if (part) parts.push(part);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -108,7 +108,7 @@
|
|||||||
<legend>Подписки</legend>
|
<legend>Подписки</legend>
|
||||||
<div id="subs"></div>
|
<div id="subs"></div>
|
||||||
<button type="button" class="link-btn" id="add-sub">+ подписка</button>
|
<button type="button" class="link-btn" id="add-sub">+ подписка</button>
|
||||||
<p class="hint">«Через»: откуда качать подписку. Авто = BOOT, если он включён.
|
<p class="hint">«Через»: откуда качать подписку. Авто = BOOT-AUTO (BOOT, иначе ноды сохранённых подписок, иначе напрямую), если BOOT включён.
|
||||||
HWID — для подписок с лимитом устройств (x-hwid, x-device-os, …).</p>
|
HWID — для подписок с лимитом устройств (x-hwid, x-device-os, …).</p>
|
||||||
<label for="RU_IPS">Доп. IP через RU (CIDR через пробел)</label>
|
<label for="RU_IPS">Доп. IP через RU (CIDR через пробел)</label>
|
||||||
<input type="text" id="RU_IPS" value="194.190.191.112/32">
|
<input type="text" id="RU_IPS" value="194.190.191.112/32">
|
||||||
@ -205,6 +205,7 @@
|
|||||||
SUBS: "", RU_IPS: "", HY2: "",
|
SUBS: "", RU_IPS: "", HY2: "",
|
||||||
GEOIP_URL: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/geoip.dat",
|
GEOIP_URL: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/geoip.dat",
|
||||||
GEOSITE_URL: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/geosite.dat",
|
GEOSITE_URL: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release/geosite.dat",
|
||||||
|
BOOT_LINKS: "",
|
||||||
BOOT_SERVER: "", BOOT_PORT: "443", BOOT_UUID: "", BOOT_SNI: "", BOOT_PBK: "", BOOT_SID: "",
|
BOOT_SERVER: "", BOOT_PORT: "443", BOOT_UUID: "", BOOT_SNI: "", BOOT_PBK: "", BOOT_SID: "",
|
||||||
TS_HOSTNAME: "mihomo", TS_DOMAINS: "",
|
TS_HOSTNAME: "mihomo", TS_DOMAINS: "",
|
||||||
HWID_UA: "v2rayN/9.99", HWID_OS: "", HWID_OS_VER: "", HWID_MODEL: "", HWID_ID: "",
|
HWID_UA: "v2rayN/9.99", HWID_OS: "", HWID_OS_VER: "", HWID_MODEL: "", HWID_ID: "",
|
||||||
@ -260,6 +261,41 @@
|
|||||||
|
|
||||||
// SUB_<ID>_<key>, else the old SUB<index>_<key>
|
// SUB_<ID>_<key>, else the old SUB<index>_<key>
|
||||||
const subGet = (v, i, id, key) => v[`SUB_${id.toUpperCase()}_${key}`] || v[`SUB${i}_${key}`] || "";
|
const subGet = (v, i, id, key) => v[`SUB_${id.toUpperCase()}_${key}`] || v[`SUB${i}_${key}`] || "";
|
||||||
|
// SUB_<ID>_DISABLED=1: kept (id, settings) but left out of the profile
|
||||||
|
const subOff = (v, i, id) => subGet(v, i, id, "DISABLED") === "1";
|
||||||
|
|
||||||
|
// vless://uuid@host:port?...&sni=..&pbk=..&sid=..#name (see vless_parse in mihomo-kit.sh)
|
||||||
|
function parseVless(link) {
|
||||||
|
const l = link.replace(/^vless:\/\//, "").replace(/#.*$/, "");
|
||||||
|
const at = l.indexOf("@");
|
||||||
|
let hp = (at < 0 ? l : l.slice(at + 1)).replace(/\?.*$/, "");
|
||||||
|
const c = hp.lastIndexOf(":");
|
||||||
|
const server = c < 0 ? hp : hp.slice(0, c);
|
||||||
|
let port = c < 0 ? hp : hp.slice(c + 1);
|
||||||
|
if (!/^[0-9]+$/.test(port)) port = "443";
|
||||||
|
const qm = l.indexOf("?");
|
||||||
|
const q = "&" + (qm < 0 ? l : l.slice(qm + 1)) + "&";
|
||||||
|
const qv = (k) => {
|
||||||
|
const i = q.indexOf("&" + k + "=");
|
||||||
|
if (i < 0) return "";
|
||||||
|
const rest = q.slice(i + k.length + 2);
|
||||||
|
return rest.slice(0, rest.indexOf("&"));
|
||||||
|
};
|
||||||
|
return { server, port, uuid: at < 0 ? l : l.slice(0, at), sni: qv("sni"), pbk: qv("pbk"), sid: qv("sid") };
|
||||||
|
}
|
||||||
|
|
||||||
|
// BOOT seeds: BOOT_LINKS or the old single BOOT_* (see boot_seeds)
|
||||||
|
function bootSeeds(v) {
|
||||||
|
if (words(v.BOOT_LINKS).length)
|
||||||
|
return words(v.BOOT_LINKS).map((l, i) => ({ name: i ? `seed${i + 1}` : "seed", ...parseVless(l) }));
|
||||||
|
if (v.BOOT_SERVER)
|
||||||
|
return [{ name: "seed", server: v.BOOT_SERVER, port: v.BOOT_PORT, uuid: v.BOOT_UUID,
|
||||||
|
sni: v.BOOT_SNI, pbk: v.BOOT_PBK, sid: v.BOOT_SID }];
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
const seedVars = (s) => ({ SEED_NAME: s.name, SEED_SERVER: s.server, SEED_PORT: s.port, SEED_UUID: s.uuid,
|
||||||
|
SEED_SNI: s.sni, SEED_PBK: s.pbk, SEED_SID: s.sid });
|
||||||
|
|
||||||
// HY2_<NAME> prefix of an own hysteria2 server's keys (see hy2_key)
|
// HY2_<NAME> prefix of an own hysteria2 server's keys (see hy2_key)
|
||||||
const hy2Key = (name) => "HY2_" + name.replace(/[a-z]/g, (c) => c.toUpperCase()).replace(/-/g, "_");
|
const hy2Key = (name) => "HY2_" + name.replace(/[a-z]/g, (c) => c.toUpperCase()).replace(/-/g, "_");
|
||||||
@ -281,18 +317,26 @@
|
|||||||
if (!["router", "mobile"].includes(v.TARGET)) throw new Error("TARGET must be router or mobile");
|
if (!["router", "mobile"].includes(v.TARGET)) throw new Error("TARGET must be router or mobile");
|
||||||
if (!["home", "street"].includes(v.LOCATION)) throw new Error("LOCATION must be home or street");
|
if (!["home", "street"].includes(v.LOCATION)) throw new Error("LOCATION must be home or street");
|
||||||
if (v.BOOT === "1") {
|
if (v.BOOT === "1") {
|
||||||
for (const k of ["BOOT_SERVER", "BOOT_UUID", "BOOT_SNI", "BOOT_PBK", "BOOT_SID"]) {
|
const seeds = bootSeeds(v);
|
||||||
if (!v[k]) throw new Error(`${k} is empty (BOOT=1)`);
|
if (!seeds.length) throw new Error("BOOT=1 but no BOOT_LINKS (vless links of the seed nodes)");
|
||||||
|
for (const s of seeds) {
|
||||||
|
for (const k of ["server", "uuid", "sni", "pbk", "sid"]) {
|
||||||
|
if (!s[k]) throw new Error(`BOOT ${s.name}: ${k.toUpperCase()} is empty (vless link needs host, uuid, sni, pbk, sid)`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
let on = 0;
|
||||||
subPairs(v.SUBS).forEach(({ id }, i) => {
|
subPairs(v.SUBS).forEach(({ id }, i) => {
|
||||||
if (subGet(v, i, id, "PROXY") === "BOOT" && v.BOOT !== "1") throw new Error(`subscription ${id}: PROXY=BOOT but BOOT=0`);
|
if (subOff(v, i, id)) return;
|
||||||
|
on++;
|
||||||
|
if (/^BOOT(-AUTO)?$/.test(subGet(v, i, id, "PROXY")) && v.BOOT !== "1") throw new Error(`subscription ${id}: PROXY=BOOT but BOOT=0`);
|
||||||
if (subGet(v, i, id, "HWID") === "1") {
|
if (subGet(v, i, id, "HWID") === "1") {
|
||||||
for (const k of ["HWID_OS", "HWID_OS_VER", "HWID_MODEL", "HWID_ID"]) {
|
for (const k of ["HWID_OS", "HWID_OS_VER", "HWID_MODEL", "HWID_ID"]) {
|
||||||
if (!v[k]) throw new Error(`${k} is empty (subscription ${id} has HWID=1)`);
|
if (!v[k]) throw new Error(`${k} is empty (subscription ${id} has HWID=1)`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (!on) throw new Error("all subscriptions are disabled (SUB_<ID>_DISABLED=1)");
|
||||||
for (const name of words(v.HY2)) {
|
for (const name of words(v.HY2)) {
|
||||||
if (!/^[A-Za-z0-9_-]+$/.test(name)) throw new Error(`HY2: bad server name ${name} (letters, digits, _ -)`);
|
if (!/^[A-Za-z0-9_-]+$/.test(name)) throw new Error(`HY2: bad server name ${name} (letters, digits, _ -)`);
|
||||||
for (const key of ["SERVER", "PORT", "PASSWORD"]) {
|
for (const key of ["SERVER", "PORT", "PASSWORD"]) {
|
||||||
@ -306,7 +350,7 @@
|
|||||||
|
|
||||||
// per-subscription variables for the .each templates (see sub_vars in mihomo-kit.sh)
|
// per-subscription variables for the .each templates (see sub_vars in mihomo-kit.sh)
|
||||||
function subVars(v, i, id, url) {
|
function subVars(v, i, id, url) {
|
||||||
let proxy = subGet(v, i, id, "PROXY") || (v.BOOT === "1" ? "BOOT" : "");
|
let proxy = subGet(v, i, id, "PROXY") || (v.BOOT === "1" ? "BOOT-AUTO" : "");
|
||||||
if (proxy === "none") proxy = "";
|
if (proxy === "none") proxy = "";
|
||||||
let ua = subGet(v, i, id, "UA");
|
let ua = subGet(v, i, id, "UA");
|
||||||
let h = subGet(v, i, id, "HEADERS");
|
let h = subGet(v, i, id, "HEADERS");
|
||||||
@ -388,7 +432,9 @@
|
|||||||
check(v);
|
check(v);
|
||||||
const tags = computeTags(v);
|
const tags = computeTags(v);
|
||||||
const subs = subPairs(v.SUBS);
|
const subs = subPairs(v.SUBS);
|
||||||
v.SUB_LIST = subs.map((s) => s.id).join(", ");
|
v.SUB_LIST = subs.filter((s, i) => !subOff(v, i, s.id)).map((s) => s.id).join(", ");
|
||||||
|
const seeds = bootSeeds(v);
|
||||||
|
v.SEED_LIST = seeds.map((s) => s.name).join(", ");
|
||||||
const hy2 = words(v.HY2);
|
const hy2 = words(v.HY2);
|
||||||
v.HY2_LIST = hy2.join(", ");
|
v.HY2_LIST = hy2.join(", ");
|
||||||
v.HY2_MAIN = hy2.length ? "MY, " : "";
|
v.HY2_MAIN = hy2.length ? "MY, " : "";
|
||||||
@ -403,13 +449,19 @@
|
|||||||
const name = path.slice(dir.length + 1, -".yaml".length);
|
const name = path.slice(dir.length + 1, -".yaml".length);
|
||||||
const info = fragmentInfo(name.slice(name.indexOf("-") + 1), tags);
|
const info = fragmentInfo(name.slice(name.indexOf("-") + 1), tags);
|
||||||
if (!info.active) continue;
|
if (!info.active) continue;
|
||||||
if (info.each && info.mod === "hy2") {
|
if (info.each && info.mod === "boot") {
|
||||||
|
for (const s of seeds) {
|
||||||
|
const part = renderText(templates[path], { ...v, ...seedVars(s) }, tags);
|
||||||
|
if (part) parts.push(part);
|
||||||
|
}
|
||||||
|
} else if (info.each && info.mod === "hy2") {
|
||||||
for (const name of hy2) {
|
for (const name of hy2) {
|
||||||
const part = renderText(templates[path], { ...v, ...hy2Vars(v, name) }, tags);
|
const part = renderText(templates[path], { ...v, ...hy2Vars(v, name) }, tags);
|
||||||
if (part) parts.push(part);
|
if (part) parts.push(part);
|
||||||
}
|
}
|
||||||
} else if (info.each) {
|
} else if (info.each) {
|
||||||
subs.forEach((s, i) => {
|
subs.forEach((s, i) => {
|
||||||
|
if (subOff(v, i, s.id)) return;
|
||||||
const part = renderText(templates[path], { ...v, ...subVars(v, i, s.id, s.url) }, tags);
|
const part = renderText(templates[path], { ...v, ...subVars(v, i, s.id, s.url) }, tags);
|
||||||
if (part) parts.push(part);
|
if (part) parts.push(part);
|
||||||
});
|
});
|
||||||
@ -433,25 +485,27 @@
|
|||||||
<script>
|
<script>
|
||||||
const TEMPLATES = {
|
const TEMPLATES = {
|
||||||
"dns/10-base.yaml": "dns:\n enable: true\n ipv6: false\n respect-rules: true\n enhanced-mode: fake-ip\n fake-ip-range: 198.18.0.1/16\n fake-ip-filter:\n - '*.lan'\n - '*.local' #@router\n - '+.ru'\n - '+.xn--p1ai' #@router\n - geosite:ru-inside #@router\n\n default-nameserver:\n - 77.88.8.8\n - 1.1.1.1 #@router\n - 223.5.5.5 #@mobile\n\n proxy-server-nameserver:\n - https://77.88.8.8/dns-query\n\n direct-nameserver:\n - 77.88.8.8\n - 77.88.8.1\n\n nameserver:\n - https://1.1.1.1/dns-query #@router\n - https://dns.google/dns-query\n - https://1.1.1.1/dns-query #@mobile\n",
|
"dns/10-base.yaml": "dns:\n enable: true\n ipv6: false\n respect-rules: true\n enhanced-mode: fake-ip\n fake-ip-range: 198.18.0.1/16\n fake-ip-filter:\n - '*.lan'\n - '*.local' #@router\n - '+.ru'\n - '+.xn--p1ai' #@router\n - geosite:ru-inside #@router\n\n default-nameserver:\n - 77.88.8.8\n - 1.1.1.1 #@router\n - 223.5.5.5 #@mobile\n\n proxy-server-nameserver:\n - https://77.88.8.8/dns-query\n\n direct-nameserver:\n - 77.88.8.8\n - 77.88.8.1\n\n nameserver:\n - https://1.1.1.1/dns-query #@router\n - https://dns.google/dns-query\n - https://1.1.1.1/dns-query #@mobile\n",
|
||||||
"groups/10-boot.yaml": " - name: BOOT\n type: select\n proxies: [seed]\n",
|
"groups/10-boot.yaml": " # BOOT: whitelisted entry nodes (BOOT_LINKS), the first alive one\n - name: BOOT\n type: fallback\n proxies: [${SEED_LIST}]\n url: \"https://www.gstatic.com/generate_204\"\n interval: 300\n lazy: false\n\n # default for downloading subscriptions: BOOT, else the nodes of the saved\n # subscriptions (providers are cached on disk), else direct\n - name: BOOT-AUTO\n type: fallback\n proxies: [BOOT, FOREIGN, DIRECT]\n url: \"https://www.gstatic.com/generate_204\"\n interval: 300\n lazy: false\n",
|
||||||
"groups/20-sub.yaml": " - name: RU\n type: url-test\n use: [${SUB_LIST}]\n filter: \"(?i)🇷🇺|\\\\bru\\\\b|russia|росси|моск\"\n url: \"https://ya.ru\"\n interval: 300\n tolerance: 50\n lazy: false\n\n - name: FOREIGN\n type: url-test\n use: [${SUB_LIST}]\n exclude-filter: \"(?i)🇷🇺|\\\\bru\\\\b|russia|росси|моск\"\n url: \"https://www.gstatic.com/generate_204\"\n interval: 300\n tolerance: 50\n lazy: false\n",
|
"groups/20-sub.yaml": " - name: RU\n type: url-test\n use: [${SUB_LIST}]\n filter: \"(?i)🇷🇺|\\\\bru\\\\b|russia|росси|моск\"\n url: \"https://ya.ru\"\n interval: 300\n tolerance: 50\n lazy: false\n\n - name: FOREIGN\n type: url-test\n use: [${SUB_LIST}]\n exclude-filter: \"(?i)🇷🇺|\\\\bru\\\\b|russia|росси|моск\"\n url: \"https://www.gstatic.com/generate_204\"\n interval: 300\n tolerance: 50\n lazy: false\n",
|
||||||
"groups/30-torrent.yaml": " - name: TORRENT\n type: url-test\n use: [${SUB_LIST}]\n filter: \"(?i)torrent|\\\\[tor\\\\]\"\n url: \"https://www.gstatic.com/generate_204\"\n interval: 300\n timeout: 6000\n tolerance: 500\n max-failed-times: 5\n lazy: false\n",
|
"groups/30-torrent.yaml": " - name: TORRENT\n type: url-test\n use: [${SUB_LIST}]\n filter: \"(?i)torrent|\\\\[tor\\\\]\"\n url: \"https://www.gstatic.com/generate_204\"\n interval: 300\n timeout: 6000\n tolerance: 500\n max-failed-times: 5\n lazy: false\n",
|
||||||
"groups/40-openvpn.yaml": " # url: what the dashboard's delay test opens through the tunnel;\n # interval 0: no background checks (they would redial with a stale OTP)\n - name: ${OVPN_GROUP}\n type: select\n use: [${OVPN_PROVIDER}]\n url: \"${OVPN_CHECK_URL}\"\n interval: 0\n",
|
"groups/40-openvpn.yaml": " # url: what the dashboard's delay test opens through the tunnel;\n # interval 0: no background checks (they would redial with a stale OTP)\n - name: ${OVPN_GROUP}\n type: select\n use: [${OVPN_PROVIDER}]\n url: \"${OVPN_CHECK_URL}\"\n interval: 0\n",
|
||||||
"groups/41-openvpn.street.yaml": " # what the OpenVPN tunnel itself goes through on a whitelisted network.\n # select, not url-test: switching nodes would break the tunnel.\n # Pick a concrete RU node in the dashboard, the choice is remembered.\n - name: OVPN-EXIT\n type: select\n use: [${SUB_LIST}]\n filter: \"(?i)🇷🇺|\\\\bru\\\\b|russia|росси|моск\"\n",
|
"groups/41-openvpn.street.yaml": " # what the OpenVPN tunnel itself goes through on a whitelisted network.\n # select, not url-test: switching nodes would break the tunnel.\n # Pick a concrete RU node in the dashboard, the choice is remembered.\n - name: OVPN-EXIT\n type: select\n use: [${SUB_LIST}]\n filter: \"(?i)🇷🇺|\\\\bru\\\\b|russia|росси|моск\"\n",
|
||||||
"groups/45-hy2.yaml": " # own hysteria2 servers: the fastest alive one; pin one in the dashboard if needed\n - name: MY\n type: url-test\n proxies: [${HY2_LIST}]\n url: \"https://www.gstatic.com/generate_204\"\n interval: 300\n tolerance: 50\n lazy: false\n",
|
"groups/45-hy2.yaml": " # own hysteria2 servers: the fastest alive one; pin one in the dashboard if needed\n - name: MY\n type: url-test\n proxies: [${HY2_LIST}]\n url: \"https://www.gstatic.com/generate_204\"\n interval: 300\n tolerance: 50\n lazy: false\n\n # street: what own servers are reached through; switches only when the node is\n # clearly worse or dead (each switch breaks everything going through MY)\n - name: MY-EXIT #@street\n type: url-test #@street\n use: [${SUB_LIST}] #@street\n exclude-filter: \"(?i)🇷🇺|\\\\bru\\\\b|russia|росси|моск\" #@street\n url: \"https://www.gstatic.com/generate_204\" #@street\n interval: 300 #@street\n tolerance: 300 #@street\n lazy: false #@street\n",
|
||||||
"groups/50-tailscale.yaml": " # url (TS_CHECK_URL, optional): a tailnet service for the dashboard's delay test\n - name: TAILSCALE\n type: select\n proxies: [tailscale]\n url: \"${@TS_CHECK_URL}\"\n interval: 0\n",
|
"groups/50-tailscale.yaml": " # url (TS_CHECK_URL, optional): a tailnet service for the dashboard's delay test\n - name: TAILSCALE\n type: select\n proxies: [tailscale]\n url: \"${@TS_CHECK_URL}\"\n interval: 0\n",
|
||||||
"groups/51-tailscale.ts_exit.yaml": " # Tailscale needs full-cone UDP from its dialer-proxy: vless/vmess/trojan\n # cannot do it in mihomo, so only ss / hysteria2 / tuic / socks5 nodes here.\n - name: TS-EXIT\n type: select\n proxies: [MY] #@hy2\n use: [${SUB_LIST}]\n exclude-type: \"vless|vmess|trojan\"\n",
|
"groups/51-tailscale.ts_exit.yaml": " # Tailscale needs full-cone UDP from its dialer-proxy: vless/vmess/trojan\n # cannot do it in mihomo, so only ss / hysteria2 / tuic / socks5 nodes here.\n - name: TS-EXIT\n type: select\n proxies: [MY] #@hy2\n use: [${SUB_LIST}]\n exclude-type: \"vless|vmess|trojan\"\n",
|
||||||
"groups/90-base.yaml": " - name: MAIN\n type: select\n proxies: [FOREIGN, ${HY2_MAIN}RU, DIRECT]\n",
|
"groups/90-base.yaml": " - name: MAIN\n type: select\n proxies: [FOREIGN, ${HY2_MAIN}RU, DIRECT]\n",
|
||||||
"groups/91-torrent.yaml": " - name: TORRENT-SEL\n type: select\n proxies: [TORRENT, FOREIGN, DIRECT]\n",
|
"groups/91-torrent.yaml": " - name: TORRENT-SEL\n type: select\n proxies: [TORRENT, FOREIGN, DIRECT]\n",
|
||||||
|
"groups/92-base.router.yaml": " - name: PUSH\n type: select\n proxies: [DIRECT, ${HY2_MAIN}FOREIGN] #@home\n proxies: [${HY2_MAIN}FOREIGN, DIRECT] #@street\n",
|
||||||
"head/10-base.yaml": "geodata-mode: true\ngeodata-loader: memconservative\ngeo-auto-update: true\ngeo-update-interval: 24\ngeox-url:\n geoip: \"${GEOIP_URL}\"\n geosite: \"${GEOSITE_URL}\"\n",
|
"head/10-base.yaml": "geodata-mode: true\ngeodata-loader: memconservative\ngeo-auto-update: true\ngeo-update-interval: 24\ngeox-url:\n geoip: \"${GEOIP_URL}\"\n geosite: \"${GEOSITE_URL}\"\n",
|
||||||
"providers/10-sub.each.yaml": " ${SUB_NAME}:\n type: http\n url: \"${SUB_URL}\"\n path: ./providers/${SUB_NAME}.yaml\n interval: 3600\n proxy: ${@SUB_PROXY}\n exclude-filter: \"(?i)app not supported|приложение не|свяжитесь\"\n header:\n User-Agent: [\"${SUB_UA}\"]\n ${@@SUB_HEADERS}\n health-check:\n enable: true\n url: \"https://www.gstatic.com/generate_204\"\n interval: 300\n timeout: 3000\n lazy: false\n",
|
"providers/10-sub.each.yaml": " ${SUB_NAME}:\n type: http\n url: \"${SUB_URL}\"\n path: ./providers/${SUB_NAME}.yaml\n interval: 3600\n proxy: ${@SUB_PROXY}\n exclude-filter: \"(?i)app not supported|приложение не|свяжитесь\"\n header:\n User-Agent: [\"${SUB_UA}\"]\n ${@@SUB_HEADERS}\n health-check:\n enable: true\n url: \"https://www.gstatic.com/generate_204\"\n interval: 300\n timeout: 3000\n lazy: false\n",
|
||||||
"providers/20-openvpn.yaml": " # OpenVPN: file written on the router by bmstu-otp.sh (fresh TOTP in the\n # password). No health-check here: a dead tunnel would be redialed with a\n # stale OTP; the cron watchdog (bmstu-otp.sh check) handles it.\n ${OVPN_PROVIDER}:\n type: file\n path: ./providers/${OVPN_PROVIDER}.yaml\n health-check:\n enable: false\n override: #@street\n dialer-proxy: OVPN-EXIT #@street\n",
|
"providers/20-openvpn.yaml": " # OpenVPN: file written on the router by bmstu-otp.sh (fresh TOTP in the\n # password). No health-check here: a dead tunnel would be redialed with a\n # stale OTP; the cron watchdog (bmstu-otp.sh check) handles it.\n ${OVPN_PROVIDER}:\n type: file\n path: ./providers/${OVPN_PROVIDER}.yaml\n health-check:\n enable: false\n override: #@street\n dialer-proxy: OVPN-EXIT #@street\n",
|
||||||
"proxies/10-boot.yaml": " # BOOT: whitelisted entry node, used to download subscriptions\n - name: seed\n type: vless\n server: ${BOOT_SERVER}\n port: ${BOOT_PORT}\n uuid: ${BOOT_UUID}\n network: tcp\n udp: true\n tls: true\n flow: xtls-rprx-vision\n servername: ${BOOT_SNI}\n client-fingerprint: firefox\n reality-opts:\n public-key: ${BOOT_PBK}\n short-id: ${BOOT_SID}\n",
|
"proxies/10-boot.each.yaml": " - name: ${SEED_NAME}\n type: vless\n server: ${SEED_SERVER}\n port: ${SEED_PORT}\n uuid: ${SEED_UUID}\n network: tcp\n udp: true\n tls: true\n flow: xtls-rprx-vision\n servername: ${SEED_SNI}\n client-fingerprint: firefox\n reality-opts:\n public-key: ${SEED_PBK}\n short-id: ${SEED_SID}\n",
|
||||||
"proxies/20-tailscale.yaml": " # Tailscale: userspace node, starts on first use. First login: open the URL\n # from the nikki log (\"To start this tsnet server ... go to: ...\"), then\n # disable key expiry for this node. Needs TS_FORCE_NOISE_443=true in the\n # mihomo environment (mihomo-kit.sh fix).\n - name: tailscale\n type: tailscale\n hostname: ${TS_HOSTNAME}\n state-dir: ./tailscale\n udp: true\n accept-routes: true\n dialer-proxy: TS-EXIT #@ts_exit\n",
|
"proxies/20-tailscale.yaml": " # Tailscale: userspace node, starts on first use. First login: open the URL\n # from the nikki log (\"To start this tsnet server ... go to: ...\"), then\n # disable key expiry for this node. Needs TS_FORCE_NOISE_443=true in the\n # mihomo environment (mihomo-kit.sh fix).\n - name: tailscale\n type: tailscale\n hostname: ${TS_HOSTNAME}\n state-dir: ./tailscale\n udp: true\n accept-routes: true\n dialer-proxy: TS-EXIT #@ts_exit\n",
|
||||||
"proxies/30-hy2.each.yaml": " - name: ${HY2_NAME}\n type: hysteria2\n server: ${HY2_SERVER}\n port: ${HY2_PORT}\n password: \"${HY2_PASSWORD}\"\n obfs: ${@HY2_OBFS}\n obfs-password: \"${@@HY2_OBFS_PASSWORD}\"\n sni: ${@HY2_SNI}\n skip-cert-verify: ${HY2_INSECURE}\n up: \"${@@HY2_UP}\"\n down: \"${@@HY2_DOWN}\"\n udp: true\n dialer-proxy: FOREIGN #@street\n",
|
"proxies/30-hy2.each.yaml": " - name: ${HY2_NAME}\n type: hysteria2\n server: ${HY2_SERVER}\n port: ${HY2_PORT}\n password: \"${HY2_PASSWORD}\"\n obfs: ${@HY2_OBFS}\n obfs-password: \"${@@HY2_OBFS_PASSWORD}\"\n sni: ${@HY2_SNI}\n skip-cert-verify: ${HY2_INSECURE}\n up: \"${@@HY2_UP}\"\n down: \"${@@HY2_DOWN}\"\n udp: true\n dialer-proxy: MY-EXIT #@street\n",
|
||||||
"rules/10-tailscale.yaml": " # Tailscale: tailnet IPs and MagicDNS names (resolved by tailscale itself)\n - IP-CIDR,100.64.0.0/10,TAILSCALE,no-resolve\n - DOMAIN-SUFFIX,ts.net,TAILSCALE\n - DOMAIN-SUFFIX,${@TS_DOMAINS},TAILSCALE\n",
|
"rules/10-tailscale.yaml": " # Tailscale: tailnet IPs and MagicDNS names (resolved by tailscale itself)\n - IP-CIDR,100.64.0.0/10,TAILSCALE,no-resolve\n - DOMAIN-SUFFIX,ts.net,TAILSCALE\n - DOMAIN-SUFFIX,${@TS_DOMAINS},TAILSCALE\n",
|
||||||
"rules/20-openvpn.yaml": " # OpenVPN server itself must not go into its own tunnel\n - IP-CIDR,${@OVPN_SERVER_IPS}/32,DIRECT,no-resolve #@home\n - IP-CIDR,${@OVPN_SERVER_IPS}/32,OVPN-EXIT,no-resolve #@street\n - DOMAIN,${OVPN_SERVER_HOST},DIRECT #@home\n - DOMAIN,${OVPN_SERVER_HOST},OVPN-EXIT #@street\n # networks pushed by the server (before the private-range DIRECT rules)\n - IP-CIDR,${@OVPN_ROUTES},${OVPN_GROUP},no-resolve\n",
|
"rules/20-openvpn.yaml": " # OpenVPN server itself must not go into its own tunnel\n - IP-CIDR,${@OVPN_SERVER_IPS}/32,DIRECT,no-resolve #@home\n - IP-CIDR,${@OVPN_SERVER_IPS}/32,OVPN-EXIT,no-resolve #@street\n - DOMAIN,${OVPN_SERVER_HOST},DIRECT #@home\n - DOMAIN,${OVPN_SERVER_HOST},OVPN-EXIT #@street\n # networks pushed by the server (before the private-range DIRECT rules)\n - IP-CIDR,${@OVPN_ROUTES},${OVPN_GROUP},no-resolve\n",
|
||||||
"rules/30-base.yaml": " - IP-CIDR,192.168.0.0/16,DIRECT,no-resolve\n - IP-CIDR,10.0.0.0/8,DIRECT,no-resolve\n - IP-CIDR,172.16.0.0/12,DIRECT,no-resolve\n",
|
"rules/30-base.yaml": " - IP-CIDR,192.168.0.0/16,DIRECT,no-resolve\n - IP-CIDR,10.0.0.0/8,DIRECT,no-resolve\n - IP-CIDR,172.16.0.0/12,DIRECT,no-resolve\n",
|
||||||
|
"rules/35-base.router.yaml": " # push notifications (Apple APNs, Google FCM): long-lived connections on a\n # stable path - group PUSH (home: DIRECT, street: MY)\n - DOMAIN-SUFFIX,push.apple.com,PUSH\n - IP-CIDR,17.249.0.0/16,PUSH,no-resolve\n - IP-CIDR,17.252.0.0/16,PUSH,no-resolve\n - IP-CIDR,17.57.144.0/22,PUSH,no-resolve\n - IP-CIDR,17.188.128.0/18,PUSH,no-resolve\n - IP-CIDR,17.188.20.0/23,PUSH,no-resolve\n - DOMAIN-REGEX,^(alt[0-9]+-)?mtalk[0-9]*\\.google\\.com$,PUSH\n - DST-PORT,5228-5230,PUSH\n",
|
||||||
"rules/40-base.yaml": " - IP-CIDR,${@RU_IPS},RU\n",
|
"rules/40-base.yaml": " - IP-CIDR,${@RU_IPS},RU\n",
|
||||||
"rules/50-torrent.yaml": " - SRC-PORT,20000-20199,TORRENT-SEL\n",
|
"rules/50-torrent.yaml": " - SRC-PORT,20000-20199,TORRENT-SEL\n",
|
||||||
"rules/90-base.yaml": " - GEOSITE,ru-inside,DIRECT\n - DOMAIN-SUFFIX,ru,RU\n - DOMAIN-SUFFIX,xn--p1ai,RU\n - MATCH,MAIN\n",
|
"rules/90-base.yaml": " - GEOSITE,ru-inside,DIRECT\n - DOMAIN-SUFFIX,ru,RU\n - DOMAIN-SUFFIX,xn--p1ai,RU\n - MATCH,MAIN\n",
|
||||||
@ -473,7 +527,7 @@ function addSub() {
|
|||||||
<input type="text" data-k="url" placeholder="https://sub.example.com/sub/xxxx или имя=https://…">
|
<input type="text" data-k="url" placeholder="https://sub.example.com/sub/xxxx или имя=https://…">
|
||||||
<button type="button" class="x-btn" title="убрать">×</button></div>
|
<button type="button" class="x-btn" title="убрать">×</button></div>
|
||||||
<div class="sub-opts">
|
<div class="sub-opts">
|
||||||
<label>через <select data-k="proxy"><option value="">авто</option><option>BOOT</option><option>DIRECT</option><option>FOREIGN</option></select></label>
|
<label>через <select data-k="proxy"><option value="">авто</option><option>BOOT-AUTO</option><option>BOOT</option><option>DIRECT</option><option>FOREIGN</option></select></label>
|
||||||
<label class="check"><input type="checkbox" data-k="hwid">HWID</label>
|
<label class="check"><input type="checkbox" data-k="hwid">HWID</label>
|
||||||
</div>
|
</div>
|
||||||
<details><summary>User-Agent и заголовки</summary>
|
<details><summary>User-Agent и заголовки</summary>
|
||||||
|
|||||||
@ -108,7 +108,7 @@
|
|||||||
<legend>Подписки</legend>
|
<legend>Подписки</legend>
|
||||||
<div id="subs"></div>
|
<div id="subs"></div>
|
||||||
<button type="button" class="link-btn" id="add-sub">+ подписка</button>
|
<button type="button" class="link-btn" id="add-sub">+ подписка</button>
|
||||||
<p class="hint">«Через»: откуда качать подписку. Авто = BOOT, если он включён.
|
<p class="hint">«Через»: откуда качать подписку. Авто = BOOT-AUTO (BOOT, иначе ноды сохранённых подписок, иначе напрямую), если BOOT включён.
|
||||||
HWID — для подписок с лимитом устройств (x-hwid, x-device-os, …).</p>
|
HWID — для подписок с лимитом устройств (x-hwid, x-device-os, …).</p>
|
||||||
<label for="RU_IPS">Доп. IP через RU (CIDR через пробел)</label>
|
<label for="RU_IPS">Доп. IP через RU (CIDR через пробел)</label>
|
||||||
<input type="text" id="RU_IPS" value="194.190.191.112/32">
|
<input type="text" id="RU_IPS" value="194.190.191.112/32">
|
||||||
@ -206,7 +206,7 @@ function addSub() {
|
|||||||
<input type="text" data-k="url" placeholder="https://sub.example.com/sub/xxxx или имя=https://…">
|
<input type="text" data-k="url" placeholder="https://sub.example.com/sub/xxxx или имя=https://…">
|
||||||
<button type="button" class="x-btn" title="убрать">×</button></div>
|
<button type="button" class="x-btn" title="убрать">×</button></div>
|
||||||
<div class="sub-opts">
|
<div class="sub-opts">
|
||||||
<label>через <select data-k="proxy"><option value="">авто</option><option>BOOT</option><option>DIRECT</option><option>FOREIGN</option></select></label>
|
<label>через <select data-k="proxy"><option value="">авто</option><option>BOOT-AUTO</option><option>BOOT</option><option>DIRECT</option><option>FOREIGN</option></select></label>
|
||||||
<label class="check"><input type="checkbox" data-k="hwid">HWID</label>
|
<label class="check"><input type="checkbox" data-k="hwid">HWID</label>
|
||||||
</div>
|
</div>
|
||||||
<details><summary>User-Agent и заголовки</summary>
|
<details><summary>User-Agent и заголовки</summary>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user