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>
103 lines
3.3 KiB
Python
103 lines
3.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Check neko-7: CDP, proxy 7890, tabs, studio URL — then soft-fix ONLY #7 Chrome if needed."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
import time
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
PASS = "4669805"
|
|
|
|
REMOTE = r'''#!/bin/bash
|
|
set -uo pipefail
|
|
NAME=douyinweb-neko-7
|
|
echo === 9222 ===
|
|
docker exec "$NAME" python3 - <<'PY'
|
|
import socket, json, urllib.request
|
|
s=socket.socket(); s.settimeout(2)
|
|
print("connect_ex", s.connect_ex(("127.0.0.1",9222))); s.close()
|
|
try:
|
|
tabs=json.loads(urllib.request.urlopen("http://127.0.0.1:9222/json/list",timeout=5).read().decode())
|
|
print("tabs", len(tabs))
|
|
for t in tabs:
|
|
print("-", (t.get("title") or "")[:60], "|", (t.get("url") or "")[:140])
|
|
except Exception as e:
|
|
print("CDP_ERR", type(e).__name__, e)
|
|
PY
|
|
|
|
echo === proxy 7890 from container ===
|
|
docker exec "$NAME" python3 - <<'PY'
|
|
import socket, urllib.request
|
|
s=socket.socket(); s.settimeout(2)
|
|
print("7890", s.connect_ex(("host.docker.internal",7890))); s.close()
|
|
try:
|
|
req=urllib.request.Request("https://www.youtube.com/", method="HEAD")
|
|
# direct
|
|
print("direct_yt", urllib.request.urlopen(req, timeout=8).status)
|
|
except Exception as e:
|
|
print("direct_yt_err", type(e).__name__, str(e)[:120])
|
|
try:
|
|
proxy=urllib.request.ProxyHandler({"http":"http://host.docker.internal:7890","https":"http://host.docker.internal:7890"})
|
|
opener=urllib.request.build_opener(proxy)
|
|
print("proxy_yt", opener.open("https://www.youtube.com/", timeout=10).status)
|
|
except Exception as e:
|
|
print("proxy_yt_err", type(e).__name__, str(e)[:160])
|
|
PY
|
|
|
|
echo === host 7890 ===
|
|
ss -lntp | grep -E ':7890|:7891|:1080' || netstat -lntp 2>/dev/null | grep -E '7890|7891' || true
|
|
curl -sS -m 5 -o /dev/null -w "clash_http:%{http_code}\n" -x http://127.0.0.1:7890 https://www.youtube.com/ || echo clash_fail
|
|
|
|
echo === chrome log tail ===
|
|
docker exec "$NAME" bash -lc 'tail -80 /var/log/neko/google-chrome.log 2>/dev/null || echo no_log'
|
|
|
|
echo === x windows ===
|
|
docker exec "$NAME" bash -lc 'DISPLAY=:99.0 xwininfo -root -tree 2>&1 | head -50' || true
|
|
|
|
echo === studio url from db ===
|
|
cd /opt/douyinWEB/backend
|
|
PYTHONPATH=/opt/douyinWEB/backend .venv/bin/python - <<'PY'
|
|
from app import yt_assign_db
|
|
for g in yt_assign_db.list_groups(include_urls=True):
|
|
if int(g.get("neko_instance_id") or 0)!=7: continue
|
|
print("name", g.get("name"))
|
|
print("neko_studio_url", g.get("neko_studio_url"))
|
|
print("channel", g.get("channel_pk"), g.get("youtube_channel_id"))
|
|
for u in (g.get("featured") or [])[:5]:
|
|
print("feat", (u.get("url") if isinstance(u, dict) else u))
|
|
PY
|
|
echo CHECK_OK
|
|
'''
|
|
|
|
|
|
def main() -> int:
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(
|
|
"107.173.30.245",
|
|
4014,
|
|
"eric",
|
|
PASS,
|
|
timeout=45,
|
|
banner_timeout=120,
|
|
allow_agent=False,
|
|
look_for_keys=False,
|
|
)
|
|
sftp = c.open_sftp()
|
|
with sftp.file("/tmp/_neko7_check.sh", "w") as f:
|
|
f.write(REMOTE)
|
|
sftp.close()
|
|
_, o, e = c.exec_command(
|
|
f"echo '{PASS}' | sudo -S -p '' bash /tmp/_neko7_check.sh",
|
|
timeout=90,
|
|
)
|
|
print((o.read() + e.read()).decode("utf-8", "replace"))
|
|
c.close()
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|