douyinWEB/scripts/_probe_wg_frp.py
eric d409e416da Ship physical dual-edge stack, Studio CDP live metrics, and ops tooling.
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>
2026-09-04 22:42:40 -05:00

71 lines
2.1 KiB
Python

# -*- coding: utf-8 -*-
from __future__ import annotations
import socket
import sys
import time
import httpx
import paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
VPS = "107.173.30.245"
def main() -> int:
for port in (22, 4014, 80, 443, 51820):
s = socket.socket()
s.settimeout(5)
try:
r = s.connect_ex((VPS, port))
print(f"port {port}: {'open' if r == 0 else 'fail/' + str(r)}", flush=True)
except Exception as e:
print(f"port {port}: {type(e).__name__} {e}", flush=True)
finally:
s.close()
with httpx.Client(timeout=15, follow_redirects=False) as c:
for u in (
"https://dy.nomadro.com/api/health",
"https://dylive.nomadro.com/api/health",
"https://dy.nomadro.com/network",
):
try:
r = c.get(u)
print(u, r.status_code, flush=True)
except Exception as e:
print(u, type(e).__name__, e, flush=True)
last = None
for i in range(6):
try:
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect(
VPS,
4014,
"eric",
"4669805",
timeout=30,
banner_timeout=60,
allow_agent=False,
look_for_keys=False,
)
_, o, e = c.exec_command(
"hostname; "
"systemctl is-active wg-quick@wg-dy douyinweb-wireguard-watch douyinweb-api douyinweb-web frpp 2>/dev/null; "
"ip -br a show wg-dy; wg show wg-dy | head -8"
)
print((o.read() + e.read()).decode("utf-8", "replace"), flush=True)
c.close()
return 0
except Exception as ex:
last = ex
print(f"frp fail{i} {type(ex).__name__}", flush=True)
time.sleep(3)
raise last # type: ignore[misc]
if __name__ == "__main__":
raise SystemExit(main())