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>
92 lines
3.8 KiB
Python
92 lines
3.8 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Diagnose YouTube page hang inside Neko Chrome (proxy/egress), not Neko UI."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
time_mod = __import__("time")
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
PASS = "4669805"
|
|
|
|
REMOTE = r'''
|
|
import json, subprocess, time
|
|
|
|
def sh(cmd, timeout=40):
|
|
r=subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=timeout)
|
|
return (r.stdout or "") + (r.stderr or "")
|
|
|
|
print("=== shellcrash / 7890 ===")
|
|
print(sh("ss -lntp | grep -E ':7890|:9999' | head -5 || true"))
|
|
print(sh("curl -sS -o /dev/null -w 'direct_yt=%{http_code} time=%{time_total}\\n' --max-time 12 https://www.youtube.com/ || true"))
|
|
print(sh("curl -sS -o /dev/null -w 'proxy_yt=%{http_code} time=%{time_total}\\n' --max-time 15 -x http://127.0.0.1:7890 https://www.youtube.com/ || true"))
|
|
print(sh("curl -sS -o /dev/null -w 'proxy_google=%{http_code}\\n' --max-time 15 -x http://127.0.0.1:7890 https://www.google.com/ || true"))
|
|
|
|
for i in (1,4,5,6):
|
|
name=f"neko-{i}"
|
|
print(f"\n======== {name} ========")
|
|
insp=sh(f"docker inspect {name} --format '{{{{json .State.Running}}}}|{{{{json .Config.Env}}}}'")
|
|
if "Error" in insp or not insp.strip():
|
|
print("missing", insp[:200]); continue
|
|
# env keys of interest
|
|
env_line=insp.strip()
|
|
for key in ("NEKO_BROWSER_PROXY","NEKO_WEBRTC_NAT1TO1","NEKO_SERVER_PROXY","HTTP_PROXY","HTTPS_PROXY","NEKO_START_URL"):
|
|
if key+"=" in env_line:
|
|
# rough extract
|
|
idx=env_line.find(key+"=")
|
|
frag=env_line[idx:idx+120].split('"')[0]
|
|
print(frag)
|
|
print("running", "true" in env_line.split("|",1)[0].lower())
|
|
# chrome supervisor
|
|
print("--- chrome ---")
|
|
print(sh(f"docker exec {name} supervisorctl status google-chrome 2>/dev/null || docker exec {name} ps aux | grep -E 'chrome|chromium' | head -5"))
|
|
# proxy reachability from container
|
|
print("--- curl via browser proxy from container ---")
|
|
print(sh(f"docker exec {name} bash -lc 'curl -sS -o /dev/null -w \"yt=%{{http_code}} t=%{{time_total}}\\\\n\" --max-time 18 -x http://host.docker.internal:7890 https://www.youtube.com/ || echo CURL_FAIL'"))
|
|
print(sh(f"docker exec {name} bash -lc 'getent hosts host.docker.internal; getent hosts www.youtube.com | head -2; curl -sS -o /dev/null -w \"direct_yt=%{{http_code}}\\\\n\" --max-time 10 https://www.youtube.com/ || echo direct_fail'"))
|
|
# recent chrome / neko logs mentioning proxy youtube
|
|
print("--- logs ---")
|
|
print(sh(f"docker logs --tail 30 {name} 2>&1 | tail -20"))
|
|
|
|
print("\n=== clash youtube rule sample ===")
|
|
print(sh("grep -n -iE 'youtube|google|PROXY|DIRECT' /opt/ShellCrash/config.yaml 2>/dev/null | head -40 || grep -n -iE 'youtube|google' /etc/ShellCrash/*.yaml 2>/dev/null | head -40 || ls /opt/ShellCrash 2>/dev/null; ls ~/.config/clash 2>/dev/null"))
|
|
'''
|
|
|
|
|
|
def main():
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
for i in range(10):
|
|
try:
|
|
c.connect(
|
|
"107.173.30.245",
|
|
4014,
|
|
"eric",
|
|
PASS,
|
|
timeout=60,
|
|
banner_timeout=120,
|
|
allow_agent=False,
|
|
look_for_keys=False,
|
|
)
|
|
break
|
|
except Exception as ex:
|
|
print("ssh", i, type(ex).__name__, flush=True)
|
|
time_mod.sleep(2 + i)
|
|
else:
|
|
raise SystemExit("ssh failed")
|
|
|
|
sftp = c.open_sftp()
|
|
with sftp.file("/tmp/_neko_yt_hang.py", "w") as f:
|
|
f.write(REMOTE)
|
|
sftp.close()
|
|
_, o, e = c.exec_command(
|
|
f"echo '{PASS}' | sudo -S -p '' python3 /tmp/_neko_yt_hang.py",
|
|
timeout=240,
|
|
)
|
|
print((o.read() + e.read()).decode("utf-8", "replace"), flush=True)
|
|
c.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|