Capture Neko/WG/network hubs, Studio viewer charts, physical deploy docs, and one-shot scripts so VPS vs physical can be toggled later without losing WIP. Co-authored-by: Cursor <cursoragent@cursor.com>
85 lines
2.7 KiB
Python
85 lines
2.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Probe WG-primary vs FRP-aux roles on VPS + physical guest."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
import time
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
|
|
def ssh(port, user, pw):
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
for i in range(5):
|
|
try:
|
|
c.connect("107.173.30.245", port, user, pw, timeout=40, banner_timeout=60, allow_agent=False, look_for_keys=False)
|
|
return c
|
|
except Exception as ex:
|
|
print("ssh", port, i, type(ex).__name__, flush=True)
|
|
time.sleep(2)
|
|
raise RuntimeError("ssh")
|
|
|
|
|
|
def run(c, cmd, timeout=60):
|
|
_, o, e = c.exec_command(cmd, timeout=timeout)
|
|
return (o.read() + e.read()).decode("utf-8", "replace")
|
|
|
|
|
|
v = ssh(22, "root", "Xiao4669805")
|
|
print("=== VPS WG server ===", flush=True)
|
|
print(
|
|
run(
|
|
v,
|
|
"ip -br a show wg-dy; wg show wg-dy; "
|
|
"systemctl is-active wg-quick@wg-dy; "
|
|
"ss -ulnp | grep 51820 || true; "
|
|
"echo --- frp ---; "
|
|
"systemctl is-active frps frpp frpc 2>/dev/null; "
|
|
"ss -lntp | grep -E ':(4014|7000|7500)\\b' || true; "
|
|
"ls /etc/frp /etc/frps /opt/frp 2>/dev/null | head; "
|
|
"grep -nE 'bind|4014|dashboard' /etc/frp/*.toml /etc/frps/*.ini /etc/frp-panel/* 2>/dev/null | head -30",
|
|
40,
|
|
),
|
|
flush=True,
|
|
)
|
|
print(
|
|
run(
|
|
v,
|
|
"curl -sS -m 5 -o /dev/null -w 'via_wg_api:%{http_code} time:%{time_total}\\n' http://10.8.0.2:8014/api/health; "
|
|
"curl -sS -m 8 -o /dev/null -w 'via_caddy:%{http_code}\\n' https://dy.nomadro.com/api/health; "
|
|
"curl -sS -m 8 -o /dev/null -w 'dylive:%{http_code}\\n' https://dylive.nomadro.com/api/health",
|
|
30,
|
|
),
|
|
flush=True,
|
|
)
|
|
v.close()
|
|
|
|
g = ssh(4014, "eric", "4669805")
|
|
print("=== GUEST (via FRP :4014) ===", flush=True)
|
|
print(
|
|
run(
|
|
g,
|
|
"echo '4669805' | sudo -S -p '' bash -lc '"
|
|
"ip -br a show wg-dy; wg show wg-dy | head -20; "
|
|
"systemctl is-active wg-quick@wg-dy; "
|
|
"ping -c 1 -W 2 10.8.0.1 | tail -2; "
|
|
"echo --- frp client ---; "
|
|
"systemctl list-units --type=service --all | grep -iE \"frp|frpc|frpp\" || true; "
|
|
"ps aux | grep -E \"[f]rpc|[f]rpp\" | head -5; "
|
|
"ls /etc/frp /home/eric/frp /opt/frp /etc/frp-panel 2>/dev/null; "
|
|
"find /etc /home/eric /opt -maxdepth 3 -iname \"*frp*\" 2>/dev/null | head -40; "
|
|
"echo --- route ---; "
|
|
"ip route | head -15; "
|
|
"ip route get 10.8.0.1; "
|
|
"ip route get 1.1.1.1 | head -1"
|
|
"'",
|
|
60,
|
|
),
|
|
flush=True,
|
|
)
|
|
g.close()
|
|
print("DONE", flush=True)
|