diff --git a/README.md b/README.md index 3a6e3bc..7d2ec0b 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,19 @@ BOOT — whitelisted seed-ноды для скачивания подписок: ## Телефон (FlClash) +С роутера: LuCI → Настройка → галка «Конфиг для телефона» → «Сохранить и применить». На +странице появится блок «Телефон (FlClash)» с QR-кодом и ссылкой +`http://<роутер>/mihomo-kit/<токен>.yaml`: FlClash → Профили → + → по ссылке (или QR). +Это `common.env`, собранный с `TARGET=mobile`: те же подписки, BOOT/`BOOT-AUTO`, HWID и +RU-адреса, без OpenVPN, Tailscale, торрентов и `PUSH`; свои серверы — в `MY`, к ним всегда +через `MY-EXIT` (телефон часто на белых списках). Пересобирается вместе с профилями. + +Ссылка открывается только в сети роутера (вне дома FlClash просто не обновит профиль) и +содержит ссылки подписок — токен и есть секрет; «Новая ссылка» (`mihomo-kit.sh mobile new`) +отзывает старую. + +Без роутера — веб-конструктор: + Открыть [web/index.html](web/index.html) (из репозитория или со своего хостинга) → «Телефон» → подписки и vless-ссылка BOOT → «Скачать» → FlClash: Профили → + → Файл. Страница всё считает в браузере и никуда ничего не отправляет. diff --git a/luci/mihomo-kit.js b/luci/mihomo-kit.js index e2c2b8f..ded5318 100644 --- a/luci/mihomo-kit.js +++ b/luci/mihomo-kit.js @@ -137,6 +137,19 @@ function parseHy2(text) { }); } +// qrcode-generator (luci/qrcode.js, installed with the page): a global "qrcode" +function loadQr() { + if (window.qrcode) + return Promise.resolve(window.qrcode); + return new Promise(function(resolve, reject) { + var s = document.createElement('script'); + s.src = L.resource('mihomo-kit/qrcode.js'); + s.onload = function() { resolve(window.qrcode); }; + s.onerror = function() { reject(new Error('qrcode.js not loaded')); }; + document.head.appendChild(s); + }); +} + function readFile(input) { var f = input.files && input.files[0]; if (!f) @@ -269,6 +282,31 @@ return view.extend({ ])); } + if (st.mobile_path) { + var mobUrl = window.location.protocol + '//' + window.location.host + st.mobile_path; + var qrBox = E('div', { 'style': 'width:220px;max-width:100%;background:#fff;padding:8px;border-radius:4px' }, E('em', 'QR…')); + loadQr().then(function(qrcode) { + var q = qrcode(0, 'M'); + q.addData(mobUrl); + q.make(); + qrBox.innerHTML = q.createSvgTag({ cellSize: 4, margin: 2, scalable: true }); + }).catch(function(e) { dom.content(qrBox, String(e)); }); + sections.push(section('Телефон (FlClash)', [ + E('div', { 'style': 'display:flex;gap:1.5em;flex-wrap:wrap;align-items:flex-start' }, [ + qrBox, + E('div', { 'style': 'flex:1;min-width:16em' }, [ + E('p', 'FlClash → Профили → + → по ссылке (или QR) — профиль из тех же подписок и BOOT, ' + + 'без OpenVPN, Tailscale и торрентов; свои серверы — через MY-EXIT.'), + E('p', [ E('a', { 'href': mobUrl, 'target': '_blank', 'rel': 'noreferrer' }, mobUrl) ]), + E('p', { 'class': 'cbi-value-description' }, 'Ссылка работает только в сети роутера: вне дома FlClash ' + + 'просто не обновит профиль. В ней ссылки подписок — не пересылай; «Новая ссылка» отзывает старую.'), + this.button('Новая ссылка', 'negative', 'mobile-new', null, + 'Выдать новую ссылку? Старая перестанет работать, в FlClash профиль надо будет добавить заново.') + ]) + ]) + ])); + } + sections.push(section('Обслуживание', [ E('table', { 'class': 'table' }, [ row(this.button('Пересобрать профили', 'action', 'build'), @@ -322,7 +360,8 @@ return view.extend({ ts_hostname: text(cfg.ts_hostname), ts_domains: text(cfg.ts_domains, 'corp.example.com'), ovpn_check_url: text(cfg.ovpn_check_url, 'https://eu.bmstu.ru'), - ts_check_url: text(cfg.ts_check_url, 'http://100.69.216.50:8080') + ts_check_url: text(cfg.ts_check_url, 'http://100.69.216.50:8080'), + mobile: check(cfg.mobile) }; var update = function() { @@ -517,6 +556,7 @@ return view.extend({ ts_domains: f.ts_domains.value.trim(), ovpn_check_url: f.ovpn_check_url.value.trim(), ts_check_url: f.ts_check_url.value.trim(), + mobile: f.mobile.checked, hy2: hy2Data }); }, this)).then(L.bind(function(r) { @@ -548,6 +588,8 @@ return view.extend({ ovpnBox, field('Tailscale', f.tailscale), tsBox, + field('Конфиг для телефона', f.mobile, 'FlClash: QR и ссылка появятся на этой странице после сохранения ' + + '(файл раздаётся роутером внутри LAN по ссылке со случайным токеном)'), E('h4', 'Свои серверы (hysteria2)'), E('p', { 'class': 'cbi-value-description' }, 'Собираются в группу MY (автовыбор самого быстрого, в дашборде можно закрепить один). MY — пункт в MAIN ' + 'рядом с FOREIGN. К самим серверам на street — через FOREIGN-ноду, на home — напрямую.'), diff --git a/luci/qrcode.js b/luci/qrcode.js new file mode 100644 index 0000000..3ba25ad --- /dev/null +++ b/luci/qrcode.js @@ -0,0 +1,3 @@ +/* qrcode-generator 1.4.4 (c) Kazuhiko Arase, MIT License + https://github.com/kazuhikoarase/qrcode-generator - vendored for the LuCI page */ +var qrcode=function(){function i(t,r){function a(t,r){g=function(t){for(var r=new Array(t),e=0;e>e&1);g[Math.floor(e/3)][e%3+l-8-3]=n}for(e=0;e<18;e+=1){n=!t&&1==(r>>e&1);g[e%3+l-8-3][Math.floor(e/3)]=n}},v=function(t,r){for(var e=f<<3|r,n=B.getBCHTypeInfo(e),o=0;o<15;o+=1){var i=!t&&1==(n>>o&1);o<6?g[o][8]=i:o<8?g[o+1][8]=i:g[l-15+o][8]=i}for(o=0;o<15;o+=1){i=!t&&1==(n>>o&1);o<8?g[8][l-o-1]=i:o<9?g[8][15-o-1+1]=i:g[8][15-o-1]=i}g[l-8][8]=!t},d=function(t,r){for(var e=-1,n=l-1,o=7,i=0,a=B.getMaskFunction(r),u=l-1;0>>o&1)),a(n,u-f)&&(c=!c),g[n][u-f]=c,-1==(o-=1)&&(i+=1,o=7)}if((n+=e)<0||l<=n){n-=e,e=-e;break}}},w=function(t,r,e){for(var n=b.getRSBlocks(t,r),o=M(),i=0;i8*u)throw"code length overflow. ("+o.getLengthInBits()+">"+8*u+")";for(o.getLengthInBits()+4<=8*u&&o.put(0,4);o.getLengthInBits()%8!=0;)o.putBit(!1);for(;!(o.getLengthInBits()>=8*u||(o.put(236,8),o.getLengthInBits()>=8*u));)o.put(17,8);return function(t,r){for(var e=0,n=0,o=0,i=new Array(r.length),a=new Array(r.length),u=0;u',e+="";for(var n=0;n";for(var o=0;o';e+=""}return e+="",e+=""},s.createSvgTag=function(t,r,e,n){var o={};"object"==typeof t&&(t=(o=t).cellSize,r=o.margin,e=o.alt,n=o.title),t=t||2,r=void 0===r?4*t:r,(e="string"==typeof e?{text:e}:e||{}).text=e.text||null,e.id=e.text?e.id||"qrcode-description":null,(n="string"==typeof n?{text:n}:n||{}).text=n.text||null,n.id=n.text?n.id||"qrcode-title":null;var i,a,u,f,c=s.getModuleCount()*t+2*r,g="";for(f="l"+t+",0 0,"+t+" -"+t+",0 0,-"+t+"z ",g+=''+p(n.text)+"":"",g+=e.text?''+p(e.text)+"":"",g+='',g+='":r+=">";break;case"&":r+="&";break;case'"':r+=""";break;default:r+=n}}return r};return s.createASCII=function(t,r){if((t=t||1)<2)return function(t){t=void 0===t?2:t;var r,e,n,o,i,a=1*s.getModuleCount()+2*t,u=t,f=a-t,c={"██":"█","█ ":"▀"," █":"▄"," ":" "},g={"██":"▀","█ ":"▀"," █":" "," ":" "},l="";for(r=0;r>>8),r.push(255&o)):r.push(a)}}return r}};var r,t,a=1,u=2,o=4,f=8,y={L:1,M:0,Q:3,H:2},e=0,n=1,c=2,g=3,l=4,h=5,s=6,v=7,B=(r=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],(t={}).getBCHTypeInfo=function(t){for(var r=t<<10;0<=d(r)-d(1335);)r^=1335<>>=1;return r}var w=function(){for(var r=new Array(256),e=new Array(256),t=0;t<8;t+=1)r[t]=1<>>8)},writeBytes:function(t,r,e){r=r||0,e=e||t.length;for(var n=0;n>>7-t%8&1)},put:function(t,r){for(var e=0;e>>r-e-1&1))},getLengthInBits:function(){return n},putBit:function(t){var r=Math.floor(n/8);e.length<=r&&e.push(0),t&&(e[r]|=128>>>n%8),n+=1}};return o},x=function(t){var r=a,n=t,e={getMode:function(){return r},getLength:function(t){return n.length},write:function(t){for(var r=n,e=0;e+2>>8&255)+(255&n),t.put(n,13),e+=2}if(e=e.length){if(0==i)return-1;throw"unexpected end of file./"+i}var t=e.charAt(n);if(n+=1,"="==t)return i=0,-1;t.match(/^\s$/)||(o=o<<6|a(t.charCodeAt(0)),i+=6)}var r=o>>>i-8&255;return i-=8,r}},a=function(t){if(65<=t&&t<=90)return t-65;if(97<=t&&t<=122)return t-97+26;if(48<=t&&t<=57)return t-48+52;if(43==t)return 62;if(47==t)return 63;throw"c:"+t};return r},I=function(t,r,e){for(var n=function(t,r){var n=t,o=r,l=new Array(t*r),e={setPixel:function(t,r,e){l[r*n+t]=e},write:function(t){t.writeString("GIF87a"),t.writeShort(n),t.writeShort(o),t.writeByte(128),t.writeByte(0),t.writeByte(0),t.writeByte(0),t.writeByte(0),t.writeByte(0),t.writeByte(255),t.writeByte(255),t.writeByte(255),t.writeString(","),t.writeShort(0),t.writeShort(0),t.writeShort(n),t.writeShort(o),t.writeByte(0);var r=i(2);t.writeByte(2);for(var e=0;255>>r!=0)throw"length over";for(;8<=n+r;)e.writeByte(255&(t<>>=8-n,n=o=0;o|=t<>>o-6),o-=6},t.flush=function(){if(0>6,128|63&n):n<55296||57344<=n?r.push(224|n>>12,128|n>>6&63,128|63&n):(e++,n=65536+((1023&n)<<10|1023&t.charCodeAt(e)),r.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n))}return r}(t)},function(t){"function"==typeof define&&define.amd?define([],t):"object"==typeof exports&&(module.exports=t())}(function(){return qrcode}); \ No newline at end of file diff --git a/luci/rpcd.sh b/luci/rpcd.sh index 6c6c18e..0c2e05c 100644 --- a/luci/rpcd.sh +++ b/luci/rpcd.sh @@ -71,6 +71,9 @@ m_status() { json_add_boolean ts_logged_in "$(b grep -q _current-profile "$NIKKI_DIR/run/tailscale/tailscaled.state")" json_add_string kit_version "$(cat "$NIKKI_DIR/kit/VERSION" 2>/dev/null)" json_add_boolean auto_update "$(b grep -q 'mihomo-kit.sh auto-update' /etc/crontabs/root)" + # phone config (MOBILE=1): /mihomo-kit/.yaml served by uhttpd + mob=$(ls /www/mihomo-kit/*.yaml 2>/dev/null | head -n 1) + json_add_string mobile_path "${mob:+/mihomo-kit/${mob##*/}}" json_add_string auto_update_last "$(tail -n 1 "$NIKKI_DIR/kit/auto-update.log" 2>/dev/null)" l=$(uci -q get nikki.mixin.api_listen) port=${l##*:} @@ -137,6 +140,7 @@ m_run() { build | update | fix) set -- mihomo-kit.sh "$cmd" ;; autoupdate-on) set -- mihomo-kit.sh auto-update on ;; autoupdate-off) set -- mihomo-kit.sh auto-update off ;; + mobile-new) set -- mihomo-kit.sh mobile new ;; *) reply_error "unknown command: $cmd" ;; esac start_job "$@" @@ -213,6 +217,7 @@ m_config_get() { json_add_string ts_domains "${TS_DOMAINS:-}" json_add_string ovpn_check_url "${OVPN_CHECK_URL:-https://eu.bmstu.ru}" json_add_string ts_check_url "${TS_CHECK_URL:-http://100.69.216.50:8080}" + json_add_boolean mobile "${MOBILE:-0}" json_add_array hy2 for n in ${HY2:-}; do k=HY2_$(echo "$n" | tr 'a-z-' 'A-Z_') @@ -237,7 +242,7 @@ m_config_set() { json_select data || reply_error "no data" job_running && reply_error "busy: $(cat "$JOB/cmd")" for v in boot_links hwid_ua hwid_os hwid_os_ver hwid_model hwid_id torrent ru_ips openvpn ovpn \ - vpn_username vpn_password totp_secret tailscale ts_hostname ts_domains ovpn_check_url ts_check_url; do + vpn_username vpn_password totp_secret tailscale ts_hostname ts_domains ovpn_check_url ts_check_url mobile; do json_get_var "$v" "$v" "" done if [ -n "$ovpn" ]; then @@ -284,6 +289,7 @@ m_config_set() { echo "FORM=1" echo "OVPN_CHECK_URL=$(q "$ovpn_check_url")" echo "TS_CHECK_URL=$(q "$ts_check_url")" + echo "MOBILE=$(q "${mobile:-0}")" hy2= if json_select hy2; then json_get_keys keys diff --git a/router/mihomo-kit.sh b/router/mihomo-kit.sh index 937dd2c..3e70810 100755 --- a/router/mihomo-kit.sh +++ b/router/mihomo-kit.sh @@ -23,6 +23,7 @@ # mihomo-kit.sh fix re-apply core version + fixes (after a nikki upgrade) # mihomo-kit.sh ts-login [-f] fresh Tailscale node, print its login URL # (-f: also when the node is already logged in) +# mihomo-kit.sh mobile new new secret link for the phone config (MOBILE=1) # mihomo-kit.sh install packages, core, fixes, links (no questions) # mihomo-kit.sh render ... print the YAML for env file(s) (last wins) @@ -90,6 +91,10 @@ compute_tags() { HY2_LIST="${HY2_LIST:+$HY2_LIST, }$_n" done [ -n "$HY2" ] && TAGS="$TAGS hy2 " HY2_MAIN="MY, " + # own servers through MY-EXIT: street (whitelists) and the phone (often on them) + case "$TAGS" in *" hy2 "*" street "* | *" street "*" hy2 "* | *" hy2 "*" mobile "* | *" mobile "*" hy2 "*) + TAGS="$TAGS hy2_exit " ;; + esac export SUB_LIST HY2_LIST HY2_MAIN } @@ -472,6 +477,45 @@ cmd_build() { die "build of $n failed" fi done + build_mobile +} + +# Phone config (FlClash): with MOBILE=1 in common.env, common.env rendered with +# TARGET=mobile is served by uhttpd as /mihomo-kit/.yaml (subscription +# links inside: the token is the secret, "mobile new" replaces it). +MOBILE_DIR=/www/mihomo-kit +build_mobile() { + if ! grep -q '^MOBILE=1' "$PROFILES_D/common.env" 2>/dev/null || [ ! -d /www ]; then + rm -f "$MOBILE_DIR"/*.yaml + return 0 + fi + if [ ! -s "$KIT_DIR/mobile-token" ]; then + (umask 077; head -c 16 /dev/urandom | md5sum | cut -c1-32 > "$KIT_DIR/mobile-token") + fi + _tok=$(cat "$KIT_DIR/mobile-token") + mkdir -p "$MOBILE_DIR" + chmod 755 "$MOBILE_DIR" + # no directory listing of the tokens + [ -f "$MOBILE_DIR/index.html" ] || : > "$MOBILE_DIR/index.html" + echo TARGET=mobile > /tmp/mihomo-kit-mobile.env + if (cmd_render "$PROFILES_D/common.env" /tmp/mihomo-kit-mobile.env) > "$MOBILE_DIR/$_tok.yaml.tmp"; then + for _f in "$MOBILE_DIR"/*.yaml; do + [ "$_f" = "$MOBILE_DIR/$_tok.yaml" ] || rm -f "$_f" + done + mv "$MOBILE_DIR/$_tok.yaml.tmp" "$MOBILE_DIR/$_tok.yaml" + chmod 644 "$MOBILE_DIR/$_tok.yaml" + log "built phone config /mihomo-kit/$_tok.yaml" + else + rm -f "$MOBILE_DIR/$_tok.yaml.tmp" + log "warning: phone config build failed" + fi + rm -f /tmp/mihomo-kit-mobile.env +} + +cmd_mobile() { + [ "${1:-}" = new ] || die "usage: mobile new" + rm -f "$KIT_DIR/mobile-token" + build_mobile } cmd_use() { @@ -654,6 +698,7 @@ install_luci() { put "$src/acl.json" /usr/share/rpcd/acl.d/luci-app-mihomo-kit.json 644 # rpcd needs a restart only for its plugin and ACL (it drops LuCI sessions) _rpcd=$_changed + put "$src/qrcode.js" /www/luci-static/resources/mihomo-kit/qrcode.js 644 _views=/www/luci-static/resources/view _v=v$(md5sum < "$src/mihomo-kit.js" | cut -c1-8) @@ -861,7 +906,7 @@ common_other_keys() { write_config() { umask 077 _any_hwid=0 - [ "${FORM:-0}" = 1 ] && COMMON_KEYS="$COMMON_KEYS|HY2|HY2_[A-Z0-9_]+|OVPN_CHECK_URL|TS_CHECK_URL" + [ "${FORM:-0}" = 1 ] && COMMON_KEYS="$COMMON_KEYS|HY2|HY2_[A-Z0-9_]+|OVPN_CHECK_URL|TS_CHECK_URL|MOBILE" _others=$(common_other_keys) sub_pairs { @@ -893,6 +938,7 @@ write_config() { if [ "${FORM:-0}" = 1 ]; then [ -n "${OVPN_CHECK_URL:-}" ] && echo "OVPN_CHECK_URL=$(q "$OVPN_CHECK_URL")" [ -n "${TS_CHECK_URL:-}" ] && echo "TS_CHECK_URL=$(q "$TS_CHECK_URL")" + [ "${MOBILE:-0}" = 1 ] && echo "MOBILE=1" echo "HY2=$(q "$HY2")" for _n in $HY2; do _k=$(hy2_key "$_n") @@ -1124,6 +1170,7 @@ case "${1:-}" in use) shift; cmd_use "$@" ;; setup) shift; cmd_setup "$@" ;; configure) shift; cmd_configure "$@" ;; + mobile) shift; cmd_mobile "$@" ;; sub-ids) cmd_sub_ids ;; update) shift; cmd_update "$@" ;; auto-update) shift; cmd_auto_update "$@" ;; @@ -1132,5 +1179,5 @@ case "${1:-}" in install) cmd_install ;; fix) cmd_fix ;; ts-login) shift; cmd_ts_login "$@" ;; - *) sed -n '2,29p' "$SELF" >&2; exit 2 ;; + *) sed -n '2,30p' "$SELF" >&2; exit 2 ;; esac diff --git a/templates/groups/45-hy2.yaml b/templates/groups/45-hy2.yaml index 84cbffc..b7e1f16 100644 --- a/templates/groups/45-hy2.yaml +++ b/templates/groups/45-hy2.yaml @@ -7,13 +7,13 @@ tolerance: 50 lazy: false - # street: what own servers are reached through; switches only when the node is + # street and mobile (hy2_exit): what own servers are reached through; switches only when the node is # clearly worse or dead (each switch breaks everything going through MY) - - name: MY-EXIT #@street - type: url-test #@street - use: [${SUB_LIST}] #@street - exclude-filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск" #@street - url: "https://www.gstatic.com/generate_204" #@street - interval: 300 #@street - tolerance: 300 #@street - lazy: false #@street + - name: MY-EXIT #@hy2_exit + type: url-test #@hy2_exit + use: [${SUB_LIST}] #@hy2_exit + exclude-filter: "(?i)🇷🇺|\\bru\\b|russia|росси|моск" #@hy2_exit + url: "https://www.gstatic.com/generate_204" #@hy2_exit + interval: 300 #@hy2_exit + tolerance: 300 #@hy2_exit + lazy: false #@hy2_exit diff --git a/templates/proxies/30-hy2.each.yaml b/templates/proxies/30-hy2.each.yaml index 43e0a72..45cdc10 100644 --- a/templates/proxies/30-hy2.each.yaml +++ b/templates/proxies/30-hy2.each.yaml @@ -10,4 +10,4 @@ up: "${@@HY2_UP}" down: "${@@HY2_DOWN}" udp: true - dialer-proxy: MY-EXIT #@street + dialer-proxy: MY-EXIT #@hy2_exit diff --git a/tests/fixtures/mobile.env b/tests/fixtures/mobile.env index 4aa7c3c..7810487 100644 --- a/tests/fixtures/mobile.env +++ b/tests/fixtures/mobile.env @@ -1 +1,5 @@ TARGET=mobile +HY2=m1 +HY2_M1_SERVER=m.example.com +HY2_M1_PORT=443 +HY2_M1_PASSWORD=p diff --git a/web/engine.js b/web/engine.js index 2ae029c..9108791 100644 --- a/web/engine.js +++ b/web/engine.js @@ -195,6 +195,8 @@ if (v.TS_EXIT === "1") t.add("ts_exit"); } } + // own servers through MY-EXIT: street (whitelists) and the phone (see compute_tags) + if (t.has("hy2") && (t.has("street") || t.has("mobile"))) t.add("hy2_exit"); return t; } diff --git a/web/index.html b/web/index.html index e75f576..9b97af4 100644 --- a/web/index.html +++ b/web/index.html @@ -383,6 +383,8 @@ if (v.TS_EXIT === "1") t.add("ts_exit"); } } + // own servers through MY-EXIT: street (whitelists) and the phone (see compute_tags) + if (t.has("hy2") && (t.has("street") || t.has("mobile"))) t.add("hy2_exit"); return t; } @@ -490,7 +492,7 @@ const TEMPLATES = { "groups/30-torrent.yaml": " - name: TORRENT\n type: url-test\n use: [${SUB_LIST}]\n filter: \"(?i)torrent|\\\\[tor\\\\]\"\n url: \"https://www.gstatic.com/generate_204\"\n interval: 300\n timeout: 6000\n tolerance: 500\n max-failed-times: 5\n lazy: false\n", "groups/40-openvpn.yaml": " # url: what the dashboard's delay test opens through the tunnel;\n # interval 0: no background checks (they would redial with a stale OTP)\n - name: ${OVPN_GROUP}\n type: select\n use: [${OVPN_PROVIDER}]\n url: \"${OVPN_CHECK_URL}\"\n interval: 0\n", "groups/41-openvpn.street.yaml": " # what the OpenVPN tunnel itself goes through on a whitelisted network.\n # select, not url-test: switching nodes would break the tunnel.\n # Pick a concrete RU node in the dashboard, the choice is remembered.\n - name: OVPN-EXIT\n type: select\n use: [${SUB_LIST}]\n filter: \"(?i)🇷🇺|\\\\bru\\\\b|russia|росси|моск\"\n", - "groups/45-hy2.yaml": " # own hysteria2 servers: the fastest alive one; pin one in the dashboard if needed\n - name: MY\n type: url-test\n proxies: [${HY2_LIST}]\n url: \"https://www.gstatic.com/generate_204\"\n interval: 300\n tolerance: 50\n lazy: false\n\n # street: what own servers are reached through; switches only when the node is\n # clearly worse or dead (each switch breaks everything going through MY)\n - name: MY-EXIT #@street\n type: url-test #@street\n use: [${SUB_LIST}] #@street\n exclude-filter: \"(?i)🇷🇺|\\\\bru\\\\b|russia|росси|моск\" #@street\n url: \"https://www.gstatic.com/generate_204\" #@street\n interval: 300 #@street\n tolerance: 300 #@street\n lazy: false #@street\n", + "groups/45-hy2.yaml": " # own hysteria2 servers: the fastest alive one; pin one in the dashboard if needed\n - name: MY\n type: url-test\n proxies: [${HY2_LIST}]\n url: \"https://www.gstatic.com/generate_204\"\n interval: 300\n tolerance: 50\n lazy: false\n\n # street and mobile (hy2_exit): what own servers are reached through; switches only when the node is\n # clearly worse or dead (each switch breaks everything going through MY)\n - name: MY-EXIT #@hy2_exit\n type: url-test #@hy2_exit\n use: [${SUB_LIST}] #@hy2_exit\n exclude-filter: \"(?i)🇷🇺|\\\\bru\\\\b|russia|росси|моск\" #@hy2_exit\n url: \"https://www.gstatic.com/generate_204\" #@hy2_exit\n interval: 300 #@hy2_exit\n tolerance: 300 #@hy2_exit\n lazy: false #@hy2_exit\n", "groups/50-tailscale.yaml": " # url (TS_CHECK_URL, optional): a tailnet service for the dashboard's delay test\n - name: TAILSCALE\n type: select\n proxies: [tailscale]\n url: \"${@TS_CHECK_URL}\"\n interval: 0\n", "groups/51-tailscale.ts_exit.yaml": " # Tailscale needs full-cone UDP from its dialer-proxy: vless/vmess/trojan\n # cannot do it in mihomo, so only ss / hysteria2 / tuic / socks5 nodes here.\n - name: TS-EXIT\n type: select\n proxies: [MY] #@hy2\n use: [${SUB_LIST}]\n exclude-type: \"vless|vmess|trojan\"\n", "groups/90-base.yaml": " - name: MAIN\n type: select\n proxies: [FOREIGN, ${HY2_MAIN}RU, DIRECT]\n", @@ -501,7 +503,7 @@ const TEMPLATES = { "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.each.yaml": " - name: ${SEED_NAME}\n type: vless\n server: ${SEED_SERVER}\n port: ${SEED_PORT}\n uuid: ${SEED_UUID}\n network: tcp\n udp: true\n tls: true\n flow: xtls-rprx-vision\n servername: ${SEED_SNI}\n client-fingerprint: firefox\n reality-opts:\n public-key: ${SEED_PBK}\n short-id: ${SEED_SID}\n", "proxies/20-tailscale.yaml": " # Tailscale: userspace node, starts on first use. First login: open the URL\n # from the nikki log (\"To start this tsnet server ... go to: ...\"), then\n # disable key expiry for this node. Needs TS_FORCE_NOISE_443=true in the\n # mihomo environment (mihomo-kit.sh fix).\n - name: tailscale\n type: tailscale\n hostname: ${TS_HOSTNAME}\n state-dir: ./tailscale\n udp: true\n accept-routes: true\n dialer-proxy: TS-EXIT #@ts_exit\n", - "proxies/30-hy2.each.yaml": " - name: ${HY2_NAME}\n type: hysteria2\n server: ${HY2_SERVER}\n port: ${HY2_PORT}\n password: \"${HY2_PASSWORD}\"\n obfs: ${@HY2_OBFS}\n obfs-password: \"${@@HY2_OBFS_PASSWORD}\"\n sni: ${@HY2_SNI}\n skip-cert-verify: ${HY2_INSECURE}\n up: \"${@@HY2_UP}\"\n down: \"${@@HY2_DOWN}\"\n udp: true\n dialer-proxy: MY-EXIT #@street\n", + "proxies/30-hy2.each.yaml": " - name: ${HY2_NAME}\n type: hysteria2\n server: ${HY2_SERVER}\n port: ${HY2_PORT}\n password: \"${HY2_PASSWORD}\"\n obfs: ${@HY2_OBFS}\n obfs-password: \"${@@HY2_OBFS_PASSWORD}\"\n sni: ${@HY2_SNI}\n skip-cert-verify: ${HY2_INSECURE}\n up: \"${@@HY2_UP}\"\n down: \"${@@HY2_DOWN}\"\n udp: true\n dialer-proxy: MY-EXIT #@hy2_exit\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/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",