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

62 lines
2.1 KiB
Python

# -*- coding: utf-8 -*-
from __future__ import annotations
import sys
import paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
GUEST_PW = "4669805"
def main() -> int:
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect(
"107.173.30.245",
4014,
"eric",
GUEST_PW,
timeout=40,
banner_timeout=80,
allow_agent=False,
look_for_keys=False,
)
script = r"""
echo '=== resolv ==='
cat /etc/resolv.conf
echo '=== nft shellcrash ==='
nft list tables 2>/dev/null || true
nft list table inet shellcrash 2>/dev/null | head -60 || echo no_shellcrash_table
echo '=== route ==='
ip route | head -10
echo '=== probes ==='
env -u http_proxy -u https_proxy -u HTTP_PROXY -u HTTPS_PROXY -u ALL_PROXY \
curl -sS -m 5 -o /dev/null -w 'baidu:%{http_code}\n' https://www.baidu.com || echo baidu:fail
env -u http_proxy -u https_proxy -u HTTP_PROXY -u HTTPS_PROXY -u ALL_PROXY \
curl -sS -m 5 -o /dev/null -w 'cf:%{http_code}\n' https://1.1.1.1 || echo cf:fail
env -u http_proxy -u https_proxy -u HTTP_PROXY -u HTTPS_PROXY -u ALL_PROXY \
curl -sS -m 5 -o /dev/null -w 'google:%{http_code}\n' https://www.google.com/generate_204 || echo google:fail
# via working node if any
curl -sS -m 3 -X PUT 'http://127.0.0.1:9999/proxies/%F0%9F%9A%80%20%E8%8A%82%E7%82%B9%E9%80%89%E6%8B%A9' \
-H 'Content-Type: application/json' -d '{"name":"242af835-singbox_hysteria"}' || true
echo
env -u http_proxy -u https_proxy -u HTTP_PROXY -u HTTPS_PROXY \
curl -sS -m 10 -o /dev/null -w 'mixed_hy2:%{http_code}\n' -x http://127.0.0.1:7890 https://www.google.com/generate_204 || echo mixed_hy2:fail
"""
sftp = c.open_sftp()
with sftp.file("/tmp/_sc_netcheck.sh", "w") as f:
f.write(script.replace("\r\n", "\n"))
sftp.close()
_, o, e = c.exec_command(
f"echo '{GUEST_PW}' | sudo -S -p '' bash /tmp/_sc_netcheck.sh",
timeout=90,
)
print((o.read() + e.read()).decode("utf-8", "replace"))
c.close()
return 0
if __name__ == "__main__":
raise SystemExit(main())