Added any custom mihomo protocols support
This commit is contained in:
parent
b1b783fd15
commit
59f8d43aa0
14
README.md
14
README.md
@ -219,6 +219,14 @@ BOOT — whitelisted seed-ноды для скачивания подписок:
|
||||
что в `FOREIGN`, но с `tolerance: 300`: меняет ноду, только если текущая заметно хуже или
|
||||
умерла — каждая смена рвёт всё, что идёт через `MY`), на `main` — напрямую.
|
||||
|
||||
Свои серверы других протоколов — там же, поле «Ссылки» (или `MY_LINKS` в `common.env`, через
|
||||
пробел): ссылки `vless://`, `vmess://`, `trojan://`, `ss://`, `hysteria2://`, `tuic://`,
|
||||
`anytls://` как из приложения. Разбирает их само ядро, как подписку (reality, xhttp, ws,
|
||||
grpc и т. д.): kit при сборке пишет их в `run/providers/my-links.txt` (права 600), его читает
|
||||
file-провайдер `my-links` в группе `MY`, ноды называются `[MY] <имя из ссылки>`. Пробелы в имени
|
||||
после `#` форма заменяет на `%20`. Как и hysteria2, на `whitelist` они идут через `MY-EXIT`.
|
||||
Только на роутере: в конфиг телефона ссылки не попадают (на телефоне — `[MY]`-ноды подписки).
|
||||
|
||||
Свои серверы можно держать и в своей подписке: ноды, в имени которых есть `[MY]`
|
||||
(`[MY] 🇩🇪 de-1`, регистр не важен), из любой подписки сами попадают в `MY`, а не в `RU` /
|
||||
`FOREIGN` / `TORRENT`. Поменял адрес сервера в подписке — роутеры подхватят при
|
||||
@ -228,7 +236,7 @@ BOOT — whitelisted seed-ноды для скачивания подписок:
|
||||
только их (на телефоне FlClash переносит файлы провайдеров к себе, поэтому там `<имя>-my`
|
||||
качает ту же ссылку ещё раз) — свой провайдер нужен, чтобы на `whitelist` и телефоне ходить к ним через
|
||||
`MY-EXIT`. Группа `MY` теперь есть
|
||||
всегда; без hysteria2 и без `[MY]`-нод она пустая, и `PUSH` на `whitelist` тогда по
|
||||
всегда; без hysteria2, ссылок и `[MY]`-нод она пустая, и `PUSH` на `whitelist` тогда по
|
||||
умолчанию `FOREIGN`.
|
||||
|
||||
CSQTT ([star-panel-csqtt](https://github.com/starkugz/csqtt-openwrt)) — резервный выход из белых
|
||||
@ -462,8 +470,8 @@ tests/fixtures/ профили для test.sh (фиктивные секре
|
||||
- `${@VAR}` — строка повторяется для каждого слова из `VAR`;
|
||||
- `${VAR}` — подстановка.
|
||||
|
||||
Теги: `base`, `sub`, `router`|`mobile`, `main`|`whitelist`|`foreign` (роутер), служебные `ovpn_exit` (whitelist, foreign), `hy2_exit` (whitelist, телефон), `boot`, `torrent`, `push`,
|
||||
`openvpn`, `tailscale`, `ts_exit`, `hy2`, `csqtt`. Значения по умолчанию — `set_defaults` в
|
||||
Теги: `base`, `sub`, `router`|`mobile`, `main`|`whitelist`|`foreign` (роутер), служебные `ovpn_exit` (whitelist, foreign), `my_exit` (whitelist, телефон), `own` (`hy2` или `my_links`), `boot`, `torrent`, `push`,
|
||||
`openvpn`, `tailscale`, `ts_exit`, `hy2`, `my_links`, `local_hosts`, `csqtt`, `lite`. Значения по умолчанию — `set_defaults` в
|
||||
`router/mihomo-kit.sh` и `DEFAULTS` в `web/engine.js` (держать одинаковыми).
|
||||
|
||||
### Ядро kit
|
||||
|
||||
@ -599,6 +599,8 @@ return view.extend({
|
||||
foreign_domains: text(cfg.foreign_domains, 'example.com *.example.org'),
|
||||
my_domains: text(cfg.my_domains, 'example.com *.example.org'),
|
||||
local_hosts: text(cfg.local_hosts, 'example.com=192.168.1.10'),
|
||||
my_links: E('textarea', { 'class': 'cbi-input-textarea', 'rows': 3, 'style': 'width:100%;font-family:monospace',
|
||||
'placeholder': 'vless://…\ntrojan://…\nss://… (по одной на строку)' }, cfg.my_links || ''),
|
||||
openvpn: check(cfg.openvpn),
|
||||
csqtt: check(cfg.csqtt),
|
||||
ovpn: E('input', { 'type': 'file', 'accept': '.ovpn,.conf' }),
|
||||
@ -824,6 +826,7 @@ return view.extend({
|
||||
foreign_domains: f.foreign_domains.value.trim(),
|
||||
my_domains: f.my_domains.value.trim(),
|
||||
local_hosts: f.local_hosts.value.trim(),
|
||||
my_links: f.my_links.value.trim(),
|
||||
openvpn: f.openvpn.checked,
|
||||
csqtt: f.csqtt.checked,
|
||||
ovpn: ovpn,
|
||||
@ -894,10 +897,14 @@ return view.extend({
|
||||
field('Локальные адреса', f.local_hosts, 'домен=IP в локальной сети (с поддоменами): роутер и клиенты ' +
|
||||
'ходят к серверу напрямую по LAN, а не через белый IP и обратно. Только для этого роутера (не телефон, ' +
|
||||
'при импорте не переносится)'),
|
||||
E('h4', 'Свои серверы (hysteria2)'),
|
||||
E('h4', 'Свои серверы'),
|
||||
E('p', { 'class': 'cbi-value-description' }, 'Собираются в группу MY (автовыбор самого быстрого, в дашборде можно закрепить один). MY — пункт в MAIN ' +
|
||||
'рядом с FOREIGN. К самим серверам на whitelist — через MY-EXIT, на main — напрямую. ' +
|
||||
'Серверы из подписок с [MY] в имени (например «[MY] 🇩🇪 de-1») тоже попадают в MY, а не в FOREIGN/RU.'),
|
||||
field('Ссылки', f.my_links, 'vless / vmess / trojan / ss / hysteria2 / tuic / anytls — как в приложении ' +
|
||||
'(reality, xhttp, ws, grpc разбирает само ядро); в MY как «[MY] имя». Только на этом роутере, в конфиг ' +
|
||||
'телефона не попадают'),
|
||||
E('h5', 'hysteria2 по полям'),
|
||||
hy2List,
|
||||
importBox,
|
||||
E('div', [
|
||||
|
||||
10
luci/rpcd.sh
10
luci/rpcd.sh
@ -283,6 +283,10 @@ m_config_get() {
|
||||
json_add_string foreign_domains "${FOREIGN_DOMAINS:-}"
|
||||
json_add_string my_domains "${MY_DOMAINS:-}"
|
||||
json_add_string local_hosts "${LOCAL_HOSTS:-}"
|
||||
# own servers as links: one per line in the form
|
||||
set -f
|
||||
json_add_string my_links "$(printf '%s\n' ${MY_LINKS:-})"
|
||||
set +f
|
||||
json_add_boolean openvpn "${OPENVPN:-0}"
|
||||
json_add_boolean csqtt "${CSQTT:-0}"
|
||||
json_add_boolean ovpn_file "$(b test -f "$NIKKI_DIR/bmstu.ovpn")"
|
||||
@ -313,7 +317,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,
|
||||
# foreign_ips, my_ips, ru_domains, foreign_domains, my_domains, local_hosts, my_links (one per line),
|
||||
# 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,
|
||||
# obfs_password, sni, insecure, up, down}]}}; empty OpenVPN secrets keep the saved ones
|
||||
@ -322,7 +326,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 push ru_ips foreign_ips my_ips \
|
||||
ru_domains foreign_domains my_domains local_hosts openvpn csqtt ovpn \
|
||||
ru_domains foreign_domains my_domains local_hosts my_links openvpn csqtt ovpn \
|
||||
vpn_username vpn_password totp_secret tailscale ts_hostname ts_domains ovpn_check_url ts_check_url mobile \
|
||||
lite lite_gomemlimit; do
|
||||
json_get_var "$v" "$v" ""
|
||||
@ -368,6 +372,8 @@ m_config_set() {
|
||||
echo "FOREIGN_DOMAINS=$(q "$foreign_domains")"
|
||||
echo "MY_DOMAINS=$(q "$my_domains")"
|
||||
echo "LOCAL_HOSTS=$(q "$local_hosts")"
|
||||
# one link per line; a space is never part of a link (a name with spaces after # -> %20)
|
||||
echo "MY_LINKS=$(q "$(printf '%s\n' "$my_links" | sed 's/^[[:space:]]*//; s/[[:space:]]*$//; s/[[:space:]]/%20/g' | grep . | tr '\n' ' ' | sed 's/ $//')")"
|
||||
echo "OPENVPN=$(q "${openvpn:-0}")"
|
||||
echo "CSQTT=$(q "${csqtt:-0}")"
|
||||
echo "VPN_USERNAME=$(q "$vpn_username")"
|
||||
|
||||
@ -89,7 +89,7 @@ set_defaults() {
|
||||
: "${BOOT:=1}" "${TORRENT:=1}" "${PUSH:=1}" "${OPENVPN:=0}" "${TAILSCALE:=0}" "${TS_EXIT:=0}"
|
||||
: "${SUBS:=}" "${RU_IPS:=}" "${HY2:=}"
|
||||
: "${FOREIGN_IPS:=}" "${MY_IPS:=}" "${RU_DOMAINS:=}" "${FOREIGN_DOMAINS:=}" "${MY_DOMAINS:=}"
|
||||
: "${LOCAL_HOSTS:=}"
|
||||
: "${LOCAL_HOSTS:=}" "${MY_LINKS:=}"
|
||||
: "${RULESET_URL:=https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release}"
|
||||
: "${BOOT_LINKS:=}"
|
||||
: "${BOOT_SERVER:=}" "${BOOT_PORT:=443}" "${BOOT_UUID:=}" "${BOOT_SNI:=}" "${BOOT_PBK:=}" "${BOOT_SID:=}"
|
||||
@ -120,6 +120,8 @@ compute_tags() {
|
||||
[ "$LITE" = 1 ] && TAGS="$TAGS lite "
|
||||
# own servers in the LAN (LOCAL_HOSTS): only the router is always at home
|
||||
[ -n "$LOCAL_HOSTS" ] && TAGS="$TAGS local_hosts "
|
||||
# own servers as links (MY_LINKS): a file on the router, the phone cannot read it
|
||||
[ -n "$MY_LINKS" ] && TAGS="$TAGS my_links "
|
||||
fi
|
||||
# CSQTT tunnel (star-panel-csqtt): last in MAIN (plain exit through its server)
|
||||
CSQTT_MAIN=""
|
||||
@ -139,6 +141,12 @@ compute_tags() {
|
||||
HY2_LIST="${HY2_LIST:+$HY2_LIST, }$_n"
|
||||
done
|
||||
[ -n "$HY2" ] && TAGS="$TAGS hy2 "
|
||||
# MY has servers for sure: hysteria2 from the settings or links (not only maybe [MY] nodes)
|
||||
case "$TAGS" in *" hy2 "* | *" my_links "*)
|
||||
TAGS="$TAGS own "
|
||||
;;
|
||||
esac
|
||||
case "$TAGS" in *" my_links "*) MY_SUB_LIST="${MY_SUB_LIST:+$MY_SUB_LIST, }my-links" ;; esac
|
||||
# OpenVPN through OVPN-EXIT (a RU node): whitelist and abroad
|
||||
case "$TAGS" in *" router "*" whitelist "* | *" router "*" foreign "*) TAGS="$TAGS ovpn_exit " ;; esac
|
||||
# own servers through MY-EXIT: whitelist and the phone (often on whitelists)
|
||||
@ -253,6 +261,14 @@ check_vars() {
|
||||
[ -n "$SUBS" ] || die "SUBS is empty (subscription URLs)"
|
||||
case "$TARGET" in router | mobile) ;; *) die "TARGET must be router or mobile" ;; esac
|
||||
case "$LOCATION" in main | whitelist | foreign) ;; *) die "LOCATION must be main, whitelist or foreign" ;; esac
|
||||
set -f
|
||||
for _l in $MY_LINKS; do
|
||||
case "$_l" in
|
||||
vless://?* | vmess://?* | trojan://?* | ss://?* | hysteria2://?* | hy2://?* | tuic://?* | anytls://?*) ;;
|
||||
*) die "MY_LINKS: '${_l%%\?*}' is not a vless/vmess/trojan/ss/hysteria2/tuic/anytls link" ;;
|
||||
esac
|
||||
done
|
||||
set +f
|
||||
if [ "$BOOT" = 1 ]; then
|
||||
[ -n "$SEED_ITEMS" ] || die "BOOT=1 but no BOOT_LINKS (vless links of the seed nodes)"
|
||||
for _it in $SEED_ITEMS; do
|
||||
@ -557,6 +573,25 @@ cmd_render() {
|
||||
# <name>.all - the list (bmstu-otp.sh on puts it back), <name>.yaml - what mihomo
|
||||
# reads: the list, or empty while the tunnel should be off (manual off, timer,
|
||||
# schedule: bmstu-otp.sh want)
|
||||
# own servers as links (MY_LINKS) -> run/providers/my-links.txt, one per line, for the
|
||||
# file provider my-links (templates/providers): mihomo itself parses them like a
|
||||
# subscription. Holds secrets: 600. No links -> no file.
|
||||
my_links_write() {
|
||||
(
|
||||
[ -f "$PROFILES_D/common.env" ] && load_env "$PROFILES_D/common.env"
|
||||
set_defaults
|
||||
_f=$NIKKI_DIR/run/providers/my-links.txt
|
||||
if [ -z "$MY_LINKS" ]; then
|
||||
rm -f "$_f"
|
||||
exit 0
|
||||
fi
|
||||
mkdir -p "${_f%/*}"
|
||||
umask 077
|
||||
set -f
|
||||
printf '%s\n' $MY_LINKS > "$_f.tmp" && mv "$_f.tmp" "$_f"
|
||||
)
|
||||
}
|
||||
|
||||
ovpn_routes_write() {
|
||||
(
|
||||
[ -f "$PROFILES_D/common.env" ] && load_env "$PROFILES_D/common.env"
|
||||
@ -582,8 +617,9 @@ ovpn_routes_write() {
|
||||
cmd_build() {
|
||||
[ -d "$PROFILES_D" ] || die "no $PROFILES_D (see profile.env.example)"
|
||||
mkdir -p "$PROFILES_OUT"
|
||||
# before mihomo -t: the profiles reference this file
|
||||
# before mihomo -t: the profiles reference these files
|
||||
ovpn_routes_write
|
||||
my_links_write
|
||||
if [ $# -eq 0 ]; then
|
||||
for e in "$PROFILES_D"/*.env; do
|
||||
n=${e##*/}
|
||||
@ -1526,11 +1562,11 @@ common_other_keys() {
|
||||
# common.env (+ bmstu.env) from the variables the wizard / configure set;
|
||||
# per-subscription values come as SUB<index>_PROXY/HWID (index in SUBS).
|
||||
# Keys only the LuCI form sets (own hysteria2 servers HY2, HY2_<NAME>_*, MY_IPS,
|
||||
# MY_DOMAINS, LOCAL_HOSTS, LITE, check URLs) are rewritten only with FORM=1; the terminal wizard keeps them.
|
||||
# MY_DOMAINS, LOCAL_HOSTS, MY_LINKS, LITE, check URLs) are rewritten only with FORM=1; the terminal wizard keeps them.
|
||||
write_config() {
|
||||
umask 077
|
||||
_any_hwid=0
|
||||
[ "${FORM:-0}" = 1 ] && COMMON_KEYS="$COMMON_KEYS|HY2|HY2_[A-Z0-9_]+|MY_IPS|MY_DOMAINS|LOCAL_HOSTS|LITE|LITE_GOMEMLIMIT|OVPN_CHECK_URL|TS_CHECK_URL|MOBILE"
|
||||
[ "${FORM:-0}" = 1 ] && COMMON_KEYS="$COMMON_KEYS|HY2|HY2_[A-Z0-9_]+|MY_IPS|MY_DOMAINS|LOCAL_HOSTS|MY_LINKS|LITE|LITE_GOMEMLIMIT|OVPN_CHECK_URL|TS_CHECK_URL|MOBILE"
|
||||
_others=$(common_other_keys)
|
||||
sub_pairs
|
||||
{
|
||||
@ -1574,6 +1610,7 @@ write_config() {
|
||||
[ -n "${MY_IPS:-}" ] && echo "MY_IPS=$(q "$MY_IPS")"
|
||||
[ -n "${MY_DOMAINS:-}" ] && echo "MY_DOMAINS=$(q "$MY_DOMAINS")"
|
||||
[ -n "${LOCAL_HOSTS:-}" ] && echo "LOCAL_HOSTS=$(q "$LOCAL_HOSTS")"
|
||||
[ -n "${MY_LINKS:-}" ] && echo "MY_LINKS=$(q "$MY_LINKS")"
|
||||
for _n in $HY2; do
|
||||
_k=$(hy2_key "$_n")
|
||||
for v in SERVER PORT PASSWORD OBFS_PASSWORD SNI INSECURE UP DOWN; do
|
||||
|
||||
@ -2,6 +2,6 @@
|
||||
# cannot do it in mihomo, so only ss / hysteria2 / tuic / socks5 nodes here.
|
||||
- name: TS-EXIT
|
||||
type: select
|
||||
proxies: [MY] #@hy2
|
||||
proxies: [MY] #@own
|
||||
use: [${SUB_LIST}]
|
||||
exclude-type: "vless|vmess|trojan"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
- name: PUSH
|
||||
type: select
|
||||
proxies: [DIRECT, MY, FOREIGN] #@!whitelist
|
||||
proxies: [MY, FOREIGN, DIRECT] #@whitelist,hy2
|
||||
# no hysteria2: MY may be empty (no [MY] nodes in the subscriptions) #@whitelist,!hy2
|
||||
proxies: [FOREIGN, MY, DIRECT] #@whitelist,!hy2
|
||||
proxies: [MY, FOREIGN, DIRECT] #@whitelist,own
|
||||
# no own servers in the settings: MY may be empty (no [MY] nodes in the subscriptions) #@whitelist,!own
|
||||
proxies: [FOREIGN, MY, DIRECT] #@whitelist,!own
|
||||
|
||||
18
templates/providers/17-my_links.yaml
Normal file
18
templates/providers/17-my_links.yaml
Normal file
@ -0,0 +1,18 @@
|
||||
# own servers as links (MY_LINKS, LuCI "Свои серверы (ссылки)"): kit writes them to
|
||||
# this file on build, mihomo parses vless/vmess/trojan/ss/hysteria2/tuic/anytls links
|
||||
# like a subscription; group MY, named "[MY] ..." like the [MY] nodes of the subscriptions
|
||||
my-links:
|
||||
type: file
|
||||
path: ./providers/my-links.txt
|
||||
override:
|
||||
additional-prefix: "[MY] "
|
||||
dialer-proxy: MY-EXIT #@my_exit
|
||||
dialer-proxy: UPLINK #@csqtt,!my_exit
|
||||
health-check:
|
||||
enable: true
|
||||
url: "https://www.gstatic.com/generate_204"
|
||||
interval: 300 #@!lite
|
||||
interval: 600 #@lite
|
||||
timeout: 3000
|
||||
lazy: false #@!lite
|
||||
lazy: true #@lite
|
||||
1
tests/fixtures/mobile.env
vendored
1
tests/fixtures/mobile.env
vendored
@ -4,3 +4,4 @@ HY2_M1_SERVER=m.example.com
|
||||
HY2_M1_PORT=443
|
||||
HY2_M1_PASSWORD=p
|
||||
LOCAL_HOSTS="sub2.example.com=192.168.64.20"
|
||||
MY_LINKS='ss://YWVzLTI1Ni1nY206cGFzcw@1.2.3.4:8388#ss1'
|
||||
|
||||
1
tests/fixtures/router-whitelist-ts-my.env
vendored
1
tests/fixtures/router-whitelist-ts-my.env
vendored
@ -1,3 +1,4 @@
|
||||
TARGET=router
|
||||
LOCATION=whitelist
|
||||
TAILSCALE=1
|
||||
MY_LINKS='vless://00000000-0000-0000-0000-000000000001@x.example.com:443?security=reality&sni=www.example.com&pbk=Nc9ZSDuQMwHN4M6TeDHjfJhgZ6SBTBbfMwx5iHQZ1ns&sid=ab&type=xhttp&path=%2Fx#de%201 trojan://pw@t.example.org:443?sni=t.example.org#tr'
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
BOOT: "1", TORRENT: "1", PUSH: "1", OPENVPN: "0", TAILSCALE: "0", TS_EXIT: "0",
|
||||
SUBS: "", RU_IPS: "", HY2: "",
|
||||
FOREIGN_IPS: "", MY_IPS: "", RU_DOMAINS: "", FOREIGN_DOMAINS: "", MY_DOMAINS: "",
|
||||
LOCAL_HOSTS: "",
|
||||
LOCAL_HOSTS: "", MY_LINKS: "",
|
||||
RULESET_URL: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release",
|
||||
BOOT_LINKS: "",
|
||||
BOOT_SERVER: "", BOOT_PORT: "443", BOOT_UUID: "", BOOT_SNI: "", BOOT_PBK: "", BOOT_SID: "",
|
||||
@ -166,6 +166,10 @@
|
||||
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 (!["main", "whitelist", "foreign"].includes(v.LOCATION)) throw new Error("LOCATION must be main, whitelist or foreign");
|
||||
for (const l of words(v.MY_LINKS)) {
|
||||
if (!/^(vless|vmess|trojan|ss|hysteria2|hy2|tuic|anytls):\/\/./.test(l))
|
||||
throw new Error(`MY_LINKS: '${l.split("?")[0]}' is not a vless/vmess/trojan/ss/hysteria2/tuic/anytls link`);
|
||||
}
|
||||
if (v.BOOT === "1") {
|
||||
const seeds = bootSeeds(v);
|
||||
if (!seeds.length) throw new Error("BOOT=1 but no BOOT_LINKS (vless links of the seed nodes)");
|
||||
@ -239,7 +243,11 @@
|
||||
if (v.LITE === "1") t.add("lite");
|
||||
// own servers in the LAN (LOCAL_HOSTS): only the router is always at home
|
||||
if (words(v.LOCAL_HOSTS).length) t.add("local_hosts");
|
||||
// own servers as links (MY_LINKS): a file on the router, the phone cannot read it
|
||||
if (words(v.MY_LINKS).length) t.add("my_links");
|
||||
}
|
||||
// MY has servers for sure: hysteria2 from the settings or links (see compute_tags)
|
||||
if (t.has("hy2") || t.has("my_links")) t.add("own");
|
||||
// OpenVPN through OVPN-EXIT: whitelist and abroad (see compute_tags)
|
||||
if (t.has("router") && (t.has("whitelist") || t.has("foreign"))) t.add("ovpn_exit");
|
||||
// own servers through MY-EXIT: whitelist and the phone (see compute_tags)
|
||||
@ -298,7 +306,8 @@
|
||||
const subs = subPairs(v.SUBS);
|
||||
v.SUB_LIST = subs.filter((s, i) => !subOff(v, i, s.id)).map((s) => s.id).join(", ");
|
||||
// providers of the "[MY] ..." nodes (group MY)
|
||||
v.MY_SUB_LIST = subs.filter((s, i) => !subOff(v, i, s.id)).map((s) => s.id + "-my").join(", ");
|
||||
v.MY_SUB_LIST = subs.filter((s, i) => !subOff(v, i, s.id)).map((s) => s.id + "-my")
|
||||
.concat(tags.has("my_links") ? ["my-links"] : []).join(", ");
|
||||
const seeds = bootSeeds(v);
|
||||
v.SEED_LIST = seeds.map((s) => s.name).join(", ");
|
||||
const hy2 = words(v.HY2);
|
||||
|
||||
@ -214,7 +214,7 @@
|
||||
BOOT: "1", TORRENT: "1", PUSH: "1", OPENVPN: "0", TAILSCALE: "0", TS_EXIT: "0",
|
||||
SUBS: "", RU_IPS: "", HY2: "",
|
||||
FOREIGN_IPS: "", MY_IPS: "", RU_DOMAINS: "", FOREIGN_DOMAINS: "", MY_DOMAINS: "",
|
||||
LOCAL_HOSTS: "",
|
||||
LOCAL_HOSTS: "", MY_LINKS: "",
|
||||
RULESET_URL: "https://cdn.jsdelivr.net/gh/SamLatsin/russia-only@release",
|
||||
BOOT_LINKS: "",
|
||||
BOOT_SERVER: "", BOOT_PORT: "443", BOOT_UUID: "", BOOT_SNI: "", BOOT_PBK: "", BOOT_SID: "",
|
||||
@ -364,6 +364,10 @@
|
||||
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 (!["main", "whitelist", "foreign"].includes(v.LOCATION)) throw new Error("LOCATION must be main, whitelist or foreign");
|
||||
for (const l of words(v.MY_LINKS)) {
|
||||
if (!/^(vless|vmess|trojan|ss|hysteria2|hy2|tuic|anytls):\/\/./.test(l))
|
||||
throw new Error(`MY_LINKS: '${l.split("?")[0]}' is not a vless/vmess/trojan/ss/hysteria2/tuic/anytls link`);
|
||||
}
|
||||
if (v.BOOT === "1") {
|
||||
const seeds = bootSeeds(v);
|
||||
if (!seeds.length) throw new Error("BOOT=1 but no BOOT_LINKS (vless links of the seed nodes)");
|
||||
@ -437,7 +441,11 @@
|
||||
if (v.LITE === "1") t.add("lite");
|
||||
// own servers in the LAN (LOCAL_HOSTS): only the router is always at home
|
||||
if (words(v.LOCAL_HOSTS).length) t.add("local_hosts");
|
||||
// own servers as links (MY_LINKS): a file on the router, the phone cannot read it
|
||||
if (words(v.MY_LINKS).length) t.add("my_links");
|
||||
}
|
||||
// MY has servers for sure: hysteria2 from the settings or links (see compute_tags)
|
||||
if (t.has("hy2") || t.has("my_links")) t.add("own");
|
||||
// OpenVPN through OVPN-EXIT: whitelist and abroad (see compute_tags)
|
||||
if (t.has("router") && (t.has("whitelist") || t.has("foreign"))) t.add("ovpn_exit");
|
||||
// own servers through MY-EXIT: whitelist and the phone (see compute_tags)
|
||||
@ -496,7 +504,8 @@
|
||||
const subs = subPairs(v.SUBS);
|
||||
v.SUB_LIST = subs.filter((s, i) => !subOff(v, i, s.id)).map((s) => s.id).join(", ");
|
||||
// providers of the "[MY] ..." nodes (group MY)
|
||||
v.MY_SUB_LIST = subs.filter((s, i) => !subOff(v, i, s.id)).map((s) => s.id + "-my").join(", ");
|
||||
v.MY_SUB_LIST = subs.filter((s, i) => !subOff(v, i, s.id)).map((s) => s.id + "-my")
|
||||
.concat(tags.has("my_links") ? ["my-links"] : []).join(", ");
|
||||
const seeds = bootSeeds(v);
|
||||
v.SEED_LIST = seeds.map((s) => s.name).join(", ");
|
||||
const hy2 = words(v.HY2);
|
||||
@ -558,14 +567,15 @@ const TEMPLATES = {
|
||||
"groups/41-openvpn.ovpn_exit.yaml": " # what the OpenVPN tunnel itself goes through on whitelist and foreign (ovpn_exit).\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-sub.yaml": " # own servers: hysteria2 from the settings (HY2) and the \"[MY] ...\" nodes of the\n # subscriptions (providers <id>-my); the fastest alive one; pin one in the dashboard if needed\n - name: MY\n type: url-test\n proxies: [${HY2_LIST}] #@hy2\n use: [${MY_SUB_LIST}]\n url: \"https://www.gstatic.com/generate_204\"\n interval: 300 #@!lite\n interval: 600 #@lite\n tolerance: 50\n lazy: false #@!lite\n lazy: true #@lite\n\n # whitelist and mobile (my_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 #@my_exit\n type: url-test #@my_exit\n use: [${SUB_LIST}] #@my_exit\n exclude-filter: \"(?i)🇷🇺|\\\\bru\\\\b|russia|росси|моск\" #@my_exit\n url: \"https://www.gstatic.com/generate_204\" #@my_exit\n interval: 300 #@my_exit\n tolerance: 300 #@my_exit\n lazy: false #@my_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/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] #@own\n use: [${SUB_LIST}]\n exclude-type: \"vless|vmess|trojan\"\n",
|
||||
"groups/60-csqtt.yaml": " # UPLINK: what the subscription nodes, BOOT seeds and own servers connect\n # through. DIRECT - as before; CSQTT - through csqtt0 first (out of the\n # whitelist), then FOREIGN / MY / RU work on top of it as usual.\n # On whitelist own servers go MY-EXIT -> node -> UPLINK.\n - name: UPLINK\n type: select\n proxies: [DIRECT, CSQTT]\n",
|
||||
"groups/90-base.yaml": " - name: MAIN\n type: select\n proxies: [FOREIGN, MY, RU, DIRECT${CSQTT_MAIN}] #@!foreign\n # abroad: direct by default, own servers / pools by hand #@foreign\n proxies: [DIRECT, MY, FOREIGN, RU${CSQTT_MAIN}] #@foreign\n",
|
||||
"groups/91-torrent.yaml": " - name: TORRENT-SEL\n type: select\n proxies: [TORRENT, FOREIGN, DIRECT]\n",
|
||||
"groups/92-push.yaml": " - name: PUSH\n type: select\n proxies: [DIRECT, MY, FOREIGN] #@!whitelist\n proxies: [MY, FOREIGN, DIRECT] #@whitelist,hy2\n # no hysteria2: MY may be empty (no [MY] nodes in the subscriptions) #@whitelist,!hy2\n proxies: [FOREIGN, MY, DIRECT] #@whitelist,!hy2\n",
|
||||
"groups/92-push.yaml": " - name: PUSH\n type: select\n proxies: [DIRECT, MY, FOREIGN] #@!whitelist\n proxies: [MY, FOREIGN, DIRECT] #@whitelist,own\n # no own servers in the settings: MY may be empty (no [MY] nodes in the subscriptions) #@whitelist,!own\n proxies: [FOREIGN, MY, DIRECT] #@whitelist,!own\n",
|
||||
"head/10-lite.yaml": "# LITE=1 (weak routers). nikki's mixin overrides keys whose uci options are set\n# (mihomo-kit.sh puts log_level / match_process there); these cover the rest\nlog-level: warning\nfind-process-mode: off #@!csqtt\ntcp-concurrent: false\nunified-delay: false\ngeo-auto-update: 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|приложение не|свяжитесь|\\\\[MY\\\\]\"\n override: #@csqtt\n dialer-proxy: UPLINK #@csqtt\n header:\n User-Agent: [\"${SUB_UA}\"]\n ${@@SUB_HEADERS}\n # one check per provider: the groups over it (use:) only add their URLs to it,\n # so the interval and lazy here are what counts for RU/FOREIGN/TORRENT/MY-EXIT.\n # lite: every 10 min and skipped while no traffic used the provider\n health-check:\n enable: true\n url: \"https://www.gstatic.com/generate_204\"\n interval: 300 #@!lite\n interval: 600 #@lite\n timeout: 3000\n lazy: false #@!lite\n lazy: true #@lite\n",
|
||||
"providers/15-sub.each.yaml": " # own servers kept in the subscription, named \"[MY] ...\", for group MY (the main\n # provider leaves them out); a provider of its own because on whitelist and the\n # phone they go through MY-EXIT. Router: not a second download, reads the file the\n # main provider saves (mihomo watches it; ./providers exists before the start,\n # ovpn_routes_write). Phone: FlClash moves provider files to paths of its own,\n # so the subscription is fetched once more.\n ${SUB_NAME}-my:\n type: file #@router\n path: ./providers/${SUB_NAME}.yaml #@router\n type: http #@mobile\n url: \"${SUB_URL}\" #@mobile\n path: ./providers/${SUB_NAME}-my.yaml #@mobile\n interval: 3600 #@mobile\n proxy: ${@SUB_PROXY} #@mobile\n filter: \"(?i)\\\\[MY\\\\]\"\n override: #@my_exit\n dialer-proxy: MY-EXIT #@my_exit\n override: #@csqtt,!my_exit\n dialer-proxy: UPLINK #@csqtt,!my_exit\n header: #@mobile\n User-Agent: [\"${SUB_UA}\"] #@mobile\n ${@@SUB_HEADERS} #@mobile\n health-check:\n enable: true\n url: \"https://www.gstatic.com/generate_204\"\n interval: 300 #@!lite\n interval: 600 #@lite\n timeout: 3000\n lazy: false #@!lite\n lazy: true #@lite\n",
|
||||
"providers/17-my_links.yaml": " # own servers as links (MY_LINKS, LuCI \"Свои серверы (ссылки)\"): kit writes them to\n # this file on build, mihomo parses vless/vmess/trojan/ss/hysteria2/tuic/anytls links\n # like a subscription; group MY, named \"[MY] ...\" like the [MY] nodes of the subscriptions\n my-links:\n type: file\n path: ./providers/my-links.txt\n override:\n additional-prefix: \"[MY] \"\n dialer-proxy: MY-EXIT #@my_exit\n dialer-proxy: UPLINK #@csqtt,!my_exit\n health-check:\n enable: true\n url: \"https://www.gstatic.com/generate_204\"\n interval: 300 #@!lite\n interval: 600 #@lite\n timeout: 3000\n lazy: false #@!lite\n lazy: true #@lite\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: #@ovpn_exit\n dialer-proxy: OVPN-EXIT #@ovpn_exit\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 dialer-proxy: UPLINK #@csqtt\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 # whitelist: control and DERP over TCP through own servers (MY -> own node -> MY-EXIT); #@whitelist,!ts_exit\n # MY holds hysteria2 from the settings and \"[MY]\" nodes of the subscriptions; empty MY is direct #@whitelist,!ts_exit\n # needs the kit's core (v1.19.32-ts1, tools/core/*.patch, MetaCubeX/mihomo#3142) #@whitelist,!ts_exit\n dialer-proxy: MY #@whitelist,!ts_exit\n",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user