douyinWEB/scripts/_diag_neko_webrtc.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

72 lines
2.8 KiB
Python

# -*- coding: utf-8 -*-
import sys, paramiko, socket
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
PVE = ("107.173.30.245", 4014, "eric", "4669805")
VPS = ("107.173.30.245", 22, "root", "Xiao4669805")
CN = "douyinweb-neko-1"
def ssh(host, port, user, pwd, cmd, sudo=False):
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect(host, port, user, pwd, timeout=25, allow_agent=False, look_for_keys=False)
full = f"echo '{pwd}' | sudo -S -p '' bash -c {repr(cmd)}" if sudo and user != "root" else cmd
_, o, e = c.exec_command(full, timeout=45)
out = o.read().decode("utf-8", "replace")
err = e.read().decode("utf-8", "replace")
c.close()
return out, err
def chk(host, port, udp=False):
try:
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM if udp else socket.SOCK_STREAM)
s.settimeout(3)
if udp:
s.sendto(b"\x00", (host, port))
return "udp_open?"
r = s.connect_ex((host, port))
s.close()
return "open" if r == 0 else f"closed({r})"
except Exception as ex:
return str(ex)
print("=== Container supervisor + chrome ===")
out, _ = ssh(*PVE, f"docker exec {CN} supervisorctl status 2>&1", sudo=True)
print(out)
out, _ = ssh(*PVE, f"docker exec {CN} ls -la /etc/neko/browser-launch.sh 2>&1", sudo=True)
print(out)
out, _ = ssh(*PVE, f"docker logs {CN} --tail 40 2>&1", sudo=True)
print(out)
print("\n=== Neko API websocket path ===")
out, _ = ssh(*PVE, "curl -s http://127.0.0.1:9200/api/status 2>&1 | head -c 2000", sudo=True)
print(out)
print("\n=== WebRTC ports on PVE (physical) ===")
out, _ = ssh(*PVE, "ss -ulnp | grep -E '52300|52000' | head -5; ss -tlnp | grep 52300", sudo=True)
print(out)
print("\n=== WebRTC ports on VPS public IP ===")
for p in [52300, 9200, 52000]:
print(f" 107.173.30.245:{p} tcp -> {chk('107.173.30.245', p)}")
print(f" 107.173.30.245:{p} udp -> {chk('107.173.30.245', p, udp=True)}")
print("\n=== VPS port listeners for neko webrtc ===")
out, _ = ssh(*VPS, "ss -tlnp | grep -E '52300|5200' ; ss -ulnp | grep -E '52300|5200' | head -10")
print(out or "(none on VPS)")
print("\n=== iptables/nft on VPS forwarding webrtc? ===")
out, _ = ssh(*VPS, "iptables -t nat -L -n 2>/dev/null | grep -E '52300|5200' | head -10; nft list ruleset 2>/dev/null | grep -E '52300|5200' | head -10")
print(out or "(no forwarding rules found)")
print("\n=== Physical public IP / NAT ===")
out, _ = ssh(*PVE, "curl -s --max-time 5 ifconfig.me 2>/dev/null; echo; ip route get 1.1.1.1 | head -1", sudo=True)
print(out)
print("\n=== ShellCrash proxy (browser needs 7890) ===")
out, _ = ssh(*PVE, "curl -s -o /dev/null -w 'proxy7890:%{http_code}' --max-time 3 http://127.0.0.1:7890 2>&1; echo; ss -tlnp | grep 7890", sudo=True)
print(out)