Fixed ovpn rule managment

This commit is contained in:
Sam Latsin 2026-10-09 17:13:30 +03:00
parent 7dd7dc57ad
commit fdeccbe434
3 changed files with 13 additions and 5 deletions

View File

@ -48,7 +48,8 @@ bmstu-otp.sh status
``` ```
На сервере BMSTU одна сессия на пользователя. `off` закрывает туннель в mihomo и не даёт На сервере BMSTU одна сессия на пользователя. `off` закрывает туннель в mihomo и не даёт
cron поднять его снова; трафик в сети BMSTU сразу получает отказ. mihomo не отправляет cron поднять его снова; трафик в сети BMSTU идёт без туннеля (дома напрямую, на улице через
`OVPN-EXIT`) — публичные ресурсы открываются, внутренние (`172.x`) нет. mihomo не отправляет
серверу EXIT, поэтому сервер держит старую сессию до своего `ping-restart` — до ~5 минут, серверу EXIT, поэтому сервер держит старую сессию до своего `ping-restart` — до ~5 минут,
потом можно подключаться с другого устройства. потом можно подключаться с другого устройства.

View File

@ -13,7 +13,7 @@
# bmstu-otp.sh authfile print username/password lines (openvpn auth-user-pass file) # bmstu-otp.sh authfile print username/password lines (openvpn auth-user-pass file)
# bmstu-otp.sh refresh regenerate provider with fresh OTP, reload, warm up # bmstu-otp.sh refresh regenerate provider with fresh OTP, reload, warm up
# bmstu-otp.sh check warm-up test; refresh only if the tunnel is dead (cron) # bmstu-otp.sh check warm-up test; refresh only if the tunnel is dead (cron)
# bmstu-otp.sh off close the tunnel and keep it closed (BMSTU traffic is rejected); # bmstu-otp.sh off close the tunnel and keep it closed (BMSTU traffic goes without it);
# frees the single server session for another client # frees the single server session for another client
# (the server drops the old session after its ping-restart, up to ~5 min) # (the server drops the old session after its ping-restart, up to ~5 min)
# bmstu-otp.sh on allow the tunnel again and bring it up # bmstu-otp.sh on allow the tunnel again and bring it up
@ -213,11 +213,12 @@ alive() {
--data-urlencode "url=$CHECK_URL" --data-urlencode "timeout=$CHECK_TIMEOUT" >/dev/null 2>&1 --data-urlencode "url=$CHECK_URL" --data-urlencode "timeout=$CHECK_TIMEOUT" >/dev/null 2>&1
} }
# provider with a single reject proxy: the old tunnel gets closed with the # provider with a single direct proxy: the old tunnel gets closed with the
# outdated proxy, and BMSTU traffic fails fast instead of hanging # outdated proxy, and BMSTU traffic goes without it (public resources still
# open; on street the provider's dialer-proxy sends it through OVPN-EXIT)
write_off_provider() { write_off_provider() {
mkdir -p "$(dirname "$PROVIDER_FILE")" mkdir -p "$(dirname "$PROVIDER_FILE")"
printf '# bmstu-otp.sh off\nproxies:\n - name: %s-off\n type: reject\n' "$PROVIDER_NAME" > "$PROVIDER_FILE" printf '# bmstu-otp.sh off\nproxies:\n - name: %s-off\n type: direct\n' "$PROVIDER_NAME" > "$PROVIDER_FILE"
} }
refresh() { refresh() {

View File

@ -678,6 +678,11 @@ cmd_update() {
[ -d "$src/$d" ] && cp -r "$src/$d" "$KIT_DIR/$d" [ -d "$src/$d" ] && cp -r "$src/$d" "$KIT_DIR/$d"
done done
rm -rf "$tmp" rm -rf "$tmp"
# the rest runs from the new script: this one is the old version
exec sh "$KIT_DIR/router/mihomo-kit.sh" post-update
}
cmd_post_update() {
install_files install_files
cmd_build cmd_build
cur=$(uci -q get nikki.config.profile) cur=$(uci -q get nikki.config.profile)
@ -690,6 +695,7 @@ case "${1:-}" in
use) shift; cmd_use "$@" ;; use) shift; cmd_use "$@" ;;
setup) cmd_setup ;; setup) cmd_setup ;;
update) cmd_update ;; update) cmd_update ;;
post-update) cmd_post_update ;;
install) cmd_install ;; install) cmd_install ;;
fix) cmd_fix ;; fix) cmd_fix ;;
ts-login) shift; cmd_ts_login "$@" ;; ts-login) shift; cmd_ts_login "$@" ;;