douyinWEB/scripts/_diag_10_88_8001.py
2026-09-13 22:10:49 -05:00

91 lines
2.3 KiB
Python

#!/usr/bin/env python3
"""Read-only: why http://10.88.0.8:8001 unreachable (WG related)."""
from __future__ import annotations
import socket
import sys
import time
import paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
HOSTS = [
("dylive", "107.173.30.245", 22, "root", "Xiao4669805"),
("dy", "108.174.50.68", 22, "root", "Xiao4669805"),
]
def ssh(label, host, port, user, pw):
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
for i in range(6):
try:
c.connect(
host,
port,
user,
pw,
timeout=40,
allow_agent=False,
look_for_keys=False,
banner_timeout=120,
)
return c
except Exception as e:
print(f"{label} ssh_retry {i}: {e}", flush=True)
time.sleep(2)
return None
def run(c, cmd, t=90):
_i, o, e = c.exec_command(cmd, timeout=t)
return (o.read() + e.read()).decode("utf-8", "replace")
# local reachability from this Windows machine
print("=== local TCP 10.88.0.8:8001 ===", flush=True)
s = socket.socket()
s.settimeout(5)
try:
s.connect(("10.88.0.8", 8001))
print("local_tcp: OK")
except Exception as e:
print(f"local_tcp: FAIL {e}")
finally:
s.close()
for label, host, port, user, pw in HOSTS:
print(f"\n======== {label} {host} ========", flush=True)
c = ssh(label, host, port, user, pw)
if not c:
print("ssh fail")
continue
print(
run(
c,
r"""
set +e
echo '--- wg interfaces ---'
wg show 2>/dev/null | head -80
echo
ip -br a 2>/dev/null | grep -E 'wg|10\.88|10\.8|82\.157' || true
echo '--- routes 10.88 ---'
ip route get 10.88.0.8 2>&1 || true
ip route | grep -E '10\.88|wg' || true
echo '--- ping/curl ---'
ping -c 2 -W 2 10.88.0.8 2>&1 | tail -5
curl -sS -m 5 -o /dev/null -w 'curl_http=%{http_code} time=%{time_total}\n' http://10.88.0.8:8001/ || echo curl_fail
ss -lntp 2>/dev/null | grep -E ':8001\b|10\.88' || true
echo '--- systemd wg ---'
systemctl is-active 'wg-quick@wg-dy' 'wg-quick@wg-dy-cn' 2>/dev/null
echo '--- who is 10.88.0.8 locally? ---'
ip -br a | grep 10.88 || echo 'no 10.88 on this host'
""",
),
flush=True,
)
c.close()
print("DONE")