#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Diagnose ops-neko/1 stuck loading (HTTP ok vs WebRTC).""" from __future__ import annotations import sys import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") VPS = ("107.173.30.245", 22, "root", "Xiao4669805") PHYS = ("107.173.30.245", 4014, "eric", "4669805") def ssh(spec): c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect(spec[0], spec[1], spec[2], spec[3], timeout=40, allow_agent=False, look_for_keys=False) return c def run(c, cmd, t=60): _i, o, e = c.exec_command(cmd, timeout=t) return (o.read() + e.read()).decode("utf-8", "replace") def main(): p = ssh(PHYS) print("=== PHYS ops-neko-1 ===", flush=True) print( run( p, "echo '4669805' | sudo -S -p '' bash -lc '" "docker ps -a --filter name=douyinweb-ops-neko-1 --format \"{{.Names}} {{.Status}} {{.Ports}}\"; " "echo ---env---; " "docker inspect douyinweb-ops-neko-1 --format \"{{range .Config.Env}}{{println .}}{{end}}\" 2>/dev/null | " " grep -E \"NEKO_WEBRTC|NEKO_BROWSER|NEKO_START|NEKO_SERVER|NEKO_INSTANCE|NEKO_LIVE|NEKO_TAMPER|NEKO_MANAGED|NEKO_DESKTOP|NEKO_MAX|NEKO_VIDEO\" | head -40; " "echo ---listen---; " "ss -lntup | grep -E \"18200|62300|6250\" | head -20; " "echo ---wg---; " "ip -br a show wg-dy wg-dy-cn 2>/dev/null; " "wg show wg-dy-cn latest-handshakes 2>/dev/null; " "wg show wg-dy latest-handshakes 2>/dev/null; " "echo ---http local---; " "curl -sS -m 5 -o /dev/null -w \"local18200=%{http_code}\\n\" http://127.0.0.1:18200/; " "curl -sS -m 5 -o /dev/null -w \"localws=%{http_code}\\n\" -H \"Upgrade: websocket\" -H \"Connection: Upgrade\" http://127.0.0.1:18200/ws || true; " "echo ---api nat---; " "grep -E \"DY_NEKO_NAT|DY_NEKO_CN|DY_PUBLIC|DY_NEKO_HTTP\" /etc/systemd/system/douyinweb-api.service 2>/dev/null | head -20; " "'", 90, ), flush=True, ) p.close() v = ssh(VPS) print("=== VPS edge ===", flush=True) print( run( v, r""" echo ---public http--- curl -sS -m 12 -o /dev/null -w 'ops1=%{http_code} t=%{time_total}\n' https://dy.nomadro.com/ops-neko/1/ curl -sS -m 12 -o /tmp/ops1.html -w 'ops1_body=%{http_code} size=%{size_download}\n' https://dy.nomadro.com/ops-neko/1/ head -c 300 /tmp/ops1.html; echo grep -oE 'n\.eko|neko|websocket|WebRTC' /tmp/ops1.html | head -10 echo ---frp aux--- systemctl is-active dy-frp-http-aux ss -lntp | grep -E '18200|62300|28333' | head -20 echo ---caddy ops-neko--- grep -n 'ops-neko\|62300\|18200' /etc/caddy/sites/dy.nomadro.com.caddy | head -40 echo ---mux from vps to guest via frp?--- # TCP mux probe via frp if forwarded timeout 3 bash -c 'echo >/dev/tcp/127.0.0.1/62300' && echo tcp62300_local_open || echo tcp62300_local_closed # via wg timeout 3 bash -c 'echo >/dev/tcp/10.8.0.2/62300' && echo tcp62300_wg_open || echo tcp62300_wg_closed timeout 3 bash -c 'echo >/dev/tcp/10.8.0.2/18200' && echo http18200_wg_open || echo http18200_wg_closed echo ---public nat1to1 guess--- # what IP does assign neko use curl -sS -m 8 https://dy.nomadro.com/api/health | head -c 200; echo """, 90, ), flush=True, ) # Tencent edge if reachable try: t = paramiko.SSHClient() t.set_missing_host_key_policy(paramiko.AutoAddPolicy()) t.connect("82.157.112.245", 22, "ubuntu", "Xiao4669805", timeout=25, allow_agent=False, look_for_keys=False) print("=== TENCENT ===", flush=True) print( run( t, r""" echo ---cn ops-neko--- curl -sS -m 12 -o /dev/null -w 'cn_ops1=%{http_code}\n' https://dy.nomadro.cn/ops-neko/1/ || true curl -sS -m 12 -o /dev/null -w 'cn_neko1=%{http_code}\n' https://dy.nomadro.cn/neko/1/ || true echo ---dnat mux--- sudo iptables -t nat -S | grep -E '62300|52300|9200|18200' | head -30 ss -lntup | grep -E '62300|52300' | head -15 ip -br a show wg-dy-cn 2>/dev/null ping -c1 -W2 10.9.0.2 >/dev/null && echo ping_guest_ok || echo ping_guest_fail """, 60, ), flush=True, ) t.close() except Exception as exc: print("TENCENT ssh fail", exc, flush=True) v.close() if __name__ == "__main__": main()