#!/usr/bin/env python3 """Restore wg-dy to :51820, then probe FRP HTTP path for dy.nomadro.com. Physical = 107.173.30.245:4014 eric/4669805. No Neko. Live flush. """ from __future__ import annotations import sys import time import httpx import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace", line_buffering=True) VPS = ("107.173.30.245", 22, "root", "Xiao4669805") GUEST = ("107.173.30.245", 4014, "eric", "4669805") def connect(spec): host, port, user, pw = spec for i in range(12): try: c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect( host, port, user, pw, timeout=25, banner_timeout=40, allow_agent=False, look_for_keys=False, ) print(f"connected {user}@{host}:{port}", flush=True) return c except Exception as ex: print(f"retry {port} {i}: {ex}", flush=True) time.sleep(2) raise RuntimeError(f"ssh fail :{port}") def run(c, cmd, t=90): print(f"$ {cmd[:220]}", flush=True) _i, o, e = c.exec_command(cmd, timeout=t) while not o.channel.exit_status_ready(): if o.channel.recv_ready(): sys.stdout.write(o.channel.recv(4096).decode("utf-8", "replace")) sys.stdout.flush() if o.channel.recv_stderr_ready(): sys.stdout.write(o.channel.recv_stderr(4096).decode("utf-8", "replace")) sys.stdout.flush() time.sleep(0.1) sys.stdout.write((o.read() + e.read()).decode("utf-8", "replace")) sys.stdout.flush() print("->", o.channel.recv_exit_status(), flush=True) print("## 1 restore VPS wg-dy ListenPort 51820", flush=True) v = connect(VPS) run( v, "cp -a /etc/wireguard/wg-dy.conf.bak.pre443 /etc/wireguard/wg-dy.conf 2>/dev/null || " "sed -i 's/^ListenPort = .*/ListenPort = 51820/' /etc/wireguard/wg-dy.conf; " "grep -E 'ListenPort|Address|AllowedIPs|PublicKey' /etc/wireguard/wg-dy.conf; " "wg-quick down wg-dy 2>/dev/null || true; " "wg-quick up wg-dy; " "wg show wg-dy; " "ss -ulnp | grep 51820 || true", ) v.close() print("## 2 restore guest Endpoint :51820", flush=True) g = connect(GUEST) run( g, "echo 4669805 | sudo -S -p '' bash -lc '" "cp -a /etc/wireguard/wg-dy.conf.bak.pre443 /etc/wireguard/wg-dy.conf 2>/dev/null || true; " "sed -i \"s/^Endpoint = .*/Endpoint = 107.173.30.245:51820/\" /etc/wireguard/wg-dy.conf; " "grep -E \"Endpoint|Address|Keepalive|AllowedIPs\" /etc/wireguard/wg-dy.conf; " "wg-quick down wg-dy 2>/dev/null || true; " "wg-quick up wg-dy; sleep 3; " "wg show wg-dy; " "systemctl is-active douyinweb-api douyinweb-web; " "curl -sS -m 6 http://127.0.0.1:8014/api/health | head -c 120; echo" "'", t=60, ) g.close() print("## 3 FRP inventory on VPS (ports that might reach guest HTTP)", flush=True) v = connect(VPS) run( v, "systemctl is-active frpp; " "ss -lntp | grep -E 'frp|4014|7000|8999|8014|4015|18014|14015|8080|8443' || true; " "ls /opt /etc | grep -i frp || true; " "find /opt /etc /root -maxdepth 3 -iname '*frp*' -type f 2>/dev/null | head -30; " "curl -sS -m 5 http://127.0.0.1:8014/api/health | head -c 80; echo; " "curl -sS -m 5 -o /dev/null -w dylive_local=%{http_code}\\\\n http://127.0.0.1:4015/", t=40, ) v.close() print("## 4 guest frpc status / local listen", flush=True) g = connect(GUEST) run( g, "echo 4669805 | sudo -S -p '' bash -lc '" "ss -lntp | grep -E \":(8014|4015)\\b\"; " "systemctl list-units --type=service --state=running | grep -iE \"frp|nps|gost\" || true; " "ps aux | grep -iE \"[f]rpc|[f]rps\" | head -10; " "ls /etc/frp /opt/frp /home/eric/frp 2>/dev/null; " "find /etc /opt /home/eric -maxdepth 3 -name \"frpc*.toml\" -o -name \"frpc*.ini\" 2>/dev/null | head -20" "'", t=40, ) g.close() print("## 5 tunnel + public", flush=True) time.sleep(2) v = connect(VPS) run( v, "wg show wg-dy | head -20; " "ping -c 3 -W 2 10.8.0.2 | tail -5; " "curl -sS -m 8 -o /dev/null -w via_wg=%{http_code}\\\\n http://10.8.0.2:8014/api/health", t=30, ) v.close() with httpx.Client(follow_redirects=False, timeout=15) as cl: for u in [ "https://dylive.nomadro.com/api/health", "https://dy.nomadro.com/api/health", "https://dy.nomadro.com/", "https://dy.nomadro.cn/api/health", ]: try: print(f"{u} -> {cl.get(u).status_code}", flush=True) except Exception as ex: print(f"{u} ERR {ex}", flush=True) print("DONE", flush=True)