diff --git a/README.md b/README.md index 5bafa40..731a62a 100644 --- a/README.md +++ b/README.md @@ -279,6 +279,23 @@ claude.ai, claude.com, anthropic.com, clau.de, claudeusercontent.com…; `openai выключена), он собирается с `REJECT` — его сервисы закрыты, а не идут мимо, — и сборка пишет предупреждение. Пул, через который идёт сервис, не удалить, пока сервис не переключён. +Цепочки — когда до выхода надо добираться через что-то ещё: +- **вход сервиса** («Вход» у сервиса, `SVC_<ИМЯ>_CHAIN`): выход — MY или пул, вход — DIRECT, + FOREIGN, RU, MY, MY-EXIT или другой пул. Например, OpenAI выходит с IP своего сервера из пула + `DE`, а к самому серверу подключается через пул `WL`: клиент → `OPENAI` → `DE ⟶ WL` → + `de-1 ⟶ WL` → `WL` → наружу. Без входа — как обычно: на whitelist и телефоне свои серверы + и так идут через `MY-EXIT`; +- **пул в UPLINK** (галка «В UPLINK» у пула, `POOL_<ИМЯ>_UPLINK=1`): в группе `UPLINK` появляется + пункт `<ПУЛ> ⟶ DIRECT`; выбрать его (граф, дашборд) — и ноды подписок, BOOT и свои серверы + сначала идут через пул, а дальше как обычно (выход из блокировок). Серверы самого пула туда + подключаются напрямую, иначе была бы петля. По умолчанию в `UPLINK` выбран `DIRECT`; выбор, + как у любой группы, хранится в `cache.db` роутера. + +mihomo строит цепочку только через `dialer-proxy` самой прокси, поэтому kit делает копии: +свои серверы — `<сервер> ⟶ <вход>`, ноды подписок — file-провайдер `<подписка>@<вход>` на тот +же скачанный файл (второго скачивания нет; на телефоне — да, как у `<имя>-my`), группа +`<ПУЛ> ⟶ <вход>`. На графе это видно отдельной веткой. + В `common.env`: ```sh @@ -287,6 +304,7 @@ SVC_CLAUDE_GEOSITE="anthropic" # через пробел, если списк SVC_CLAUDE_DOMAINS="" # ещё домены (с поддоменами) SVC_CLAUDE_IPS="" # ещё IP / подсети SVC_CLAUDE_VIA=MY # MY | FOREIGN | RU | DIRECT | MAIN | пул (DE) +SVC_CLAUDE_CHAIN="" # вход для MY / пула: DIRECT | FOREIGN | RU | MY | MY-EXIT | пул POOLS="de" POOL_DE_TYPE=fallback # fallback | url-test | select @@ -294,6 +312,7 @@ POOL_DE_SERVERS="de-1; nl-2" # свои серверы по имени, че POOL_DE_SUBS="sam_hub sam_hub-my" # подписки ( без [MY], -my — только [MY]) POOL_DE_FILTER='(?i)🇩🇪|\bde\b' # по имени ноды подписки POOL_DE_EXCLUDE='(?i)torrent' +POOL_DE_UPLINK=1 # предлагать в UPLINK ``` Сервисы попадают и в конфиг телефона. Правила по доменам не работают для трафика, который diff --git a/install.sh b/install.sh index 5df5d6b..f0671de 100755 --- a/install.sh +++ b/install.sh @@ -12,7 +12,13 @@ KIT_DIR=/etc/nikki/kit here=$(cd "$(dirname "$0")" 2>/dev/null && pwd || echo /nonexistent) mkdir -p "$KIT_DIR" if [ -f "$here/router/mihomo-kit.sh" ]; then - [ "$here" = "$KIT_DIR" ] || cp -r "$here/templates" "$here/presets" "$here/router" "$here/luci" "$KIT_DIR/" + # whole directories, as below: a template renamed in the kit must not stay behind + if [ "$here" != "$KIT_DIR" ]; then + for d in templates presets router luci; do + rm -rf "${KIT_DIR:?}/$d" + cp -r "$here/$d" "$KIT_DIR/" + done + fi else tmp=/tmp/mihomo-kit.$$ mkdir -p "$tmp" diff --git a/luci/graph.js b/luci/graph.js index 019d585..2a9651e 100644 --- a/luci/graph.js +++ b/luci/graph.js @@ -1155,7 +1155,7 @@ var key = svc ? 'svc:' + svc.name : 'new'; if (editors[key]) return editors[key]; - svc = svc || { name: '', geosite: '', domains: '', ips: '', via: 'MY' }; + svc = svc || { name: '', geosite: '', domains: '', ips: '', via: 'MY', chain: '' }; var input = function(v, ph) { return el('input', { type: 'text', value: v || '', placeholder: ph }); }; var f = { name: input(svc.name, 'claude'), @@ -1163,9 +1163,14 @@ domains: input(svc.domains, 'example.com'), ips: input(svc.ips, '1.2.3.0/24'), via: el('select', {}, VIA_TEXT.concat(pools.map(function(p) { return [ p.name.toUpperCase(), 'пул ' + p.name.toUpperCase() ]; })) + .map(function(o) { return el('option', { value: o[0] }, [ o[1] ]); })), + chain: el('select', {}, [ [ '', 'как обычно' ], [ 'DIRECT', 'напрямую' ], [ 'FOREIGN', 'FOREIGN' ], [ 'RU', 'RU' ], + [ 'MY', 'MY' ], [ 'MY-EXIT', 'MY-EXIT (whitelist, телефон)' ] ] + .concat(pools.map(function(p) { return [ p.name.toUpperCase(), 'пул ' + p.name.toUpperCase() ]; })) .map(function(o) { return el('option', { value: o[0] }, [ o[1] ]); })) }; f.via.value = svc.via || 'MY'; + f.chain.value = svc.chain || ''; var msg = el('div', { 'class': 'mkg-msg' }); var say = function(t, err) { msg.textContent = t; @@ -1174,7 +1179,7 @@ var buttons = [], save = saver(say, buttons); var saveBtn = el('button', { 'class': 'btn cbi-button cbi-button-apply', onclick: function() { var v = { name: f.name.value.trim().toLowerCase(), geosite: f.geosite.value.trim(), domains: f.domains.value.trim(), - ips: f.ips.value.trim(), via: f.via.value }; + ips: f.ips.value.trim(), via: f.via.value, chain: f.chain.value }; var others = services.filter(function(x) { return !svc.name || x.name != svc.name; }); var bad = nameError(v.name, svcOf); if (bad) @@ -1183,6 +1188,10 @@ return say('сервис ' + v.name + ' уже есть', true); if (!v.geosite && !v.domains && !v.ips) return say('нужен geosite, домены или IP', true); + if (v.chain && v.via != 'MY' && !poolOf[v.via]) + return say('вход — только когда выход через MY или пул', true); + if (v.chain && v.chain == v.via) + return say('вход и выход — одно и то же', true); var list = services.map(function(x) { return x.name == svc.name ? v : x; }); if (!svc.name) list.push(v); @@ -1202,6 +1211,7 @@ el('label', {}, [ 'домены (с поддоменами)', f.domains ]), el('label', {}, [ 'IP / подсети', f.ips ]), el('label', {}, [ 'через что (или потяни от группы к MY / FOREIGN / RU / MAIN / DIRECT / пулу)', f.via ]), + el('label', {}, [ 'вход: через что подключаться к серверам выхода (для MY или пула)', f.chain ]), el('div', { 'class': 'acts' }, [ saveBtn, svc.name ? el('button', { 'class': 'btn cbi-button cbi-button-remove', onclick: function() { if (window.confirm('Удалить сервис ' + svc.name + '? Его трафик пойдёт по остальным правилам.')) save(services.filter(function(x) { return x.name != svc.name; }), pools, 'Удаляю ' + svc.name); @@ -1242,9 +1252,11 @@ srv: ticks(meta.servers || [], (pool.servers || '').split(';').map(function(x) { return x.trim(); }).filter(Boolean)), subs: ticks(meta.subs || [], (pool.subs || '').split(/\s+/).filter(Boolean)), filter: input(pool.filter, '\\[WL\\] или (?i)🇩🇪|\\bde\\b'), - exclude: input(pool.exclude, '(?i)torrent') + exclude: input(pool.exclude, '(?i)torrent'), + uplink: el('input', { type: 'checkbox', style: 'width:auto' }) }; f.type.value = pool.type || 'fallback'; + f.uplink.checked = pool.uplink == '1'; var msg = el('div', { 'class': 'mkg-msg' }); var say = function(t, err) { msg.textContent = t; @@ -1252,13 +1264,14 @@ }; var buttons = [], save = saver(say, buttons); var users = function() { - return services.filter(function(x) { return x.via == pool.name.toUpperCase(); }).map(function(x) { return x.name; }); + var G = pool.name.toUpperCase(); + return services.filter(function(x) { return x.via == G || x.chain == G; }).map(function(x) { return x.name; }); }; var saveBtn = el('button', { 'class': 'btn cbi-button cbi-button-apply', onclick: function() { var v = { name: f.name.value.trim().toLowerCase(), type: f.type.value, servers: f.srv.filter(function(o) { return o.c.checked; }).map(function(o) { return o.v; }).join('; '), subs: f.subs.filter(function(o) { return o.c.checked; }).map(function(o) { return o.v; }).join(' '), - filter: f.filter.value.trim(), exclude: f.exclude.value.trim() }; + filter: f.filter.value.trim(), exclude: f.exclude.value.trim(), uplink: f.uplink.checked ? '1' : '' }; var bad = nameError(v.name, poolOf); if (bad) return say(bad, true); @@ -1285,6 +1298,7 @@ el('div', {}, f.subs.length ? f.subs.map(function(o) { return o.el; }) : [ el('em', { text: 'нет' }) ]), el('label', {}, [ 'фильтр по имени ноды подписки (regex; пусто — все)', f.filter ]), el('label', {}, [ 'исключить', f.exclude ]), + el('label', { style: 'color:var(--fg)' }, [ f.uplink, ' предлагать в UPLINK: выбрать там — всё сначала через пул' ]), el('div', { 'class': 'acts' }, [ saveBtn, pool.name ? el('button', { 'class': 'btn cbi-button cbi-button-remove', onclick: function() { if (users().length) return say('через пул идут сервисы ' + users().join(', ') + ': сначала переключи их', true); diff --git a/luci/mihomo-kit.js b/luci/mihomo-kit.js index 4aceaf3..9fd2b47 100644 --- a/luci/mihomo-kit.js +++ b/luci/mihomo-kit.js @@ -573,10 +573,22 @@ return view.extend({ .map(function(o) { return E('option', { 'value': o[0] }, o[1]); })); sel.value = cur; }; + // "вход" of a service (SVC__CHAIN): what its exit servers dial through + var chainOptions = function(sel) { + var cur = sel.value || sel.getAttribute('data-chain') || ''; + var names = pools.length ? pools.map(function(p) { return p.name.value.trim().toUpperCase(); }) + : (cfg.pools || []).map(function(p) { return p.name.toUpperCase(); }); + dom.content(sel, [ [ '', 'как обычно' ], [ 'DIRECT', 'напрямую' ], [ 'FOREIGN', 'FOREIGN' ], [ 'RU', 'RU' ], + [ 'MY', 'MY' ], [ 'MY-EXIT', 'MY-EXIT (whitelist, телефон)' ] ] + .concat(names.filter(Boolean).map(function(n) { return [ n, 'пул ' + n ]; })) + .map(function(o) { return E('option', { 'value': o[0] }, o[1]); })); + sel.value = cur; + }; var addService = function(v) { var e = { name: text(v.name || '', 'claude'), via: E('select', { 'class': 'cbi-input-select', 'data-via': v.via || 'MY' }), + chain: E('select', { 'class': 'cbi-input-select', 'data-chain': v.chain || '' }), geosite: text(v.geosite || '', 'anthropic'), domains: text(v.domains || '', 'example.com'), ips: text(v.ips || '', '1.2.3.0/24') @@ -585,6 +597,9 @@ return view.extend({ viaOptions(e.via); e.via.addEventListener('focus', function() { viaOptions(e.via); }); e.via.addEventListener('mousedown', function() { viaOptions(e.via); }); + chainOptions(e.chain); + e.chain.addEventListener('focus', function() { chainOptions(e.chain); }); + e.chain.addEventListener('mousedown', function() { chainOptions(e.chain); }); var el = E('div', { 'style': 'border:1px solid #8884;border-radius:4px;padding:.5em;margin-bottom:.5em' }, [ E('div', { 'style': 'display:flex;gap:.5em;align-items:center;flex-wrap:wrap' }, [ e.name, 'через', e.via, @@ -595,7 +610,10 @@ return view.extend({ ]), field('geosite', e.geosite, 'списки MetaCubeX/meta-rules-dat через пробел: anthropic, openai, youtube…'), field('Домены', e.domains, 'ещё домены, с поддоменами'), - field('IP', e.ips, 'ещё адреса, без маски = /32') + field('IP', e.ips, 'ещё адреса, без маски = /32'), + field('Вход', e.chain, 'для выхода через MY или пул: через что подключаться к его серверам (например, ' + + 'сервер с нужным IP доступен только через другой пул). «Как обычно» — на whitelist и телефоне через MY-EXIT, ' + + 'иначе напрямую') ]); services.push(e); svcList.appendChild(el); @@ -737,7 +755,8 @@ return view.extend({ (v.servers || '').split(';').map(function(x) { return x.trim(); }).filter(Boolean)), subs: boxes(poolSubs, (v.subs || '').split(/\s+/).filter(Boolean)), filter: text(v.filter || '', '(?i)🇩🇪|\\bde\\b или \\[WL\\]'), - exclude: text(v.exclude || '', '(?i)torrent') + exclude: text(v.exclude || '', '(?i)torrent'), + uplink: check(v.uplink == '1') }; e.name.style.width = '9em'; e.type.value = v.type || 'fallback'; @@ -755,7 +774,9 @@ return view.extend({ 'их ноды — по фильтру ниже; «только [MY]» — ноды с [MY] в имени'), field('Фильтр', e.filter, 'регулярное выражение по имени ноды подписки (filter в mihomo): ' + 'метка своей подписки — \\[WL\\], страна — (?i)🇩🇪|\\bde\\b; пусто — все ноды. К своим серверам не применяется'), - field('Исключить', e.exclude, 'ноды подписки с таким именем не берутся') + field('Исключить', e.exclude, 'ноды подписки с таким именем не берутся'), + field('В UPLINK', e.uplink, 'предлагать пул в группе UPLINK: если выбрать его там (дашборд, граф), всё ' + + 'сначала идёт через пул, а дальше как обычно — для выхода из блокировок. Серверы пула при этом подключаются напрямую') ]); pools.push(e); poolList.appendChild(el); @@ -841,7 +862,7 @@ return view.extend({ return { name: e.name.value.trim().toLowerCase(), type: e.type.value, servers: e.srv.filter(function(o) { return o.c.checked; }).map(function(o) { return o.v; }).join('; '), subs: e.subs.filter(function(o) { return o.c.checked; }).map(function(o) { return o.v; }).join(' '), - filter: e.filter.value.trim(), exclude: e.exclude.value.trim() }; + filter: e.filter.value.trim(), exclude: e.exclude.value.trim(), uplink: e.uplink.checked ? '1' : '' }; }); poolData.forEach(function(v) { if (!/^[a-z0-9][a-z0-9_-]*$/.test(v.name)) @@ -856,7 +877,7 @@ return view.extend({ }); var svcNames = {}; var svcData = services.map(function(e) { - return { name: e.name.value.trim().toLowerCase(), via: e.via.value, geosite: e.geosite.value.trim(), + return { name: e.name.value.trim().toLowerCase(), via: e.via.value, chain: e.chain.value, geosite: e.geosite.value.trim(), domains: e.domains.value.trim(), ips: e.ips.value.trim() }; }); svcData.forEach(function(v) { @@ -869,6 +890,15 @@ return view.extend({ svcNames[v.name] = true; if (!v.geosite && !v.domains && !v.ips) errors.push('Сервис «' + v.name + '»: нужен geosite, домены или IP'); + var builtin = /^(MY|FOREIGN|RU|DIRECT|MAIN|MY-EXIT)$/; + if (!builtin.test(v.via) && !poolNames[v.via.toLowerCase()]) + errors.push('Сервис «' + v.name + '»: пула ' + v.via + ' больше нет'); + if (v.chain && !builtin.test(v.chain) && !poolNames[v.chain.toLowerCase()]) + errors.push('Сервис «' + v.name + '»: пула ' + v.chain + ' (вход) больше нет'); + if (v.chain && v.via != 'MY' && !poolNames[v.via.toLowerCase()]) + errors.push('Сервис «' + v.name + '»: вход — только когда выход через MY или пул'); + else if (v.chain && v.chain == v.via) + errors.push('Сервис «' + v.name + '»: вход и выход — одно и то же'); }); if (f.lite_gomemlimit.value.trim() && !/^[1-9][0-9]*(B|KiB|MiB|GiB)?$/.test(f.lite_gomemlimit.value.trim())) errors.push('Лимит памяти: число с единицей, например 64MiB'); diff --git a/luci/rpcd.sh b/luci/rpcd.sh index 32c310e..a422982 100644 --- a/luci/rpcd.sh +++ b/luci/rpcd.sh @@ -18,8 +18,8 @@ # graph {profile}: the built profile's YAML for the graph page (default: the running one) # and the services and pools of the settings (+ servers, subs: what a pool can take) # api {path}: GET /proxies, /connections or /providers/proxies of the mihomo API -# services_set {services: [{name, geosite, domains, ips, via}], pools: [{name, type, servers, -# subs, filter, exclude}]}: replace the services and pools ("mihomo-kit.sh services") +# services_set {services: [{name, geosite, domains, ips, via, chain}], pools: [{name, type, servers, +# subs, filter, exclude, uplink}]}: replace the services and pools ("mihomo-kit.sh services") # as the job # group {group, action, name, url}: select (pick / pin name), unfix (back to automatic), # delay (test every member against url) - the graph page, through the mihomo API @@ -291,8 +291,8 @@ m_config_get() { json_add_string foreign_domains "${FOREIGN_DOMAINS:-}" json_add_string my_domains "${MY_DOMAINS:-}" json_add_string local_hosts "${LOCAL_HOSTS:-}" - blocks_json services "${SERVICES:-}" SVC geosite domains ips via - blocks_json pools "${POOLS:-}" POOL type servers subs filter exclude + blocks_json services "${SERVICES:-}" SVC geosite domains ips via chain + blocks_json pools "${POOLS:-}" POOL type servers subs filter exclude uplink # own servers: one JSON proxy per line (luci/servers.js); the old hy2 / my_links # below are moved into it by the page on the next save json_add_string servers_text "$(cat "$NIKKI_DIR/my-servers" 2>/dev/null)" @@ -331,7 +331,7 @@ m_config_get() { # {"data": {boot_links (one per line), subs: [{url, via, hwid}], hwid_*, torrent, push, ru_ips, # foreign_ips, my_ips, ru_domains, foreign_domains, my_domains, local_hosts, my_links (one per line), -# services: [{name, geosite, domains, ips, via}], pools: [{name, type, servers, subs, filter, exclude}], +# services: [{name, geosite, domains, ips, via, chain}], pools: [{name, type, servers, subs, filter, exclude, uplink}], # servers_text (own servers, one JSON proxy per line: written to /etc/nikki/my-servers), # openvpn, csqtt, ovpn (file text, optional), vpn_username, vpn_password, totp_secret, # tailscale, ts_hostname, ts_domains, lite, lite_gomemlimit, hy2: [{name, server, port, password, @@ -434,8 +434,8 @@ m_config_set() { json_select .. fi echo "HY2=$(q "$hy2")" - blocks_env services SERVICES SVC geosite domains ips via - blocks_env pools POOLS POOL type servers subs filter exclude + blocks_env services SERVICES SVC geosite domains ips via chain + blocks_env pools POOLS POOL type servers subs filter exclude uplink } > "$env" umask 022 start_job mihomo-kit.sh configure "$env" @@ -525,8 +525,8 @@ m_graph() { json_add_string yaml "$(cat "$NIKKI_DIR/profiles/$want.yaml")" # the services and pools, as config_get gives them, and what a pool can take: the graph edits these [ -f "$PROFILES_D/common.env" ] && . "$PROFILES_D/common.env" - blocks_json services "${SERVICES:-}" SVC geosite domains ips via - blocks_json pools "${POOLS:-}" POOL type servers subs filter exclude + blocks_json services "${SERVICES:-}" SVC geosite domains ips via chain + blocks_json pools "${POOLS:-}" POOL type servers subs filter exclude uplink pool_sources json_dump } @@ -537,8 +537,8 @@ m_services_set() { umask 077 env=$(mktemp /tmp/mihomo-kit-svc.XXXXXX) || reply_error "mktemp failed" { - blocks_env services SERVICES SVC geosite domains ips via - blocks_env pools POOLS POOL type servers subs filter exclude + blocks_env services SERVICES SVC geosite domains ips via chain + blocks_env pools POOLS POOL type servers subs filter exclude uplink } > "$env" umask 022 start_job mihomo-kit.sh services "$env" diff --git a/router/mihomo-kit.sh b/router/mihomo-kit.sh index bc15243..cf2afd4 100755 --- a/router/mihomo-kit.sh +++ b/router/mihomo-kit.sh @@ -129,6 +129,12 @@ compute_tags() { # geosite rule-providers [ -n "$POOLS" ] && TAGS="$TAGS pool " [ -n "$SERVICES" ] && TAGS="$TAGS svc " + # UPLINK (what the nodes connect through): with CSQTT or a pool offered there + case "$TAGS" in *" csqtt "*) TAGS="$TAGS uplink " ;; esac + for _p in $POOLS; do + eval "_u=\${$(pool_key "$_p")_UPLINK:-0}" + case "$TAGS" in *" uplink "*) ;; *) [ "$_u" = 1 ] && TAGS="$TAGS uplink " ;; esac + done # CSQTT tunnel (star-panel-csqtt): last in MAIN (plain exit through its server) CSQTT_MAIN="" case "$TAGS" in *" csqtt "*) CSQTT_MAIN=", CSQTT" ;; esac @@ -398,6 +404,8 @@ own_servers_vars() { # _VIA MY (default): the first alive own server (fallback - the exit IP stays the # same while it lives); FOREIGN | RU | DIRECT | MAIN or a pool (its group, e.g. DE): # a select starting with it +# _CHAIN the entry for _VIA = MY or a pool: its servers dial through this (DIRECT, FOREIGN, +# RU, MY, MY-EXIT or another pool) - " ⟶ " first in the group svc_key() { printf 'SVC_%s' "$(printf '%s' "$1" | tr 'a-z-' 'A-Z_')"; } # Pools (POOLS="de wl ..."): own servers and subscription nodes picked by hand, a group each @@ -408,18 +416,21 @@ svc_key() { printf 'SVC_%s' "$(printf '%s' "$1" | tr 'a-z-' 'A-Z_')"; } # [MY] nodes), "my-links"; space separated # _FILTER, _EXCLUDE mihomo filter / exclude-filter over those providers' nodes (regex; several: # separated by `); they never apply to _SERVERS +# _UPLINK=1 offered in UPLINK (everything connects through this pool first; its own servers and +# nodes go there directly - group " ⟶ DIRECT") # A pool left with nothing (servers renamed, subscriptions off) gets REJECT: closed, not elsewhere. pool_key() { printf 'POOL_%s' "$(printf '%s' "$1" | tr 'a-z-' 'A-Z_')"; } # pool_vars : POOL_NAME POOL_GROUP POOL_TYPE POOL_PROXIES POOL_USE POOL_FILTER POOL_EXCLUDE # for the pool template; ITEM_TAGS pool_proxies / pool_use / pool_filter / pool_exclude / -# pool_select / pool_urltest; POOL_DROPPED: what is gone from the settings +# pool_select / pool_urltest; POOL_DROPPED: what is gone from the settings; POOL_JSON: its own +# servers as JSON strings, one per line (for the chains) pool_vars() { _k=$(pool_key "$1") POOL_NAME=$1 POOL_GROUP=$(printf '%s' "$1" | tr 'a-z' 'A-Z') eval "_t=\${${_k}_TYPE:-fallback} _sv=\${${_k}_SERVERS:-} _su=\${${_k}_SUBS:-} _fi=\${${_k}_FILTER:-} _ex=\${${_k}_EXCLUDE:-}" - POOL_TYPE=$_t POOL_PROXIES="" POOL_USE="" POOL_DROPPED="" ITEM_TAGS="" + POOL_TYPE=$_t POOL_PROXIES="" POOL_USE="" POOL_DROPPED="" POOL_JSON="" ITEM_TAGS="" _old_ifs=$IFS IFS=';' for _n in $_sv; do @@ -428,6 +439,8 @@ pool_vars() { _j="\"$(yq "$_n")\"" if printf '%s\n' "$OWN_NAMES" | grep -qxF "$_j"; then POOL_PROXIES="${POOL_PROXIES:+$POOL_PROXIES, }$(printf '%s' "$_j" | sed 's/\$/\\u0024/g')" + POOL_JSON="${POOL_JSON:+$POOL_JSON +}$_j" else POOL_DROPPED="${POOL_DROPPED:+$POOL_DROPPED, }$_n" fi @@ -457,7 +470,8 @@ pool_vars() { # check POOLS and their keys; POOL_GROUPS " DE WL " for the services' _VIA pools_vars() { - POOL_GROUPS=" " + POOL_GROUPS=" " VARIANTS="" UPLINK_MORE="" + case "$TAGS" in *" csqtt "*) UPLINK_MORE=", CSQTT" ;; esac set -f for _s in $POOLS; do case "$_s" in [a-z0-9]*) ;; *) die "POOLS: bad name '$_s' (a-z, 0-9, _ -)" ;; esac @@ -473,9 +487,123 @@ pools_vars() { [ -z "$POOL_DROPPED" ] || log "warning: pool $_s: no longer in the settings: $POOL_DROPPED" [ "$POOL_PROXIES" != REJECT ] || log "warning: pool $_s is empty: its services are closed (REJECT)" POOL_GROUPS="$POOL_GROUPS$POOL_GROUP " + eval "_u=\${${_k}_UPLINK:-0}" + if [ "$_u" = 1 ]; then + variant_add "$POOL_GROUP" DIRECT + UPLINK_MORE="$UPLINK_MORE, \"$POOL_GROUP ⟶ DIRECT\"" + fi done set +f ITEM_TAGS="" + export UPLINK_MORE +} + +# Chains: " ⟶ " - the pool's own servers and subscription nodes, each dialing +# through (DIRECT, FOREIGN, RU, MY, MY-EXIT or another pool) instead of what they use +# otherwise. mihomo chains only by a proxy's dialer-proxy, so these are copies: own servers +# " ⟶ " (proxies/35-variant), file providers "@" on the same +# downloaded file (providers/19-vprov), the group (groups/47-vgroup). = MY: all own servers +# and [MY] nodes. VARIANTS: "|" lines. +variant_add() { + printf '%s\n' "$VARIANTS" | grep -qxF "$1|$2" || VARIANTS="${VARIANTS:+$VARIANTS +}$1|$2" +} + +# variant_members : _vm_json (own servers, JSON strings per line), _vm_use ("a, b"), +# _vm_type, _vm_filter, _vm_exclude +variant_members() { + if [ "$1" = MY ]; then + _vm_json=$OWN_NAMES _vm_use=$MY_SUB_LIST _vm_type=fallback _vm_filter="" _vm_exclude="" + else + pool_vars "$(printf '%s' "$1" | tr 'A-Z' 'a-z')" + _vm_json=$POOL_JSON _vm_use=$POOL_USE _vm_type=$POOL_TYPE _vm_filter=$POOL_FILTER _vm_exclude=$POOL_EXCLUDE + fi +} + +# VARIANTS -> VARIANT_PROXIES (copies of own servers, once per server and entry), VPROV_ITEMS +# ("|", once each), VGROUP_ITEMS (= VARIANTS); tags variant / vprov / vgroup +variants_build() { + VARIANT_PROXIES="" VPROV_ITEMS="" VGROUP_ITEMS=$VARIANTS + _out=$(mktemp) + printf '%s\n' "$VARIANTS" | while IFS='|' read -r _p _e; do + [ -n "$_p" ] || continue + variant_members "$_p" + printf '%s\n' "$_vm_json" | while IFS= read -r _j; do + [ -n "$_j" ] || continue + _jc=$(printf '%s' "$_j" | sed 's/\$/\\u0024/g') + # through the environment: awk -v would read the backslashes of the JSON name + _b=$(printf '%s\n' "$OWN_BODIES" | P="\"name\":$_jc," awk 'index($0, ENVIRON["P"]) == 1 { print; exit }') + [ -n "$_b" ] || continue + _rest=${_b#"\"name\":$_jc"} + _n="${_jc%\"} ⟶ $_e\"" + if [ "$_e" = DIRECT ]; then + printf '%s\n' "- {\"name\":$_n$_rest" + else + printf '%s\n' "- {\"dialer-proxy\": \"$_e\", \"name\":$_n$_rest" + fi + done + done | awk '!seen[$0]++' > "$_out" + VARIANT_PROXIES=$(cat "$_out") + printf '%s\n' "$VARIANTS" | while IFS='|' read -r _p _e; do + [ -n "$_p" ] || continue + variant_members "$_p" + printf '%s\n' "$_vm_use" | tr ',' '\n' | sed 's/^ *//' | while read -r _v; do + [ -n "$_v" ] && printf '%s|%s\n' "$_v" "$_e" + done + done | awk '!seen[$0]++' > "$_out" + VPROV_ITEMS=$(cat "$_out") + rm -f "$_out" + [ -n "$VARIANT_PROXIES" ] && TAGS="$TAGS variant " + [ -n "$VPROV_ITEMS" ] && TAGS="$TAGS vprov " + [ -n "$VGROUP_ITEMS" ] && TAGS="$TAGS vgroup " + export VARIANT_PROXIES +} + +# vprov_vars "|": VP_NAME VP_BASE VP_ENTRY VP_PATH (+ the subscription's +# SUB_* for the phone); ITEM_TAGS vp_sub / vp_my / vp_links, vp_direct +vprov_vars() { + VP_BASE=${1%%|*} VP_ENTRY=${1#*|} + VP_NAME="$VP_BASE@$VP_ENTRY" + ITEM_TAGS="" + [ "$VP_ENTRY" = DIRECT ] && ITEM_TAGS=" vp_direct " + case "$VP_BASE" in + my-links) VP_PATH=./providers/my-links.txt ITEM_TAGS="$ITEM_TAGS vp_links " ;; + *-my) VP_PATH="./providers/${VP_BASE%-my}.yaml" ITEM_TAGS="$ITEM_TAGS vp_my " ;; + *) VP_PATH="./providers/$VP_BASE.yaml" ITEM_TAGS="$ITEM_TAGS vp_sub " ;; + esac + # the phone downloads it again (see providers/15-sub): the subscription's URL and headers + _id=${VP_BASE%-my} _i=0 + for _pr in $SUB_PAIRS; do + [ "${_pr%%=*}" = "$_id" ] && sub_vars "$_i" "$_id" "${_pr#*=}" + _i=$((_i + 1)) + done + export VP_NAME VP_BASE VP_ENTRY VP_PATH +} + +# vgroup_vars "|": VG_* for groups/47-vgroup; ITEM_TAGS vg_* +vgroup_vars() { + VG_POOL=${1%%|*} VG_ENTRY=${1#*|} + VG_NAME="$VG_POOL ⟶ $VG_ENTRY" + variant_members "$VG_POOL" + VG_TYPE=$_vm_type VG_FILTER=$_vm_filter VG_EXCLUDE=$_vm_exclude + VG_PROXIES=$(printf '%s\n' "$_vm_json" | while IFS= read -r _j; do + [ -n "$_j" ] && printf '%s\n' "${_j%\"} ⟶ $VG_ENTRY\"" + done | sed 's/\$/\\u0024/g' | awk '{ printf "%s%s", (NR > 1 ? ", " : ""), $0 }') + VG_USE=$(printf '%s\n' "$_vm_use" | tr ',' '\n' | sed 's/^ *//' | grep . | sed "s/\$/@$VG_ENTRY/" | + awk '{ printf "%s%s", (NR > 1 ? ", " : ""), $0 }') + if [ -z "$VG_PROXIES$VG_USE" ]; then + VG_PROXIES=REJECT VG_TYPE=select + fi + ITEM_TAGS="" + [ -n "$VG_PROXIES" ] && ITEM_TAGS="$ITEM_TAGS vg_proxies " + [ -n "$VG_USE" ] && ITEM_TAGS="$ITEM_TAGS vg_use " + [ -n "$VG_USE" ] && [ -n "$VG_FILTER" ] && ITEM_TAGS="$ITEM_TAGS vg_filter " + [ -n "$VG_USE" ] && [ -n "$VG_EXCLUDE" ] && ITEM_TAGS="$ITEM_TAGS vg_exclude " + case "$VG_TYPE" in + select) ITEM_TAGS="$ITEM_TAGS vg_select " ;; + url-test) ITEM_TAGS="$ITEM_TAGS vg_urltest " ;; + esac + export VG_POOL VG_ENTRY VG_NAME VG_TYPE VG_PROXIES VG_USE VG_FILTER VG_EXCLUDE } # names of the groups and proxies a service or pool group must not take @@ -487,7 +615,7 @@ svc_vars() { _k=$(svc_key "$1") SVC_NAME=$1 SVC_GROUP=$(printf '%s' "$1" | tr 'a-z' 'A-Z') - eval "SVC_GEOSITE=\${${_k}_GEOSITE:-} SVC_DOMAINS=\${${_k}_DOMAINS:-} SVC_IPS=\${${_k}_IPS:-} SVC_VIA=\${${_k}_VIA:-MY}" + eval "SVC_GEOSITE=\${${_k}_GEOSITE:-} SVC_DOMAINS=\${${_k}_DOMAINS:-} SVC_IPS=\${${_k}_IPS:-} SVC_VIA=\${${_k}_VIA:-MY} SVC_CHAIN=\${${_k}_CHAIN:-}" SVC_DOMAINS=$(norm_list dom "$SVC_DOMAINS") SVC_IPS=$(norm_list ip "$SVC_IPS") SVC_PROXIES=$SVC_VIA @@ -495,7 +623,11 @@ svc_vars() { [ "$_g" = "$SVC_VIA" ] || SVC_PROXIES="$SVC_PROXIES, $_g" done ITEM_TAGS="" - [ "$SVC_VIA" = MY ] && ITEM_TAGS=" svc_my " + if [ -n "$SVC_CHAIN" ]; then + SVC_PROXIES="\"$SVC_VIA ⟶ $SVC_CHAIN\", $SVC_PROXIES" + elif [ "$SVC_VIA" = MY ]; then + ITEM_TAGS=" svc_my " + fi export SVC_NAME SVC_GROUP SVC_GEOSITE SVC_DOMAINS SVC_IPS SVC_PROXIES } @@ -515,6 +647,14 @@ services_vars() { *) die "$(svc_key "$_s")_VIA: MY, FOREIGN, RU, DIRECT, MAIN or a pool${POOL_GROUPS% }, not '$SVC_VIA'" ;; esac [ -n "$SVC_GEOSITE$SVC_DOMAINS$SVC_IPS" ] || die "service $_s: no GEOSITE, DOMAINS or IPS" + if [ -n "$SVC_CHAIN" ]; then + case " MY$POOL_GROUPS" in *" $SVC_VIA "*) ;; *) die "$(svc_key "$_s")_CHAIN: only for _VIA = MY or a pool" ;; esac + _entries=" DIRECT FOREIGN RU MY${POOL_GROUPS% }" + case "$TAGS" in *" my_exit "*) _entries="$_entries MY-EXIT" ;; esac + case "$_entries " in *" $SVC_CHAIN "*) ;; *) die "$(svc_key "$_s")_CHAIN: one of$_entries, not '$SVC_CHAIN'" ;; esac + [ "$SVC_CHAIN" != "$SVC_VIA" ] || die "$(svc_key "$_s")_CHAIN: the same as _VIA" + variant_add "$SVC_VIA" "$SVC_CHAIN" + fi for _g in $SVC_GEOSITE; do case "$_g" in *[!a-z0-9._@!-]*) die "service $_s: bad geosite name '$_g'" ;; esac case " $GEOSITE_ITEMS " in *" $_g "*) ;; *) GEOSITE_ITEMS="${GEOSITE_ITEMS:+$GEOSITE_ITEMS }$_g" ;; esac @@ -612,6 +752,18 @@ render_section() { render_part "$f" done ITEM_TAGS="" + elif [ "$EACH" = 1 ] && { [ "$_mod" = vprov ] || [ "$_mod" = vgroup ]; }; then + # items have spaces ("a|b" per line): split on lines only + _old_ifs=$IFS + IFS=' +' + for _it in $([ "$_mod" = vprov ] && printf '%s\n' "$VPROV_ITEMS" || printf '%s\n' "$VGROUP_ITEMS"); do + IFS=$_old_ifs + if [ "$_mod" = vprov ]; then vprov_vars "$_it"; else vgroup_vars "$_it"; fi + render_part "$f" + done + IFS=$_old_ifs + ITEM_TAGS="" elif [ "$EACH" = 1 ] && [ "$_mod" = svc ]; then for _it in $SERVICES; do svc_vars "$_it" @@ -703,6 +855,7 @@ render() { pools_vars services_vars [ -n "$GEOSITE_ITEMS" ] && TAGS="$TAGS geosite " + variants_build local_hosts_vars export TARGET LOCATION RULESET_URL BOOT_SERVER BOOT_PORT BOOT_UUID BOOT_SNI \ BOOT_PBK BOOT_SID TS_HOSTNAME TS_DOMAINS OVPN_PROVIDER OVPN_GROUP OVPN_SERVER_HOST \ @@ -1790,7 +1943,7 @@ write_config() { [ -n "${POOLS:-}" ] && echo "POOLS=$(q "$POOLS")" for _s in ${POOLS:-}; do _k=$(pool_key "$_s") - for v in TYPE SERVERS SUBS FILTER EXCLUDE; do + for v in TYPE SERVERS SUBS FILTER EXCLUDE UPLINK; do eval "_v=\${${_k}_$v:-}" [ -n "$_v" ] && echo "${_k}_$v=$(q "$_v")" done @@ -1798,7 +1951,7 @@ write_config() { [ -n "${SERVICES:-}" ] && echo "SERVICES=$(q "$SERVICES")" for _s in ${SERVICES:-}; do _k=$(svc_key "$_s") - for v in GEOSITE DOMAINS IPS VIA; do + for v in GEOSITE DOMAINS IPS VIA CHAIN; do eval "_v=\${${_k}_$v:-}" [ -n "$_v" ] && echo "${_k}_$v=$(q "$_v")" done diff --git a/router/profile.env.example b/router/profile.env.example index 4d2f9d9..f1611ed 100644 --- a/router/profile.env.example +++ b/router/profile.env.example @@ -61,6 +61,7 @@ RU_IPS="194.190.191.112/32" #SVC_CLAUDE_DOMAINS="" #SVC_CLAUDE_IPS="" #SVC_CLAUDE_VIA=MY # or a pool's group: DE +#SVC_CLAUDE_CHAIN=WL # entry for VIA = MY / a pool: DIRECT FOREIGN RU MY MY-EXIT or a pool # pools: own servers and subscription nodes picked by hand, a group each (the name in upper # case) for the services' VIA. TYPE: fallback (default) | url-test | select; SERVERS: own @@ -72,6 +73,7 @@ RU_IPS="194.190.191.112/32" #POOL_DE_SUBS="sam_hub sam_hub-my" #POOL_DE_FILTER='(?i)🇩🇪|\bde\b' #POOL_DE_EXCLUDE='(?i)torrent' +#POOL_DE_UPLINK=1 # offer in UPLINK: everything through the pool first # OpenVPN (BMSTU), needs /etc/nikki/bmstu.env and bmstu-otp.sh OPENVPN=0 diff --git a/templates/groups/47-vgroup.each.yaml b/templates/groups/47-vgroup.each.yaml new file mode 100644 index 0000000..0acf008 --- /dev/null +++ b/templates/groups/47-vgroup.each.yaml @@ -0,0 +1,14 @@ + # ${VG_POOL} through ${VG_ENTRY} (SVC__CHAIN, POOL__UPLINK): its servers and + # nodes, each dialing through ${VG_ENTRY} + - name: "${VG_NAME}" + type: ${VG_TYPE} + proxies: [${VG_PROXIES}] #@vg_proxies + use: [${VG_USE}] #@vg_use + filter: "${VG_FILTER}" #@vg_filter + exclude-filter: "${VG_EXCLUDE}" #@vg_exclude + url: "https://www.gstatic.com/generate_204" #@!vg_select + interval: 300 #@!vg_select,!lite + interval: 600 #@!vg_select,lite + tolerance: 50 #@vg_urltest + lazy: false #@!vg_select,!lite + lazy: true #@!vg_select,lite diff --git a/templates/groups/60-csqtt.yaml b/templates/groups/60-uplink.yaml similarity index 56% rename from templates/groups/60-csqtt.yaml rename to templates/groups/60-uplink.yaml index 6afa3b1..f7ffe5d 100644 --- a/templates/groups/60-csqtt.yaml +++ b/templates/groups/60-uplink.yaml @@ -1,7 +1,8 @@ # UPLINK: what the subscription nodes, BOOT seeds and own servers connect # through. DIRECT - as before; CSQTT - through csqtt0 first (out of the - # whitelist), then FOREIGN / MY / RU work on top of it as usual. + # whitelist); a pool (POOL__UPLINK=1) - through its servers, they themselves + # direct; then FOREIGN / MY / RU work on top of it as usual. # On whitelist own servers go MY-EXIT -> node -> UPLINK. - name: UPLINK type: select - proxies: [DIRECT, CSQTT] + proxies: [DIRECT${UPLINK_MORE}] diff --git a/templates/providers/10-sub.each.yaml b/templates/providers/10-sub.each.yaml index 7abb0a7..ec90526 100644 --- a/templates/providers/10-sub.each.yaml +++ b/templates/providers/10-sub.each.yaml @@ -5,8 +5,8 @@ interval: 3600 proxy: ${@SUB_PROXY} exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]" - override: #@csqtt - dialer-proxy: UPLINK #@csqtt + override: #@uplink + dialer-proxy: UPLINK #@uplink header: User-Agent: ["${SUB_UA}"] ${@@SUB_HEADERS} diff --git a/templates/providers/15-sub.each.yaml b/templates/providers/15-sub.each.yaml index 8342207..85f047f 100644 --- a/templates/providers/15-sub.each.yaml +++ b/templates/providers/15-sub.each.yaml @@ -15,8 +15,8 @@ filter: "(?i)\\[MY\\]" override: #@my_exit dialer-proxy: MY-EXIT #@my_exit - override: #@csqtt,!my_exit - dialer-proxy: UPLINK #@csqtt,!my_exit + override: #@uplink,!my_exit + dialer-proxy: UPLINK #@uplink,!my_exit header: #@mobile User-Agent: ["${SUB_UA}"] #@mobile ${@@SUB_HEADERS} #@mobile diff --git a/templates/providers/17-my_links.yaml b/templates/providers/17-my_links.yaml index 16304d5..30fe208 100644 --- a/templates/providers/17-my_links.yaml +++ b/templates/providers/17-my_links.yaml @@ -7,7 +7,7 @@ override: additional-prefix: "[MY] " dialer-proxy: MY-EXIT #@my_exit - dialer-proxy: UPLINK #@csqtt,!my_exit + dialer-proxy: UPLINK #@uplink,!my_exit health-check: enable: true url: "https://www.gstatic.com/generate_204" diff --git a/templates/providers/19-vprov.each.yaml b/templates/providers/19-vprov.each.yaml new file mode 100644 index 0000000..d34459a --- /dev/null +++ b/templates/providers/19-vprov.each.yaml @@ -0,0 +1,26 @@ + # ${VP_BASE} for the chains through ${VP_ENTRY}: the same nodes, named "... ⟶ ${VP_ENTRY}" + ${VP_NAME}: + type: file #@router + path: ${VP_PATH} #@router + type: http #@mobile + url: "${SUB_URL}" #@mobile + path: ./providers/${VP_NAME}.yaml #@mobile + interval: 3600 #@mobile + proxy: ${@SUB_PROXY} #@mobile + filter: "(?i)\\[MY\\]" #@vp_my + exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]" #@vp_sub + override: + additional-prefix: "[MY] " #@vp_links + additional-suffix: " ⟶ ${VP_ENTRY}" + dialer-proxy: ${VP_ENTRY} #@!vp_direct + header: #@mobile + User-Agent: ["${SUB_UA}"] #@mobile + ${@@SUB_HEADERS} #@mobile + health-check: + enable: true + url: "https://www.gstatic.com/generate_204" + interval: 300 #@!lite + interval: 600 #@lite + timeout: 3000 + lazy: false #@!lite + lazy: true #@lite diff --git a/templates/proxies/10-boot.each.yaml b/templates/proxies/10-boot.each.yaml index 1d98767..41c260f 100644 --- a/templates/proxies/10-boot.each.yaml +++ b/templates/proxies/10-boot.each.yaml @@ -12,4 +12,4 @@ reality-opts: public-key: ${SEED_PBK} short-id: ${SEED_SID} - dialer-proxy: UPLINK #@csqtt + dialer-proxy: UPLINK #@uplink diff --git a/templates/proxies/30-own_srv.yaml b/templates/proxies/30-own_srv.yaml index 41dcd58..752fdb0 100644 --- a/templates/proxies/30-own_srv.yaml +++ b/templates/proxies/30-own_srv.yaml @@ -1,6 +1,6 @@ # own servers of the settings (LuCI "Свои серверы", /etc/nikki/my-servers): one JSON # proxy per line, as mihomo's own config would have it; the kit puts dialer-proxy in - # front: whitelist and the phone through MY-EXIT, with CSQTT through UPLINK + # front: whitelist and the phone through MY-EXIT, else with UPLINK (CSQTT, pools) through it - {"dialer-proxy": "MY-EXIT", ${@@OWN_BODIES} #@my_exit - - {"dialer-proxy": "UPLINK", ${@@OWN_BODIES} #@csqtt,!my_exit - - {${@@OWN_BODIES} #@!my_exit,!csqtt + - {"dialer-proxy": "UPLINK", ${@@OWN_BODIES} #@uplink,!my_exit + - {${@@OWN_BODIES} #@!my_exit,!uplink diff --git a/templates/proxies/35-variant.yaml b/templates/proxies/35-variant.yaml new file mode 100644 index 0000000..183dfa2 --- /dev/null +++ b/templates/proxies/35-variant.yaml @@ -0,0 +1,3 @@ + # copies of own servers for the chains (SVC__CHAIN, POOL__UPLINK): the same + # server dialing through another entry, named " ⟶ " (group " ⟶ ") + ${@@VARIANT_PROXIES} diff --git a/tests/expected/mobile.yaml b/tests/expected/mobile.yaml index 12aea28..cd303d6 100644 --- a/tests/expected/mobile.yaml +++ b/tests/expected/mobile.yaml @@ -16,12 +16,16 @@ proxies: # own servers of the settings (LuCI "Свои серверы", /etc/nikki/my-servers): one JSON # proxy per line, as mihomo's own config would have it; the kit puts dialer-proxy in - # front: whitelist and the phone through MY-EXIT, with CSQTT through UPLINK + # front: whitelist and the phone through MY-EXIT, else with UPLINK (CSQTT, pools) through it - {"dialer-proxy": "MY-EXIT", "name":"🇩🇪 de 1","type":"vless","server":"x.example.com","port":"443","uuid":"00000000-0000-0000-0000-000000000001","udp":true,"tls":true,"client-fingerprint":"chrome","servername":"www.example.com","reality-opts":{"public-key":"Nc9ZSDuQMwHN4M6TeDHjfJhgZ6SBTBbfMwx5iHQZ1ns","short-id":"ab"},"xudp":true,"network":"xhttp","xhttp-opts":{"path":"/x"}} - {"dialer-proxy": "MY-EXIT", "name":"tr \"q\"","type":"trojan","server":"t.example.org","port":"443","password":"p\u0024w","udp":true,"skip-cert-verify":false,"sni":"t.example.org","network":"grpc","grpc-opts":{"grpc-service-name":"g"},"client-fingerprint":"chrome"} - {"dialer-proxy": "MY-EXIT", "name":"hy-own","type":"hysteria2","server":"h.example.net","port":8443,"password":"a\u0024b","obfs":"salamander","obfs-password":"o","up":"50 mbps"} - {"dialer-proxy": "MY-EXIT", "name":"m1","type":"hysteria2","server":"m.example.com","port":443,"password":"p","udp":true} + # copies of own servers for the chains (SVC__CHAIN, POOL__UPLINK): the same + # server dialing through another entry, named " ⟶ " (group " ⟶ ") + - {"dialer-proxy": "FOREIGN", "name":"m1 ⟶ FOREIGN","type":"hysteria2","server":"m.example.com","port":443,"password":"p","udp":true} + proxy-providers: example: type: http @@ -109,6 +113,26 @@ proxy-providers: timeout: 3000 lazy: false + # example2-my for the chains through FOREIGN: the same nodes, named "... ⟶ FOREIGN" + example2-my@FOREIGN: + type: http + url: "https://sub2.example.com/x?a=1&b=2" + path: ./providers/example2-my@FOREIGN.yaml + interval: 3600 + proxy: BOOT-AUTO + filter: "(?i)\\[MY\\]" + override: + additional-suffix: " ⟶ FOREIGN" + dialer-proxy: FOREIGN + header: + User-Agent: ["mihomo"] + health-check: + enable: true + url: "https://www.gstatic.com/generate_204" + interval: 300 + timeout: 3000 + lazy: false + rule-providers: # Russian services (geosite ru-inside of russia-only, as .mrs): an ordinary # http rule-set, so every client fetches it with the config, no geodata setup @@ -212,6 +236,16 @@ proxy-groups: tolerance: 50 lazy: false + # pool one (POOLS, POOL_*): own servers and subscription nodes picked in the settings; + # filter / exclude-filter apply to the subscriptions' nodes only + - name: ONE + type: fallback + proxies: ["m1"] + use: [example2-my] + url: "https://www.gstatic.com/generate_204" + interval: 300 + lazy: false + # own servers: those of the settings (proxies/30-own_srv) and the "[MY] ..." nodes of # the subscriptions (providers -my); the fastest alive one; pin one in the dashboard if needed - name: MY @@ -235,13 +269,16 @@ proxy-groups: lazy: false # service claude (SERVICES, SVC_*): its own way, whatever MAIN is - # through own servers: the first alive one, not the fastest - the exit IP stays the - # same while the server lives (a site that checks the region sees one country); - # pick another in the dashboard, the choice is remembered - name: CLAUDE + type: select + proxies: ["ONE ⟶ FOREIGN", ONE, MY, FOREIGN, RU, DIRECT] + + # ONE through FOREIGN (SVC__CHAIN, POOL__UPLINK): its servers and + # nodes, each dialing through FOREIGN + - name: "ONE ⟶ FOREIGN" type: fallback - proxies: ["🇩🇪 de 1", "tr \"q\"", "hy-own", "m1"] - use: [example-my, example2-my] + proxies: ["m1 ⟶ FOREIGN"] + use: [example2-my@FOREIGN] url: "https://www.gstatic.com/generate_204" interval: 300 lazy: false diff --git a/tests/expected/router-csqtt-foreign.yaml b/tests/expected/router-csqtt-foreign.yaml index dd54f1c..b1106ed 100644 --- a/tests/expected/router-csqtt-foreign.yaml +++ b/tests/expected/router-csqtt-foreign.yaml @@ -17,7 +17,7 @@ proxies: # own servers of the settings (LuCI "Свои серверы", /etc/nikki/my-servers): one JSON # proxy per line, as mihomo's own config would have it; the kit puts dialer-proxy in - # front: whitelist and the phone through MY-EXIT, with CSQTT through UPLINK + # front: whitelist and the phone through MY-EXIT, else with UPLINK (CSQTT, pools) through it - {"dialer-proxy": "UPLINK", "name":"🇩🇪 de 1","type":"vless","server":"x.example.com","port":"443","uuid":"00000000-0000-0000-0000-000000000001","udp":true,"tls":true,"client-fingerprint":"chrome","servername":"www.example.com","reality-opts":{"public-key":"Nc9ZSDuQMwHN4M6TeDHjfJhgZ6SBTBbfMwx5iHQZ1ns","short-id":"ab"},"xudp":true,"network":"xhttp","xhttp-opts":{"path":"/x"}} - {"dialer-proxy": "UPLINK", "name":"tr \"q\"","type":"trojan","server":"t.example.org","port":"443","password":"p\u0024w","udp":true,"skip-cert-verify":false,"sni":"t.example.org","network":"grpc","grpc-opts":{"grpc-service-name":"g"},"client-fingerprint":"chrome"} - {"dialer-proxy": "UPLINK", "name":"hy-own","type":"hysteria2","server":"h.example.net","port":8443,"password":"a\u0024b","obfs":"salamander","obfs-password":"o","up":"50 mbps"} @@ -232,7 +232,8 @@ proxy-groups: # UPLINK: what the subscription nodes, BOOT seeds and own servers connect # through. DIRECT - as before; CSQTT - through csqtt0 first (out of the - # whitelist), then FOREIGN / MY / RU work on top of it as usual. + # whitelist); a pool (POOL__UPLINK=1) - through its servers, they themselves + # direct; then FOREIGN / MY / RU work on top of it as usual. # On whitelist own servers go MY-EXIT -> node -> UPLINK. - name: UPLINK type: select diff --git a/tests/expected/router-csqtt.yaml b/tests/expected/router-csqtt.yaml index 0a6673a..9b5d463 100644 --- a/tests/expected/router-csqtt.yaml +++ b/tests/expected/router-csqtt.yaml @@ -17,7 +17,7 @@ proxies: # own servers of the settings (LuCI "Свои серверы", /etc/nikki/my-servers): one JSON # proxy per line, as mihomo's own config would have it; the kit puts dialer-proxy in - # front: whitelist and the phone through MY-EXIT, with CSQTT through UPLINK + # front: whitelist and the phone through MY-EXIT, else with UPLINK (CSQTT, pools) through it - {"dialer-proxy": "MY-EXIT", "name":"🇩🇪 de 1","type":"vless","server":"x.example.com","port":"443","uuid":"00000000-0000-0000-0000-000000000001","udp":true,"tls":true,"client-fingerprint":"chrome","servername":"www.example.com","reality-opts":{"public-key":"Nc9ZSDuQMwHN4M6TeDHjfJhgZ6SBTBbfMwx5iHQZ1ns","short-id":"ab"},"xudp":true,"network":"xhttp","xhttp-opts":{"path":"/x"}} - {"dialer-proxy": "MY-EXIT", "name":"tr \"q\"","type":"trojan","server":"t.example.org","port":"443","password":"p\u0024w","udp":true,"skip-cert-verify":false,"sni":"t.example.org","network":"grpc","grpc-opts":{"grpc-service-name":"g"},"client-fingerprint":"chrome"} - {"dialer-proxy": "MY-EXIT", "name":"hy-own","type":"hysteria2","server":"h.example.net","port":8443,"password":"a\u0024b","obfs":"salamander","obfs-password":"o","up":"50 mbps"} @@ -242,7 +242,8 @@ proxy-groups: # UPLINK: what the subscription nodes, BOOT seeds and own servers connect # through. DIRECT - as before; CSQTT - through csqtt0 first (out of the - # whitelist), then FOREIGN / MY / RU work on top of it as usual. + # whitelist); a pool (POOL__UPLINK=1) - through its servers, they themselves + # direct; then FOREIGN / MY / RU work on top of it as usual. # On whitelist own servers go MY-EXIT -> node -> UPLINK. - name: UPLINK type: select diff --git a/tests/expected/router-foreign.yaml b/tests/expected/router-foreign.yaml index dd8e1f8..ded45d8 100644 --- a/tests/expected/router-foreign.yaml +++ b/tests/expected/router-foreign.yaml @@ -27,7 +27,7 @@ proxies: # own servers of the settings (LuCI "Свои серверы", /etc/nikki/my-servers): one JSON # proxy per line, as mihomo's own config would have it; the kit puts dialer-proxy in - # front: whitelist and the phone through MY-EXIT, with CSQTT through UPLINK + # front: whitelist and the phone through MY-EXIT, else with UPLINK (CSQTT, pools) through it - {"name":"nl-1","type":"hysteria2","server":"vpn.example.com","port":443,"password":"p","udp":true} proxy-providers: diff --git a/tests/expected/router-lite-csqtt.yaml b/tests/expected/router-lite-csqtt.yaml index 15aa5b5..ecbcb96 100644 --- a/tests/expected/router-lite-csqtt.yaml +++ b/tests/expected/router-lite-csqtt.yaml @@ -231,7 +231,8 @@ proxy-groups: # UPLINK: what the subscription nodes, BOOT seeds and own servers connect # through. DIRECT - as before; CSQTT - through csqtt0 first (out of the - # whitelist), then FOREIGN / MY / RU work on top of it as usual. + # whitelist); a pool (POOL__UPLINK=1) - through its servers, they themselves + # direct; then FOREIGN / MY / RU work on top of it as usual. # On whitelist own servers go MY-EXIT -> node -> UPLINK. - name: UPLINK type: select diff --git a/tests/expected/router-lite.yaml b/tests/expected/router-lite.yaml index ca4c3b6..86da46e 100644 --- a/tests/expected/router-lite.yaml +++ b/tests/expected/router-lite.yaml @@ -24,7 +24,7 @@ proxies: # own servers of the settings (LuCI "Свои серверы", /etc/nikki/my-servers): one JSON # proxy per line, as mihomo's own config would have it; the kit puts dialer-proxy in - # front: whitelist and the phone through MY-EXIT, with CSQTT through UPLINK + # front: whitelist and the phone through MY-EXIT, else with UPLINK (CSQTT, pools) through it - {"dialer-proxy": "MY-EXIT", "name":"nl-1","type":"hysteria2","server":"vpn.example.com","port":443,"password":"p","udp":true} proxy-providers: diff --git a/tests/expected/router-main.yaml b/tests/expected/router-main.yaml index 644ae42..4e2b4e5 100644 --- a/tests/expected/router-main.yaml +++ b/tests/expected/router-main.yaml @@ -27,7 +27,7 @@ proxies: # own servers of the settings (LuCI "Свои серверы", /etc/nikki/my-servers): one JSON # proxy per line, as mihomo's own config would have it; the kit puts dialer-proxy in - # front: whitelist and the phone through MY-EXIT, with CSQTT through UPLINK + # front: whitelist and the phone through MY-EXIT, else with UPLINK (CSQTT, pools) through it - {"name":"🇩🇪 de 1","type":"vless","server":"x.example.com","port":"443","uuid":"00000000-0000-0000-0000-000000000001","udp":true,"tls":true,"client-fingerprint":"chrome","servername":"www.example.com","reality-opts":{"public-key":"Nc9ZSDuQMwHN4M6TeDHjfJhgZ6SBTBbfMwx5iHQZ1ns","short-id":"ab"},"xudp":true,"network":"xhttp","xhttp-opts":{"path":"/x"}} - {"name":"tr \"q\"","type":"trojan","server":"t.example.org","port":"443","password":"p\u0024w","udp":true,"skip-cert-verify":false,"sni":"t.example.org","network":"grpc","grpc-opts":{"grpc-service-name":"g"},"client-fingerprint":"chrome"} - {"name":"hy-own","type":"hysteria2","server":"h.example.net","port":8443,"password":"a\u0024b","obfs":"salamander","obfs-password":"o","up":"50 mbps"} diff --git a/tests/expected/router-whitelist-ts-my.yaml b/tests/expected/router-whitelist-ts-my.yaml index 2ec576d..c9b499f 100644 --- a/tests/expected/router-whitelist-ts-my.yaml +++ b/tests/expected/router-whitelist-ts-my.yaml @@ -13,6 +13,7 @@ proxies: reality-opts: public-key: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA short-id: a1b2 + dialer-proxy: UPLINK # Tailscale: userspace node, starts on first use. First login: open the URL # from the nikki log ("To start this tsnet server ... go to: ..."), then @@ -31,11 +32,19 @@ proxies: # own servers of the settings (LuCI "Свои серверы", /etc/nikki/my-servers): one JSON # proxy per line, as mihomo's own config would have it; the kit puts dialer-proxy in - # front: whitelist and the phone through MY-EXIT, with CSQTT through UPLINK + # front: whitelist and the phone through MY-EXIT, else with UPLINK (CSQTT, pools) through it - {"dialer-proxy": "MY-EXIT", "name":"🇩🇪 de 1","type":"vless","server":"x.example.com","port":"443","uuid":"00000000-0000-0000-0000-000000000001","udp":true,"tls":true,"client-fingerprint":"chrome","servername":"www.example.com","reality-opts":{"public-key":"Nc9ZSDuQMwHN4M6TeDHjfJhgZ6SBTBbfMwx5iHQZ1ns","short-id":"ab"},"xudp":true,"network":"xhttp","xhttp-opts":{"path":"/x"}} - {"dialer-proxy": "MY-EXIT", "name":"tr \"q\"","type":"trojan","server":"t.example.org","port":"443","password":"p\u0024w","udp":true,"skip-cert-verify":false,"sni":"t.example.org","network":"grpc","grpc-opts":{"grpc-service-name":"g"},"client-fingerprint":"chrome"} - {"dialer-proxy": "MY-EXIT", "name":"hy-own","type":"hysteria2","server":"h.example.net","port":8443,"password":"a\u0024b","obfs":"salamander","obfs-password":"o","up":"50 mbps"} + # copies of own servers for the chains (SVC__CHAIN, POOL__UPLINK): the same + # server dialing through another entry, named " ⟶ " (group " ⟶ ") + - {"dialer-proxy": "WL", "name":"🇩🇪 de 1 ⟶ WL","type":"vless","server":"x.example.com","port":"443","uuid":"00000000-0000-0000-0000-000000000001","udp":true,"tls":true,"client-fingerprint":"chrome","servername":"www.example.com","reality-opts":{"public-key":"Nc9ZSDuQMwHN4M6TeDHjfJhgZ6SBTBbfMwx5iHQZ1ns","short-id":"ab"},"xudp":true,"network":"xhttp","xhttp-opts":{"path":"/x"}} + - {"dialer-proxy": "WL", "name":"hy-own ⟶ WL","type":"hysteria2","server":"h.example.net","port":8443,"password":"a\u0024b","obfs":"salamander","obfs-password":"o","up":"50 mbps"} + - {"dialer-proxy": "FOREIGN", "name":"🇩🇪 de 1 ⟶ FOREIGN","type":"vless","server":"x.example.com","port":"443","uuid":"00000000-0000-0000-0000-000000000001","udp":true,"tls":true,"client-fingerprint":"chrome","servername":"www.example.com","reality-opts":{"public-key":"Nc9ZSDuQMwHN4M6TeDHjfJhgZ6SBTBbfMwx5iHQZ1ns","short-id":"ab"},"xudp":true,"network":"xhttp","xhttp-opts":{"path":"/x"}} + - {"dialer-proxy": "FOREIGN", "name":"tr \"q\" ⟶ FOREIGN","type":"trojan","server":"t.example.org","port":"443","password":"p\u0024w","udp":true,"skip-cert-verify":false,"sni":"t.example.org","network":"grpc","grpc-opts":{"grpc-service-name":"g"},"client-fingerprint":"chrome"} + - {"dialer-proxy": "FOREIGN", "name":"hy-own ⟶ FOREIGN","type":"hysteria2","server":"h.example.net","port":8443,"password":"a\u0024b","obfs":"salamander","obfs-password":"o","up":"50 mbps"} + proxy-providers: example: type: http @@ -44,6 +53,8 @@ proxy-providers: interval: 3600 proxy: BOOT-AUTO exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]" + override: + dialer-proxy: UPLINK header: User-Agent: ["mihomo"] # one check per provider: the groups over it (use:) only add their URLs to it, @@ -63,6 +74,8 @@ proxy-providers: interval: 3600 proxy: BOOT-AUTO exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]" + override: + dialer-proxy: UPLINK header: User-Agent: ["mihomo"] # one check per provider: the groups over it (use:) only add their URLs to it, @@ -129,6 +142,95 @@ proxy-providers: timeout: 3000 lazy: false + # example for the chains through DIRECT: the same nodes, named "... ⟶ DIRECT" + example@DIRECT: + type: file + path: ./providers/example.yaml + exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]" + override: + additional-suffix: " ⟶ DIRECT" + health-check: + enable: true + url: "https://www.gstatic.com/generate_204" + interval: 300 + timeout: 3000 + lazy: false + + # example for the chains through WL: the same nodes, named "... ⟶ WL" + example@WL: + type: file + path: ./providers/example.yaml + exclude-filter: "(?i)app not supported|приложение не|свяжитесь|\\[MY\\]" + override: + additional-suffix: " ⟶ WL" + dialer-proxy: WL + health-check: + enable: true + url: "https://www.gstatic.com/generate_204" + interval: 300 + timeout: 3000 + lazy: false + + # example2-my for the chains through WL: the same nodes, named "... ⟶ WL" + example2-my@WL: + type: file + path: ./providers/example2.yaml + filter: "(?i)\\[MY\\]" + override: + additional-suffix: " ⟶ WL" + dialer-proxy: WL + health-check: + enable: true + url: "https://www.gstatic.com/generate_204" + interval: 300 + timeout: 3000 + lazy: false + + # example-my for the chains through FOREIGN: the same nodes, named "... ⟶ FOREIGN" + example-my@FOREIGN: + type: file + path: ./providers/example.yaml + filter: "(?i)\\[MY\\]" + override: + additional-suffix: " ⟶ FOREIGN" + dialer-proxy: FOREIGN + health-check: + enable: true + url: "https://www.gstatic.com/generate_204" + interval: 300 + timeout: 3000 + lazy: false + + # example2-my for the chains through FOREIGN: the same nodes, named "... ⟶ FOREIGN" + example2-my@FOREIGN: + type: file + path: ./providers/example2.yaml + filter: "(?i)\\[MY\\]" + override: + additional-suffix: " ⟶ FOREIGN" + dialer-proxy: FOREIGN + health-check: + enable: true + url: "https://www.gstatic.com/generate_204" + interval: 300 + timeout: 3000 + lazy: false + + # my-links for the chains through FOREIGN: the same nodes, named "... ⟶ FOREIGN" + my-links@FOREIGN: + type: file + path: ./providers/my-links.txt + override: + additional-prefix: "[MY] " + additional-suffix: " ⟶ FOREIGN" + dialer-proxy: FOREIGN + health-check: + enable: true + url: "https://www.gstatic.com/generate_204" + interval: 300 + timeout: 3000 + lazy: false + rule-providers: # Russian services (geosite ru-inside of russia-only, as .mrs): an ordinary # http rule-set, so every client fetches it with the config, no geodata setup @@ -280,6 +382,16 @@ proxy-groups: type: select proxies: [REJECT] + # pool wl (POOLS, POOL_*): own servers and subscription nodes picked in the settings; + # filter / exclude-filter apply to the subscriptions' nodes only + - name: WL + type: fallback + use: [example] + filter: "\\[WL\\]" + url: "https://www.gstatic.com/generate_204" + interval: 300 + lazy: false + # own servers: those of the settings (proxies/30-own_srv) and the "[MY] ..." nodes of # the subscriptions (providers -my); the fastest alive one; pin one in the dashboard if needed - name: MY @@ -305,12 +417,45 @@ proxy-groups: # service claude (SERVICES, SVC_*): its own way, whatever MAIN is - name: CLAUDE type: select - proxies: [DE, MY, FOREIGN, RU, DIRECT] + proxies: ["DE ⟶ WL", DE, MY, FOREIGN, RU, DIRECT] # service chat (SERVICES, SVC_*): its own way, whatever MAIN is - name: CHAT type: select - proxies: [FOREIGN, MY, RU, DIRECT] + proxies: ["MY ⟶ FOREIGN", MY, FOREIGN, RU, DIRECT] + + # WL through DIRECT (SVC__CHAIN, POOL__UPLINK): its servers and + # nodes, each dialing through DIRECT + - name: "WL ⟶ DIRECT" + type: fallback + use: [example@DIRECT] + filter: "\\[WL\\]" + url: "https://www.gstatic.com/generate_204" + interval: 300 + lazy: false + + # DE through WL (SVC__CHAIN, POOL__UPLINK): its servers and + # nodes, each dialing through WL + - name: "DE ⟶ WL" + type: url-test + proxies: ["🇩🇪 de 1 ⟶ WL", "hy-own ⟶ WL"] + use: [example@WL, example2-my@WL] + filter: "(?i)🇩🇪|\\bde\\b" + exclude-filter: "(?i)tor" + url: "https://www.gstatic.com/generate_204" + interval: 300 + tolerance: 50 + lazy: false + + # MY through FOREIGN (SVC__CHAIN, POOL__UPLINK): its servers and + # nodes, each dialing through FOREIGN + - name: "MY ⟶ FOREIGN" + type: fallback + proxies: ["🇩🇪 de 1 ⟶ FOREIGN", "tr \"q\" ⟶ FOREIGN", "hy-own ⟶ FOREIGN"] + use: [example-my@FOREIGN, example2-my@FOREIGN, my-links@FOREIGN] + url: "https://www.gstatic.com/generate_204" + interval: 300 + lazy: false # url (TS_CHECK_URL, optional): a tailnet service for the dashboard's delay test - name: TAILSCALE @@ -319,6 +464,15 @@ proxy-groups: url: "http://100.69.216.50:8080" interval: 0 + # UPLINK: what the subscription nodes, BOOT seeds and own servers connect + # through. DIRECT - as before; CSQTT - through csqtt0 first (out of the + # whitelist); a pool (POOL__UPLINK=1) - through its servers, they themselves + # direct; then FOREIGN / MY / RU work on top of it as usual. + # On whitelist own servers go MY-EXIT -> node -> UPLINK. + - name: UPLINK + type: select + proxies: [DIRECT, "WL ⟶ DIRECT"] + - name: MAIN type: select proxies: [FOREIGN, MY, RU, DIRECT] diff --git a/tests/expected/router-whitelist-ts.yaml b/tests/expected/router-whitelist-ts.yaml index 2fe5142..9b8efe5 100644 --- a/tests/expected/router-whitelist-ts.yaml +++ b/tests/expected/router-whitelist-ts.yaml @@ -31,7 +31,7 @@ proxies: # own servers of the settings (LuCI "Свои серверы", /etc/nikki/my-servers): one JSON # proxy per line, as mihomo's own config would have it; the kit puts dialer-proxy in - # front: whitelist and the phone through MY-EXIT, with CSQTT through UPLINK + # front: whitelist and the phone through MY-EXIT, else with UPLINK (CSQTT, pools) through it - {"dialer-proxy": "MY-EXIT", "name":"nl-1","type":"hysteria2","server":"vpn.example.com","port":443,"password":"p","udp":true} - {"dialer-proxy": "MY-EXIT", "name":"de-2","type":"hysteria2","server":"5.6.7.8","port":443,"password":"q","udp":true} diff --git a/tests/expected/router-whitelist.yaml b/tests/expected/router-whitelist.yaml index 0241eac..51e916b 100644 --- a/tests/expected/router-whitelist.yaml +++ b/tests/expected/router-whitelist.yaml @@ -28,7 +28,7 @@ proxies: # own servers of the settings (LuCI "Свои серверы", /etc/nikki/my-servers): one JSON # proxy per line, as mihomo's own config would have it; the kit puts dialer-proxy in - # front: whitelist and the phone through MY-EXIT, with CSQTT through UPLINK + # front: whitelist and the phone through MY-EXIT, else with UPLINK (CSQTT, pools) through it - {"dialer-proxy": "MY-EXIT", "name":"nl-1","type":"hysteria2","server":"vpn.example.com","port":443,"password":"p\"w\\1","obfs":"salamander","obfs-password":"obfs","sni":"vpn.example.com","up":"50 mbps","down":"100 mbps","udp":true} - {"dialer-proxy": "MY-EXIT", "name":"de_2","type":"hysteria2","server":"5.6.7.8","port":8443,"password":"x","sni":"www.bing.com","skip-cert-verify":true,"udp":true} diff --git a/tests/fixtures/mobile.env b/tests/fixtures/mobile.env index 29170ce..8539481 100644 --- a/tests/fixtures/mobile.env +++ b/tests/fixtures/mobile.env @@ -8,3 +8,8 @@ MY_LINKS='ss://YWVzLTI1Ni1nY206cGFzcw@1.2.3.4:8388#ss1' MY_SERVERS_FILE=tests/fixtures/own.servers SERVICES=claude SVC_CLAUDE_GEOSITE=anthropic +POOLS=one +POOL_ONE_SERVERS='m1' +POOL_ONE_SUBS="example2-my" +SVC_CLAUDE_VIA=ONE +SVC_CLAUDE_CHAIN=FOREIGN diff --git a/tests/fixtures/router-whitelist-ts-my.env b/tests/fixtures/router-whitelist-ts-my.env index 285e61f..7a58137 100644 --- a/tests/fixtures/router-whitelist-ts-my.env +++ b/tests/fixtures/router-whitelist-ts-my.env @@ -6,14 +6,19 @@ MY_SERVERS_FILE=tests/fixtures/own.servers SERVICES="claude chat" SVC_CLAUDE_GEOSITE=anthropic SVC_CLAUDE_VIA=DE +SVC_CLAUDE_CHAIN=WL SVC_CLAUDE_DOMAINS="*.claude.example" SVC_CHAT_GEOSITE="openai anthropic" SVC_CHAT_IPS="1.2.3.4" -SVC_CHAT_VIA=FOREIGN -POOLS="de gone" +SVC_CHAT_VIA=MY +SVC_CHAT_CHAIN=FOREIGN +POOLS="de gone wl" POOL_DE_TYPE=url-test POOL_DE_SERVERS='🇩🇪 de 1; hy-own; renamed-server' POOL_DE_SUBS="example example2-my no-such" POOL_DE_FILTER='(?i)🇩🇪|\bde\b' POOL_DE_EXCLUDE='(?i)tor' POOL_GONE_SERVERS='renamed-server' +POOL_WL_SUBS="example" +POOL_WL_FILTER='\[WL\]' +POOL_WL_UPLINK=1