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

98 lines
4.0 KiB
Python

# -*- coding: utf-8 -*-
import sys, paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
REMOTE = r'''
set +e
TOKEN=$(curl -sS -X POST 'http://127.0.0.1:9000/api/v1/auth/login' \
-H 'Content-Type: application/json' \
-d '{"username":"hackrobot","password":"Xiao4669805@"}' | python3 -c "import sys,json; print(json.load(sys.stdin)['body']['token'])")
python3 <<PY
import json, urllib.request, time
token = """$TOKEN""".strip()
H = {"Authorization": f"Bearer {token}", "Content-Type": "application/json"}
def call(method, path, body=None, timeout=30):
data = None if body is None else json.dumps(body).encode()
req = urllib.request.Request(f"http://127.0.0.1:9000{path}", data=data, headers=H, method=method)
t0=time.time()
try:
with urllib.request.urlopen(req, timeout=timeout) as r:
raw=r.read().decode()
return r.status, json.loads(raw), time.time()-t0
except Exception as e:
return 0, {"err": str(e)}, time.time()-t0
# discover proxy status endpoints via common names
paths = [
("POST", "/api/v1/proxy/list", {"page":1,"page_size":50}),
("POST", "/api/v1/proxy/get", {}),
("POST", "/api/v1/proxy/stats", {}),
("POST", "/api/v1/proxy/status", {}),
("POST", "/api/v1/platform/proxystatus", {}),
("POST", "/api/v1/platform/proxiesstatus", {}),
("POST", "/api/v1/client/get", {"client_id":"hackrobot.c.pve-ubuntu"}),
("POST", "/api/v1/server/get", {"server_id":"hackrobot.s.vps"}),
]
for m,p,b in paths:
code,d,dt = call(m,p,b)
msg = d.get("msg") if isinstance(d,dict) else d
body = d.get("body") if isinstance(d,dict) else None
print(f"{m} {p} -> http={code} t={dt:.2f}s msg={msg} body_keys={list(body)[:12] if isinstance(body,dict) else type(body).__name__}")
if isinstance(d,dict) and d.get("code")==200:
s=json.dumps(d,ensure_ascii=False)[:1200]
print(" ", s)
# list proxies then try status with ids
code,d,dt = call("POST","/api/v1/proxy/list",{"page":1,"page_size":50})
print("\nproxy list", d.get("code"), d.get("msg"), f"t={dt:.2f}")
proxies=[]
if isinstance(d.get("body"), dict):
proxies = d["body"].get("proxies") or d["body"].get("list") or []
print("count", len(proxies))
for p in proxies:
if isinstance(p, dict):
print({k:p.get(k) for k in ["id","name","type","client_id","server_id","stopped","status","working_status","state"] if k in p or True})
# print compact
print(" ", {k:p.get(k) for k in list(p)[:15]})
# try clientsstatus with real ids from client list
code,cl,dt=call("POST","/api/v1/client/list",{"page":1,"page_size":50})
clients=(cl.get("body") or {}).get("clients") or []
ids=[]
for c in clients:
ids.append(c.get("id"))
ids.extend(c.get("client_ids") or [])
print("\nclient ids", ids)
for body in [
{"client_ids": ids},
{"clientIds": ids},
{"ids": ids},
{"ClientIds": ids},
]:
code,d,dt=call("POST","/api/v1/platform/clientsstatus", body)
print("clientsstatus", body.keys(), "->", d.get("code"), d.get("msg"), f"t={dt:.2f}", str(d.get("body"))[:400])
PY
echo
echo '=== recent logs mentioning proxy/status/vps ==='
docker logs --since 2h frp-panel 2>&1 | grep -iE 'error|warn|timeout|vps|proxy|status|rpc' | tail -50
echo
echo '=== reachability to hackrobot.s.vps 107.173.30.245 ==='
timeout 5 bash -c 'echo >/dev/tcp/107.173.30.245/7000' && echo '7000 open' || echo '7000 fail'
timeout 5 bash -c 'echo >/dev/tcp/107.173.30.245/9001' && echo '9001 open' || echo '9001 fail'
timeout 5 bash -c 'echo >/dev/tcp/107.173.30.245/22' && echo '22 open' || echo '22 fail'
curl -sS -o /dev/null -w 'http9000:%{http_code} t=%{time_total}\n' --max-time 8 http://107.173.30.245:9000/ || echo http9000 fail
'''
c=paramiko.SSHClient(); c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect('107.172.77.34',22,'root','Xiao4669805',timeout=45,allow_agent=False,look_for_keys=False)
_,o,e=c.exec_command(REMOTE,timeout=180)
print(o.read().decode('utf-8','replace'))
err=e.read().decode('utf-8','replace')
if err.strip(): print('STDERR', err[-1500:])
c.close()