Added hy2

This commit is contained in:
Sam Latsin 2026-10-09 18:12:54 +03:00
parent e756608011
commit 3affe0aeb9
14 changed files with 308 additions and 29 deletions

View File

@ -91,6 +91,12 @@ x-device-os, x-ver-os, x-device-model, x-hwid). Порядок подписок
переименовывает их по имени. Если провайдер сменит домен, сменится и имя — задай его переименовывает их по имени. Если провайдер сменит домен, сменится и имя — задай его
явно, чтобы настройки не потерялись. явно, чтобы настройки не потерялись.
Свои серверы hysteria2 — LuCI → Настройка → «Свои серверы» (или `HY2="имя1 имя2"` и
`HY2_<ИМЯ>_SERVER/_PORT/_PASSWORD/_OBFS_PASSWORD/_SNI/_INSECURE/_UP/_DOWN` в
`common.env`). Они попадают в группу `MAIN` рядом с `FOREIGN` (и в `TS-EXIT`, если он
включён) и выбираются вручную в дашборде — в автовыборе не участвуют. На профиле `street`
к ним идут через ноду `FOREIGN` (`dialer-proxy`), на `home` — напрямую.
Новый профиль = новый файл в `profiles.d/` (например `LOCATION=home` + `OPENVPN=0`), Новый профиль = новый файл в `profiles.d/` (например `LOCATION=home` + `OPENVPN=0`),
затем `mihomo-kit.sh build && mihomo-kit.sh use <имя>`. Все опции — в затем `mihomo-kit.sh build && mihomo-kit.sh use <имя>`. Все опции — в
[router/profile.env.example](router/profile.env.example). [router/profile.env.example](router/profile.env.example).
@ -155,14 +161,15 @@ tests/fixtures/ профили для test.sh (фиктивные секре
Шаблоны: `templates/<секция>/NN-<модуль>[.<тег>...][.each].yaml`; секции собираются в Шаблоны: `templates/<секция>/NN-<модуль>[.<тег>...][.each].yaml`; секции собираются в
порядке head, proxies, providers, sniffer, dns, groups, rules, файлы — по имени. порядке head, proxies, providers, sniffer, dns, groups, rules, файлы — по имени.
- файл включается, если активны модуль и все теги; `.each` — по разу на подписку - файл включается, если активны модуль и все теги; `.each` — по разу на элемент модуля
(`${SUB_NAME}`, `${SUB_URL}`); (`sub` — подписка: `${SUB_NAME}`, `${SUB_URL}`; `hy2` — свой сервер: `${HY2_NAME}`, ...);
- `${@@VAR}` — строка повторяется для каждой строки `VAR` (пустая `VAR` — строки нет);
- `строка #@тег[,!тег]` — строка остаётся, только если условия выполнены; - `строка #@тег[,!тег]` — строка остаётся, только если условия выполнены;
- `${@VAR}` — строка повторяется для каждого слова из `VAR`; - `${@VAR}` — строка повторяется для каждого слова из `VAR`;
- `${VAR}` — подстановка. - `${VAR}` — подстановка.
Теги: `base`, `sub`, `router`|`mobile`, `home`|`street` (роутер), `boot`, `torrent`, Теги: `base`, `sub`, `router`|`mobile`, `home`|`street` (роутер), `boot`, `torrent`,
`openvpn`, `tailscale`, `ts_exit`. Значения по умолчанию — `set_defaults` в `openvpn`, `tailscale`, `ts_exit`, `hy2`. Значения по умолчанию — `set_defaults` в
`router/mihomo-kit.sh` и `DEFAULTS` в `web/engine.js` (держать одинаковыми). `router/mihomo-kit.sh` и `DEFAULTS` в `web/engine.js` (держать одинаковыми).
После правки шаблонов или движка: После правки шаблонов или движка:

View File

@ -26,6 +26,10 @@ else
rm -rf "${KIT_DIR:?}/$d" rm -rf "${KIT_DIR:?}/$d"
cp -r "$src/$d" "$KIT_DIR/" cp -r "$src/$d" "$KIT_DIR/"
done done
# commit id from the git archive header (same as kit_version in mihomo-kit.sh)
sha=$(gunzip -c "$tmp/kit.tgz" | head -c 1536 | tr -c 'a-z0-9=\n' '\n' |
grep '^comment=[0-9a-f]\{40\}$' | head -n 1 | cut -c9-15) || true
echo "${sha:-?} $(date '+%Y-%m-%d %H:%M')" > "$KIT_DIR/VERSION"
rm -rf "$tmp" rm -rf "$tmp"
fi fi
# stdin may be the piped script: the wizard (setup --cli) reads answers from /dev/tty # stdin may be the piped script: the wizard (setup --cli) reads answers from /dev/tty

View File

@ -95,9 +95,16 @@ return view.extend({
return E('option', { 'value': p }, p); return E('option', { 'value': p }, p);
})); }));
select.value = st.profile; select.value = st.profile;
// mihomo serves its external-ui at /ui; metacubexd/zashboard take the API from the query
var host = window.location.hostname;
var dash = 'http://' + host + ':' + st.api_port + '/ui/?hostname=' + encodeURIComponent(host) +
'&port=' + st.api_port + (st.api_secret ? '&secret=' + encodeURIComponent(st.api_secret) : '');
sections.push(section('Состояние', [ sections.push(section('Состояние', [
E('table', { 'class': 'table' }, [ E('table', { 'class': 'table' }, [
row('nikki', st.running ? 'работает' : E('strong', 'остановлен')), row('nikki', st.running ? [ 'работает — ',
E('a', { 'href': dash, 'target': '_blank', 'rel': 'noreferrer' }, 'открыть дашборд') ]
: E('strong', 'остановлен')),
row('Версия kit', st.kit_version || 'неизвестна (появится после «Обновить kit»)'),
row('Профиль', [ select, ' ', row('Профиль', [ select, ' ',
this.button('Включить', 'apply', 'use', function() { return select.value; }) ]) this.button('Включить', 'apply', 'use', function() { return select.value; }) ])
]) ])
@ -218,6 +225,39 @@ return view.extend({
}; };
(cfg.subs && cfg.subs.length ? cfg.subs : [ {} ]).forEach(addSub); (cfg.subs && cfg.subs.length ? cfg.subs : [ {} ]).forEach(addSub);
// own hysteria2 servers: one block of fields each
var hy2List = E('div'), hy2 = [];
var addHy2 = function(h) {
var e = {
name: text(h.name, 'nl-1'),
server: text(h.server, 'vpn.example.com'),
port: text(h.port || '443'),
password: text(h.password, '', 'password'),
obfs_password: text(h.obfs_password, 'пусто — без obfs', 'password'),
sni: text(h.sni, 'пусто — как server'),
insecure: check(h.insecure == '1'),
up: text(h.up, '50 mbps'),
down: text(h.down, '100 mbps')
};
var el = E('div', { 'style': 'border:1px solid #8884;border-radius:4px;padding:.5em;margin-bottom:.5em' }, [
field('Имя', e.name, 'буквы, цифры, _ - ; так сервер виден в дашборде'),
field('Сервер', e.server),
field('Порт', e.port),
field('Пароль', e.password, 'auth.password на сервере'),
field('Obfs-пароль', e.obfs_password, 'salamander; пусто — без obfs'),
field('SNI', e.sni),
field('Не проверять сертификат', e.insecure, 'для самоподписанного сертификата (SNI чужого сайта)'),
field('Up / Down', [ e.up, e.down ], 'реальный потолок канала клиента; пусто — без ограничения'),
E('button', { 'class': 'btn cbi-button cbi-button-remove', 'click': function() {
hy2List.removeChild(el);
hy2.splice(hy2.indexOf(e), 1);
} }, 'Удалить сервер')
]);
hy2.push(e);
hy2List.appendChild(el);
};
(cfg.hy2 || []).forEach(addHy2);
dom.content(hwidBox, [ dom.content(hwidBox, [
E('h4', 'HWID (общий для подписок с галкой HWID)'), E('h4', 'HWID (общий для подписок с галкой HWID)'),
field('User-Agent', f.hwid_ua), field('User-Agent', f.hwid_ua),
@ -261,6 +301,21 @@ return view.extend({
if (!cfg.has_totp && !f.totp_secret.value.trim()) if (!cfg.has_totp && !f.totp_secret.value.trim())
errors.push('OpenVPN: нужен TOTP-секрет'); errors.push('OpenVPN: нужен TOTP-секрет');
} }
var names = {};
var hy2Data = hy2.map(function(e) {
var d = {};
Object.keys(e).forEach(function(k) {
d[k] = k == 'insecure' ? e[k].checked : (k == 'password' || k == 'obfs_password' ? e[k].value : e[k].value.trim());
});
if (!/^[A-Za-z0-9_-]+$/.test(d.name))
errors.push('Свой сервер: имя «' + d.name + '» — только буквы, цифры, _ -');
else if (names[d.name.toUpperCase().replace(/-/g, '_')])
errors.push('Свой сервер: имя ' + d.name + ' повторяется');
names[d.name.toUpperCase().replace(/-/g, '_')] = true;
if (!d.server || !/^[0-9]+$/.test(d.port) || !d.password)
errors.push('Свой сервер ' + (d.name || '?') + ': нужны сервер, порт и пароль');
return d;
});
if (errors.length) { if (errors.length) {
ui.addNotification(null, errors.map(function(e) { return E('p', e); }), 'danger'); ui.addNotification(null, errors.map(function(e) { return E('p', e); }), 'danger');
return; return;
@ -280,7 +335,8 @@ return view.extend({
totp_secret: f.totp_secret.value.replace(/\s+/g, ''), totp_secret: f.totp_secret.value.replace(/\s+/g, ''),
tailscale: f.tailscale.checked, tailscale: f.tailscale.checked,
ts_hostname: f.ts_hostname.value.trim(), ts_hostname: f.ts_hostname.value.trim(),
ts_domains: f.ts_domains.value.trim() ts_domains: f.ts_domains.value.trim(),
hy2: hy2Data
}); });
}, this)).then(L.bind(function(r) { }, this)).then(L.bind(function(r) {
if (r.error) { if (r.error) {
@ -310,6 +366,11 @@ return view.extend({
ovpnBox, ovpnBox,
field('Tailscale', f.tailscale), field('Tailscale', f.tailscale),
tsBox, tsBox,
E('h4', 'Свои серверы (hysteria2)'),
E('p', { 'class': 'cbi-value-description' }, 'Появляются в группе MAIN рядом с FOREIGN (и в TS-EXIT) — ' +
'выбираются вручную в дашборде, в автовыборе не участвуют. На профиле street идут через FOREIGN-ноду, на home — напрямую.'),
hy2List,
E('button', { 'class': 'btn cbi-button cbi-button-add', 'click': function() { addHy2({}); } }, 'Добавить сервер'),
E('div', { 'class': 'cbi-page-actions' }, [ save ]) E('div', { 'class': 'cbi-page-actions' }, [ save ])
]); ]);
}, },

View File

@ -1,7 +1,8 @@
#!/bin/sh #!/bin/sh
# rpcd plugin "mihomo-kit" for the LuCI page (installed as /usr/libexec/rpcd/mihomo-kit). # rpcd plugin "mihomo-kit" for the LuCI page (installed as /usr/libexec/rpcd/mihomo-kit).
# #
# status profile, nikki running, which features are on # status profile, nikki running, which features are on, kit version,
# mihomo API port/secret (dashboard link)
# ovpn_status OpenVPN state (up/down/off) + current OTP; slow (a delay test) # ovpn_status OpenVPN state (up/down/off) + current OTP; slow (a delay test)
# run start a whitelisted command as the background job # run start a whitelisted command as the background job
# job the job's command, state, exit code and output # job the job's command, state, exit code and output
@ -57,6 +58,12 @@ m_status() {
json_add_boolean openvpn "$(b test "$(envval OPENVPN "$prof")" = 1)" json_add_boolean openvpn "$(b test "$(envval OPENVPN "$prof")" = 1)"
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)"
l=$(uci -q get nikki.mixin.api_listen)
port=${l##*:}
case "$port" in '' | *[!0-9]*) port=9090 ;; esac
json_add_int api_port "$port"
json_add_string api_secret "$(uci -q get nikki.mixin.api_secret)"
json_dump json_dump
} }
@ -156,12 +163,25 @@ m_config_get() {
json_add_boolean tailscale "${TAILSCALE:-0}" json_add_boolean tailscale "${TAILSCALE:-0}"
json_add_string ts_hostname "${TS_HOSTNAME:-$(uci -q get 'system.@system[0].hostname' | tr 'A-Z' 'a-z')-mihomo}" json_add_string ts_hostname "${TS_HOSTNAME:-$(uci -q get 'system.@system[0].hostname' | tr 'A-Z' 'a-z')-mihomo}"
json_add_string ts_domains "${TS_DOMAINS:-}" json_add_string ts_domains "${TS_DOMAINS:-}"
json_add_array hy2
for n in ${HY2:-}; do
k=HY2_$(echo "$n" | tr 'a-z-' 'A-Z_')
json_add_object ""
json_add_string name "$n"
for v in server port password obfs_password sni insecure up down; do
eval "val=\${${k}_$(echo "$v" | tr 'a-z' 'A-Z'):-}"
json_add_string "$v" "$val"
done
json_close_object
done
json_close_array
json_dump json_dump
} }
# {"data": {boot_link, subs: [{url, via, hwid}], hwid_*, torrent, ru_ips, # {"data": {boot_link, 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}}; empty secrets keep the saved ones # tailscale, ts_hostname, ts_domains, hy2: [{name, server, port, password,
# obfs_password, sni, insecure, up, down}]}}; empty OpenVPN secrets keep the saved ones
m_config_set() { 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"
@ -210,6 +230,27 @@ m_config_set() {
echo "TAILSCALE=$(q "${tailscale:-0}")" echo "TAILSCALE=$(q "${tailscale:-0}")"
echo "TS_HOSTNAME=$(q "$ts_hostname")" echo "TS_HOSTNAME=$(q "$ts_hostname")"
echo "TS_DOMAINS=$(q "$ts_domains")" echo "TS_DOMAINS=$(q "$ts_domains")"
echo "HY2_SET=1"
hy2=
if json_select hy2; then
json_get_keys keys
for k in $keys; do
json_select "$k"
json_get_var name name ""
name=$(printf '%s' "$name" | tr -d ' \t\r\n')
if [ -n "$name" ]; then
hy2="${hy2:+$hy2 }$name"
K=HY2_$(echo "$name" | tr 'a-z-' 'A-Z_')
for v in server port password obfs_password sni insecure up down; do
json_get_var val "$v" ""
echo "${K}_$(echo "$v" | tr 'a-z' 'A-Z')=$(q "$val")"
done
fi
json_select ..
done
json_select ..
fi
echo "HY2=$(q "$hy2")"
} > "$env" } > "$env"
umask 022 umask 022
start_job mihomo-kit.sh configure "$env" start_job mihomo-kit.sh configure "$env"

View File

@ -41,7 +41,8 @@ die() { log "error: $*"; exit 1; }
# --- rendering -------------------------------------------------------------- # --- rendering --------------------------------------------------------------
# Template syntax (same in web/engine.js): # Template syntax (same in web/engine.js):
# file NN-<module>[.<tag>...][.each].yaml included if module and tags are active; # file NN-<module>[.<tag>...][.each].yaml included if module and tags are active;
# .each = once per subscription # .each = once per item of the module:
# sub - subscription, hy2 - own server
# line ... #@tag[,!tag] kept only if the conditions hold # line ... #@tag[,!tag] kept only if the conditions hold
# line ... ${@VAR} ... repeated for every word of VAR # line ... ${@VAR} ... repeated for every word of VAR
# line ... ${@@VAR} ... repeated for every line of VAR # line ... ${@@VAR} ... repeated for every line of VAR
@ -50,7 +51,7 @@ die() { log "error: $*"; exit 1; }
set_defaults() { set_defaults() {
: "${TARGET:=router}" "${LOCATION:=home}" : "${TARGET:=router}" "${LOCATION:=home}"
: "${BOOT:=1}" "${TORRENT:=1}" "${OPENVPN:=0}" "${TAILSCALE:=0}" "${TS_EXIT:=0}" : "${BOOT:=1}" "${TORRENT:=1}" "${OPENVPN:=0}" "${TAILSCALE:=0}" "${TS_EXIT:=0}"
: "${SUBS:=}" "${RU_IPS:=}" : "${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_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:=}"
@ -77,7 +78,14 @@ compute_tags() {
for _p in $SUB_PAIRS; do for _p in $SUB_PAIRS; do
SUB_LIST="${SUB_LIST:+$SUB_LIST, }${_p%%=*}" SUB_LIST="${SUB_LIST:+$SUB_LIST, }${_p%%=*}"
done done
export SUB_LIST # own hysteria2 servers: HY2_LIST "a, b" (TS-EXIT), HY2_MAIN "a, b, " (MAIN)
HY2_LIST="" HY2_MAIN=""
for _n in $HY2; do
HY2_LIST="${HY2_LIST:+$HY2_LIST, }$_n"
HY2_MAIN="$HY2_MAIN$_n, "
done
[ -n "$HY2" ] && TAGS="$TAGS hy2 "
export SUB_LIST HY2_LIST HY2_MAIN
} }
# 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
@ -148,8 +156,18 @@ check_vars() {
fi fi
i=$((i + 1)) i=$((i + 1))
done done
for _n in $HY2; do
case "$_n" in *[!A-Za-z0-9_-]*) die "HY2: bad server name $_n (letters, digits, _ -)" ;; esac
_k=$(hy2_key "$_n")
for v in SERVER PORT PASSWORD; do
eval "[ -n \"\${${_k}_$v:-}\" ]" || die "${_k}_$v is empty (hysteria2 server $_n)"
done
done
} }
# hy2_key <name>: HY2_<NAME> prefix of the server's keys (upper case, - -> _)
hy2_key() { printf 'HY2_%s' "$(printf '%s' "$1" | tr 'a-z-' 'A-Z_')"; }
# YAML double-quoted string body # YAML double-quoted string body
yq() { printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g'; } yq() { printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g'; }
@ -188,6 +206,26 @@ sub_vars() {
export SUB_NAME SUB_URL SUB_PROXY SUB_UA SUB_HEADERS export SUB_NAME SUB_URL SUB_PROXY SUB_UA SUB_HEADERS
} }
# variables for templates/proxies/*-hy2.each.yaml: hy2_vars <name>
# HY2_<NAME>_SERVER, _PORT, _PASSWORD required
# HY2_<NAME>_OBFS_PASSWORD salamander obfs (empty = none)
# HY2_<NAME>_SNI, _INSECURE=1 (skip-cert-verify), _UP, _DOWN ("50 mbps")
hy2_vars() {
_k=$(hy2_key "$1")
eval "HY2_SERVER=\${${_k}_SERVER} HY2_PORT=\${${_k}_PORT} _pw=\${${_k}_PASSWORD}
_ob=\${${_k}_OBFS_PASSWORD:-} HY2_SNI=\${${_k}_SNI:-} _in=\${${_k}_INSECURE:-0}
_up=\${${_k}_UP:-} _dn=\${${_k}_DOWN:-}"
HY2_NAME=$1
HY2_PASSWORD=$(yq "$_pw")
HY2_OBFS="" HY2_OBFS_PASSWORD=""
[ -n "$_ob" ] && HY2_OBFS=salamander HY2_OBFS_PASSWORD=$(yq "$_ob")
HY2_INSECURE=false
[ "$_in" = 1 ] && HY2_INSECURE=true
HY2_UP=$(yq "$_up") HY2_DOWN=$(yq "$_dn")
export HY2_NAME HY2_SERVER HY2_PORT HY2_PASSWORD HY2_OBFS HY2_OBFS_PASSWORD HY2_SNI \
HY2_INSECURE HY2_UP HY2_DOWN
}
render_file() { render_file() {
awk -v tags="$TAGS" ' awk -v tags="$TAGS" '
function active(c, neg) { function active(c, neg) {
@ -257,7 +295,15 @@ render_section() {
_name=${f##*/} _name=${f##*/}
_name=${_name%.yaml} _name=${_name%.yaml}
fragment_active "${_name#*-}" || continue fragment_active "${_name#*-}" || continue
if [ "$EACH" = 1 ]; then if [ "$EACH" = 1 ] && [ "$_mod" = hy2 ]; then
for _n in $HY2; do
hy2_vars "$_n"
_part=$(render_file "$f")
[ -n "$_part" ] && _out="${_out:+$_out
}$_part"
done
elif [ "$EACH" = 1 ]; then
i=0 i=0
for _pr in $SUB_PAIRS; do for _pr in $SUB_PAIRS; do
sub_vars "$i" "${_pr%%=*}" "${_pr#*=}" sub_vars "$i" "${_pr%%=*}" "${_pr#*=}"
@ -692,10 +738,13 @@ common_other_keys() {
} }
# common.env (+ bmstu.env) from the variables the wizard / configure set; # common.env (+ bmstu.env) from the variables the wizard / configure set;
# per-subscription values come as SUB<index>_PROXY/HWID (index in SUBS) # per-subscription values come as SUB<index>_PROXY/HWID (index in SUBS).
# Own hysteria2 servers (HY2, HY2_<NAME>_*) are rewritten only with HY2_SET=1
# (LuCI form); the terminal wizard does not ask for them and keeps them.
write_config() { write_config() {
umask 077 umask 077
_any_hwid=0 _any_hwid=0
[ "${HY2_SET:-0}" = 1 ] && COMMON_KEYS="$COMMON_KEYS|HY2|HY2_[A-Z0-9_]+"
_others=$(common_other_keys) _others=$(common_other_keys)
sub_pairs sub_pairs
{ {
@ -727,6 +776,16 @@ write_config() {
echo "OPENVPN=$OPENVPN" echo "OPENVPN=$OPENVPN"
echo "TAILSCALE=$TAILSCALE" echo "TAILSCALE=$TAILSCALE"
[ "$TAILSCALE" = 1 ] && echo "TS_HOSTNAME=$(q "$TS_HOSTNAME")" && echo "TS_DOMAINS=$(q "$TS_DOMAINS")" [ "$TAILSCALE" = 1 ] && echo "TS_HOSTNAME=$(q "$TS_HOSTNAME")" && echo "TS_DOMAINS=$(q "$TS_DOMAINS")"
if [ "${HY2_SET:-0}" = 1 ]; then
echo "HY2=$(q "$HY2")"
for _n in $HY2; do
_k=$(hy2_key "$_n")
for v in SERVER PORT PASSWORD OBFS_PASSWORD SNI INSECURE UP DOWN; do
eval "_v=\${${_k}_$v:-}"
[ -n "$_v" ] && echo "${_k}_$v=$(q "$_v")"
done
done
fi
[ -n "$_others" ] && echo "$_others" [ -n "$_others" ] && echo "$_others"
true true
} > "$PROFILES_D/common.env.tmp" && mv "$PROFILES_D/common.env.tmp" "$PROFILES_D/common.env" } > "$PROFILES_D/common.env.tmp" && mv "$PROFILES_D/common.env.tmp" "$PROFILES_D/common.env"
@ -762,7 +821,8 @@ cmd_sub_ids() {
} }
# Settings from the LuCI form: <env> holds BOOT_LINK, SUBS, SUB<i>_PROXY/HWID, # Settings from the LuCI form: <env> holds BOOT_LINK, 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_*,
# HY2_SET=1 + 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.
cmd_configure() { cmd_configure() {
[ -f "${1:-}" ] || die "usage: configure <env>" [ -f "${1:-}" ] || die "usage: configure <env>"
@ -840,6 +900,14 @@ cmd_setup() {
} > "$TTY_OUT" } > "$TTY_OUT"
} }
# kit_version <kit.tgz>: "<commit> <date>" into $KIT_DIR/VERSION. git archive
# (what the git server serves) puts the commit id into the first tar header.
kit_version() {
_sha=$(gunzip -c "$1" 2>/dev/null | head -c 1536 | tr -c 'a-z0-9=\n' '\n' |
grep '^comment=[0-9a-f]\{40\}$' | head -n 1 | cut -c9-15)
echo "${_sha:-?} $(date '+%Y-%m-%d %H:%M')" > "$KIT_DIR/VERSION"
}
cmd_update() { cmd_update() {
tmp=$(mktemp -d) tmp=$(mktemp -d)
log "downloading $KIT_URL" log "downloading $KIT_URL"
@ -852,7 +920,9 @@ cmd_update() {
rm -rf "${KIT_DIR:?}/$d" rm -rf "${KIT_DIR:?}/$d"
[ -d "$src/$d" ] && cp -r "$src/$d" "$KIT_DIR/$d" [ -d "$src/$d" ] && cp -r "$src/$d" "$KIT_DIR/$d"
done done
kit_version "$tmp/kit.tgz"
rm -rf "$tmp" rm -rf "$tmp"
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
} }

View File

@ -2,5 +2,6 @@
# cannot do it in mihomo, so only ss / hysteria2 / tuic / socks5 nodes here. # cannot do it in mihomo, so only ss / hysteria2 / tuic / socks5 nodes here.
- name: TS-EXIT - name: TS-EXIT
type: select type: select
proxies: [${HY2_LIST}] #@hy2
use: [${SUB_LIST}] use: [${SUB_LIST}]
exclude-type: "vless|vmess|trojan" exclude-type: "vless|vmess|trojan"

View File

@ -1,3 +1,3 @@
- name: MAIN - name: MAIN
type: select type: select
proxies: [FOREIGN, RU, DIRECT] proxies: [FOREIGN, ${HY2_MAIN}RU, DIRECT]

View File

@ -0,0 +1,13 @@
- name: ${HY2_NAME}
type: hysteria2
server: ${HY2_SERVER}
port: ${HY2_PORT}
password: "${HY2_PASSWORD}"
obfs: ${@HY2_OBFS}
obfs-password: "${@@HY2_OBFS_PASSWORD}"
sni: ${@HY2_SNI}
skip-cert-verify: ${HY2_INSECURE}
up: "${@@HY2_UP}"
down: "${@@HY2_DOWN}"
udp: true
dialer-proxy: FOREIGN #@street

View File

@ -1,3 +1,7 @@
LOCATION=home LOCATION=home
OPENVPN=1 OPENVPN=1
TAILSCALE=1 TAILSCALE=1
HY2=home-hy
HY2_HOME_HY_SERVER=1.1.1.1
HY2_HOME_HY_PORT=443
HY2_HOME_HY_PASSWORD=x

View File

@ -3,3 +3,16 @@ OPENVPN=1
TAILSCALE=1 TAILSCALE=1
TS_EXIT=1 TS_EXIT=1
TS_DOMAINS="corp.example internal.example" TS_DOMAINS="corp.example internal.example"
HY2="nl-1 de_2"
HY2_NL_1_SERVER=vpn.example.com
HY2_NL_1_PORT=443
HY2_NL_1_PASSWORD='p"w\1'
HY2_NL_1_OBFS_PASSWORD=obfs
HY2_NL_1_SNI=vpn.example.com
HY2_NL_1_UP="50 mbps"
HY2_NL_1_DOWN="100 mbps"
HY2_DE_2_SERVER=5.6.7.8
HY2_DE_2_PORT=8443
HY2_DE_2_PASSWORD=x
HY2_DE_2_SNI=www.bing.com
HY2_DE_2_INSECURE=1

View File

@ -8,4 +8,6 @@ cd "$(dirname "$0")/.."
# ustar without macOS metadata: busybox tar on OpenWrt chokes on pax/xattr headers # ustar without macOS metadata: busybox tar on OpenWrt chokes on pax/xattr headers
COPYFILE_DISABLE=1 tar --no-xattrs --format ustar -czf - install.sh templates presets router luci | COPYFILE_DISABLE=1 tar --no-xattrs --format ustar -czf - install.sh templates presets router luci |
ssh "$host" 'mkdir -p /etc/nikki/kit && tar xzf - -C /etc/nikki/kit && chmod +x /etc/nikki/kit/router/*.sh' ssh "$host" 'mkdir -p /etc/nikki/kit && tar xzf - -C /etc/nikki/kit && chmod +x /etc/nikki/kit/router/*.sh'
ver="$(git describe --always --dirty 2>/dev/null || echo '?') push $(date '+%Y-%m-%d %H:%M')"
ssh "$host" "echo '$ver' > /etc/nikki/kit/VERSION"
echo "pushed to $host:/etc/nikki/kit — now: ssh $host sh /etc/nikki/kit/install.sh" echo "pushed to $host:/etc/nikki/kit — now: ssh $host sh /etc/nikki/kit/install.sh"

View File

@ -13,7 +13,7 @@ for (const dir of fs.readdirSync(tplDir)) {
for (const f of fs.readdirSync(full)) templates[`${dir}/${f}`] = fs.readFileSync(path.join(full, f), "utf8"); for (const f of fs.readdirSync(full)) templates[`${dir}/${f}`] = fs.readFileSync(path.join(full, f), "utf8");
} }
const vars = {}; const vars = {};
for (const [k, val] of Object.entries(process.env)) if (k in DEFAULTS || /^SUB[0-9]*_/.test(k)) vars[k] = val; for (const [k, val] of Object.entries(process.env)) if (k in DEFAULTS || /^(SUB[0-9]*|HY2)_/.test(k)) vars[k] = val;
try { try {
process.stdout.write(render(templates, vars)); process.stdout.write(render(templates, vars));
} catch (e) { } catch (e) {

View File

@ -3,7 +3,8 @@
// //
// Template syntax: // Template syntax:
// file NN-<module>[.<tag>...][.each].yaml included if module and tags are active; // file NN-<module>[.<tag>...][.each].yaml included if module and tags are active;
// .each = once per subscription // .each = once per item of the module:
// sub - subscription, hy2 - own server
// line ... #@tag[,!tag] kept only if the conditions hold // line ... #@tag[,!tag] kept only if the conditions hold
// line ... ${@VAR} ... repeated for every word of VAR // line ... ${@VAR} ... repeated for every word of VAR
// line ... ${@@VAR} ... repeated for every line of VAR // line ... ${@@VAR} ... repeated for every line of VAR
@ -13,7 +14,7 @@
const DEFAULTS = { const DEFAULTS = {
TARGET: "router", LOCATION: "home", TARGET: "router", LOCATION: "home",
BOOT: "1", TORRENT: "1", OPENVPN: "0", TAILSCALE: "0", TS_EXIT: "0", BOOT: "1", TORRENT: "1", OPENVPN: "0", TAILSCALE: "0", TS_EXIT: "0",
SUBS: "", RU_IPS: "", 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_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: "",
@ -71,6 +72,21 @@
// 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}`] || "";
// 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, "_");
// variables for templates/proxies/*-hy2.each.yaml (see hy2_vars in mihomo-kit.sh)
function hy2Vars(v, name) {
const k = (key) => v[`${hy2Key(name)}_${key}`] || "";
const obfs = k("OBFS_PASSWORD");
return {
HY2_NAME: name, HY2_SERVER: k("SERVER"), HY2_PORT: k("PORT"), HY2_PASSWORD: yq(k("PASSWORD")),
HY2_OBFS: obfs ? "salamander" : "", HY2_OBFS_PASSWORD: obfs ? yq(obfs) : "",
HY2_SNI: k("SNI"), HY2_INSECURE: k("INSECURE") === "1" ? "true" : "false",
HY2_UP: yq(k("UP")), HY2_DOWN: yq(k("DOWN")),
};
}
function check(v) { function check(v) {
if (!words(v.SUBS).length) throw new Error("SUBS is empty (subscription URLs)"); if (!words(v.SUBS).length) throw new Error("SUBS is empty (subscription URLs)");
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");
@ -88,6 +104,12 @@
} }
} }
}); });
for (const name of words(v.HY2)) {
if (!/^[A-Za-z0-9_-]+$/.test(name)) throw new Error(`HY2: bad server name ${name} (letters, digits, _ -)`);
for (const key of ["SERVER", "PORT", "PASSWORD"]) {
if (!v[`${hy2Key(name)}_${key}`]) throw new Error(`${hy2Key(name)}_${key} is empty (hysteria2 server ${name})`);
}
}
} }
// YAML double-quoted string body // YAML double-quoted string body
@ -118,6 +140,7 @@
function computeTags(v) { function computeTags(v) {
const t = new Set(["base", "sub", v.TARGET]); const t = new Set(["base", "sub", v.TARGET]);
if (v.BOOT === "1") t.add("boot"); if (v.BOOT === "1") t.add("boot");
if (words(v.HY2).length) t.add("hy2");
if (v.TARGET === "router") { if (v.TARGET === "router") {
t.add(v.LOCATION); t.add(v.LOCATION);
if (v.TORRENT === "1") t.add("torrent"); if (v.TORRENT === "1") t.add("torrent");
@ -163,12 +186,12 @@
function fragmentInfo(spec, tags) { function fragmentInfo(spec, tags) {
const [mod, ...rest] = spec.split("."); const [mod, ...rest] = spec.split(".");
let each = false; let each = false;
if (!tags.has(mod)) return { active: false, each }; if (!tags.has(mod)) return { active: false, each, mod };
for (const t of rest) { for (const t of rest) {
if (t === "each") { each = true; continue; } if (t === "each") { each = true; continue; }
if (!tags.has(t)) return { active: false, each }; if (!tags.has(t)) return { active: false, each, mod };
} }
return { active: true, each }; return { active: true, each, mod };
} }
function render(templates, input) { function render(templates, input) {
@ -177,6 +200,9 @@
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.map((s) => s.id).join(", ");
const hy2 = words(v.HY2);
v.HY2_LIST = hy2.join(", ");
v.HY2_MAIN = hy2.map((n) => n + ", ").join("");
const sections = []; const sections = [];
for (const [dir, header] of SECTIONS) { for (const [dir, header] of SECTIONS) {
@ -188,7 +214,12 @@
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) { if (info.each && info.mod === "hy2") {
for (const name of hy2) {
const part = renderText(templates[path], { ...v, ...hy2Vars(v, name) }, tags);
if (part) parts.push(part);
}
} else if (info.each) {
subs.forEach((s, i) => { subs.forEach((s, i) => {
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);

View File

@ -191,7 +191,8 @@
// //
// Template syntax: // Template syntax:
// file NN-<module>[.<tag>...][.each].yaml included if module and tags are active; // file NN-<module>[.<tag>...][.each].yaml included if module and tags are active;
// .each = once per subscription // .each = once per item of the module:
// sub - subscription, hy2 - own server
// line ... #@tag[,!tag] kept only if the conditions hold // line ... #@tag[,!tag] kept only if the conditions hold
// line ... ${@VAR} ... repeated for every word of VAR // line ... ${@VAR} ... repeated for every word of VAR
// line ... ${@@VAR} ... repeated for every line of VAR // line ... ${@@VAR} ... repeated for every line of VAR
@ -201,7 +202,7 @@
const DEFAULTS = { const DEFAULTS = {
TARGET: "router", LOCATION: "home", TARGET: "router", LOCATION: "home",
BOOT: "1", TORRENT: "1", OPENVPN: "0", TAILSCALE: "0", TS_EXIT: "0", BOOT: "1", TORRENT: "1", OPENVPN: "0", TAILSCALE: "0", TS_EXIT: "0",
SUBS: "", RU_IPS: "", 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_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: "",
@ -259,6 +260,21 @@
// 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}`] || "";
// 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, "_");
// variables for templates/proxies/*-hy2.each.yaml (see hy2_vars in mihomo-kit.sh)
function hy2Vars(v, name) {
const k = (key) => v[`${hy2Key(name)}_${key}`] || "";
const obfs = k("OBFS_PASSWORD");
return {
HY2_NAME: name, HY2_SERVER: k("SERVER"), HY2_PORT: k("PORT"), HY2_PASSWORD: yq(k("PASSWORD")),
HY2_OBFS: obfs ? "salamander" : "", HY2_OBFS_PASSWORD: obfs ? yq(obfs) : "",
HY2_SNI: k("SNI"), HY2_INSECURE: k("INSECURE") === "1" ? "true" : "false",
HY2_UP: yq(k("UP")), HY2_DOWN: yq(k("DOWN")),
};
}
function check(v) { function check(v) {
if (!words(v.SUBS).length) throw new Error("SUBS is empty (subscription URLs)"); if (!words(v.SUBS).length) throw new Error("SUBS is empty (subscription URLs)");
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");
@ -276,6 +292,12 @@
} }
} }
}); });
for (const name of words(v.HY2)) {
if (!/^[A-Za-z0-9_-]+$/.test(name)) throw new Error(`HY2: bad server name ${name} (letters, digits, _ -)`);
for (const key of ["SERVER", "PORT", "PASSWORD"]) {
if (!v[`${hy2Key(name)}_${key}`]) throw new Error(`${hy2Key(name)}_${key} is empty (hysteria2 server ${name})`);
}
}
} }
// YAML double-quoted string body // YAML double-quoted string body
@ -306,6 +328,7 @@
function computeTags(v) { function computeTags(v) {
const t = new Set(["base", "sub", v.TARGET]); const t = new Set(["base", "sub", v.TARGET]);
if (v.BOOT === "1") t.add("boot"); if (v.BOOT === "1") t.add("boot");
if (words(v.HY2).length) t.add("hy2");
if (v.TARGET === "router") { if (v.TARGET === "router") {
t.add(v.LOCATION); t.add(v.LOCATION);
if (v.TORRENT === "1") t.add("torrent"); if (v.TORRENT === "1") t.add("torrent");
@ -351,12 +374,12 @@
function fragmentInfo(spec, tags) { function fragmentInfo(spec, tags) {
const [mod, ...rest] = spec.split("."); const [mod, ...rest] = spec.split(".");
let each = false; let each = false;
if (!tags.has(mod)) return { active: false, each }; if (!tags.has(mod)) return { active: false, each, mod };
for (const t of rest) { for (const t of rest) {
if (t === "each") { each = true; continue; } if (t === "each") { each = true; continue; }
if (!tags.has(t)) return { active: false, each }; if (!tags.has(t)) return { active: false, each, mod };
} }
return { active: true, each }; return { active: true, each, mod };
} }
function render(templates, input) { function render(templates, input) {
@ -365,6 +388,9 @@
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.map((s) => s.id).join(", ");
const hy2 = words(v.HY2);
v.HY2_LIST = hy2.join(", ");
v.HY2_MAIN = hy2.map((n) => n + ", ").join("");
const sections = []; const sections = [];
for (const [dir, header] of SECTIONS) { for (const [dir, header] of SECTIONS) {
@ -376,7 +402,12 @@
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) { if (info.each && info.mod === "hy2") {
for (const name of hy2) {
const part = renderText(templates[path], { ...v, ...hy2Vars(v, name) }, tags);
if (part) parts.push(part);
}
} else if (info.each) {
subs.forEach((s, i) => { subs.forEach((s, i) => {
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);
@ -407,14 +438,15 @@ const TEMPLATES = {
"groups/40-openvpn.yaml": " - name: ${OVPN_GROUP}\n type: select\n use: [${OVPN_PROVIDER}]\n", "groups/40-openvpn.yaml": " - name: ${OVPN_GROUP}\n type: select\n use: [${OVPN_PROVIDER}]\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/50-tailscale.yaml": " - name: TAILSCALE\n type: select\n proxies: [tailscale]\n", "groups/50-tailscale.yaml": " - name: TAILSCALE\n type: select\n proxies: [tailscale]\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 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: [${HY2_LIST}] #@hy2\n use: [${SUB_LIST}]\n exclude-type: \"vless|vmess|trojan\"\n",
"groups/90-base.yaml": " - name: MAIN\n type: select\n proxies: [FOREIGN, 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",
"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.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/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",
"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",