# -*- coding: utf-8 -*- import json import sys import time from pathlib import Path import httpx import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") ROOT = Path(__file__).resolve().parents[1] HUB = ROOT / "backend" / "app" / "shellcrash_hub.py" VPS, PORT, USER, PW = "107.173.30.245", 4014, "eric", "4669805" def main(): c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect(VPS, PORT, USER, PW, timeout=40, banner_timeout=80, allow_agent=False, look_for_keys=False) sftp = c.open_sftp() sftp.put(str(HUB), "/tmp/_up_shellcrash_hub.py") sftp.close() _, o, e = c.exec_command( f"echo '{PW}' | sudo -S -p '' bash -c '" "install -m 644 /tmp/_up_shellcrash_hub.py /opt/douyinWEB/backend/app/shellcrash_hub.py; " "cd /opt/douyinWEB/backend && .venv/bin/python -m py_compile app/shellcrash_hub.py && " "systemctl restart douyinweb-api'" ) print((o.read() + e.read()).decode("utf-8", "replace"), flush=True) for _ in range(12): time.sleep(2) _, o2, _ = c.exec_command("curl -sS -m 3 -o /dev/null -w '%{http_code}' http://127.0.0.1:8014/api/health") code = o2.read().decode().strip() print("health", code, flush=True) if code == "200": break c.close() with httpx.Client(base_url="https://dy.nomadro.com", timeout=30) as client: r = client.post("/api/auth/login", json={"username": "hackrobot", "password": "Xiao4669805@"}) print("login", r.status_code, flush=True) wp = client.post("/api/network/shellcrash/web_panel").json() print(json.dumps({k: wp.get(k) for k in ("url", "direct_url", "ok")}, ensure_ascii=False, indent=2), flush=True) # API still reachable for online panel v = client.get("/shellcrash-ui/version") print("controller", v.status_code, v.text[:80], flush=True) if __name__ == "__main__": main()