From ed2ae0a513a00133a552d4018a58207e0214e825 Mon Sep 17 00:00:00 2001 From: andrey271192 <76248502+andrey271192@users.noreply.github.com> Date: Fri, 13 Nov 2026 23:13:07 +0300 Subject: [PATCH] router install: second IP in init/package/failover, download timeouts Co-Authored-By: Claude Opus 5.5 --- app.py | 4 ++-- overlay/phobos-client.sh | 36 ++++++++++++++++++++++++++++-------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/app.py b/app.py index a078ef7..bb000c0 100644 --- a/app.py +++ b/app.py @@ -4473,7 +4473,7 @@ def install_command(token, port=None): return ("p=/tmp/phobos-init-$$.sh; ok=0; " f"for u in {' '.join(urls)}; do " "rm -f $p; " - "(wget -q -O $p $u || wget --no-check-certificate -q -O $p $u || curl -kfsSL -o $p $u || curl -fsSL -o $p $u) 2>/dev/null || continue; " + "(wget -T 10 -q -O $p $u || wget -T 10 --no-check-certificate -q -O $p $u || curl -m 20 -kfsSL -o $p $u || curl -m 20 -fsSL -o $p $u) 2>/dev/null || continue; " "head -c 2 $p | grep -q \"#!\" || continue; " "sh $p && ok=1 && break; " "done; rm -f $p; [ $ok -eq 1 ] || echo ERROR_install_script_download_failed") @@ -4483,7 +4483,7 @@ def short_install_command(token, port=None): port = port or panel_port() alts = alt_endpoints(SERVER_IP) host = alts[0] if alts else client_endpoint(SERVER_IP) # prefer the IP that is reachable from RU - return f"wget -qO /tmp/p.sh {"http" if alts else panel_scheme()}://{host}:{port}/init/{token}.sh && sh /tmp/p.sh" + return f"wget -T 15 -qO /tmp/p.sh {"http" if alts else panel_scheme()}://{host}:{port}/init/{token}.sh && sh /tmp/p.sh" @app.route("/init/") diff --git a/overlay/phobos-client.sh b/overlay/phobos-client.sh index ce1b402..5f81a40 100755 --- a/overlay/phobos-client.sh +++ b/overlay/phobos-client.sh @@ -306,11 +306,26 @@ PY printf 'http://%s:8444 %s://%s:%s %s://%s:%s\n' \ "$panel_tunnel_ip" "$panel_scheme" "$panel_tunnel_ip" "$panel_port" \ "$panel_scheme" "$SERVER_PUBLIC_IP_V4" "$panel_port" > "$pkg_root/panel_urls" - cat > "$pkg_root/failover.conf" </dev/null || true) + if [[ -n "$pkg_alts" ]]; then + local _u; _u=$(cat "$pkg_root/panel_urls") + for _a in $pkg_alts; do _u="$_u http://${_a}:${panel_port}"; done + echo "$_u" > "$pkg_root/panel_urls" + fi + { + echo "# Phobos Failover Configuration" + echo "SERVER_1=${CLIENT_ENDPOINT:-$SERVER_PUBLIC_IP_V4}:${OBFUSCATOR_PORTS:-51821,51822,51823}" + echo "KEY_1=${OBFUSCATOR_KEY:-}" + _n=1 + for _a in $pkg_alts; do + _n=$((_n+1)) + echo "SERVER_${_n}=${_a}:${OBFUSCATOR_PORTS:-51821,51822,51823}" + echo "KEY_${_n}=${OBFUSCATOR_KEY:-}" + done + } > "$pkg_root/failover.conf" find "$pkg_root" -type f ! -path "*/bin/*" -exec sed -i 's/\r$//' {} \; @@ -396,10 +411,15 @@ action_link() { case "$panel_scheme" in http|https) ;; *) panel_scheme="http";; esac local primary_url="${panel_scheme}://${SERVER_PUBLIC_IP_V4}:${panel_port}/packages/$token/phobos-$id.tar.gz" local fallback_url="http://${SERVER_PUBLIC_IP_V4}:80/packages/$token/phobos-$id.tar.gz" + # second IPs of this server (settings.json alt_endpoints): reachable where the main IP is blocked + local alt_urls="" alt + for alt in $(python3 -c "import json,sys;print(' '.join(json.load(open('/opt/phobos-panel/settings.json')).get('alt_endpoints',{}).get(sys.argv[1],[])))" "$SERVER_PUBLIC_IP_V4" 2>/dev/null); do + alt_urls="$alt_urls http://${alt}:${panel_port}/packages/$token/phobos-$id.tar.gz http://${alt}:80/packages/$token/phobos-$id.tar.gz" + done cat > "$WWW_DIR/init/$token.sh" </dev/null; then - curl -k -L -s -o "\$dir/package.tar.gz" "\$url" 2>/dev/null || continue + curl -k -L -s --connect-timeout 10 -m 300 -o "\$dir/package.tar.gz" "\$url" 2>/dev/null || continue else - wget --no-check-certificate -q -O "\$dir/package.tar.gz" "\$url" 2>/dev/null || wget -q -O "\$dir/package.tar.gz" "\$url" 2>/dev/null || continue + wget -T 15 --no-check-certificate -q -O "\$dir/package.tar.gz" "\$url" 2>/dev/null || wget -T 15 -q -O "\$dir/package.tar.gz" "\$url" 2>/dev/null || continue fi if grep -qi '/dev/null; then echo "Bad response from \$url (HTML/proxy page), trying next..."