douyinWEB/scripts/_tmp_fix_neko_caddy_ports.py
2026-09-13 22:10:49 -05:00

65 lines
2.2 KiB
Python

# -*- coding: utf-8 -*-
"""Find where dy.com /neko is proxied; fix FRP/Caddy port mismatch. No switches."""
from __future__ import annotations
import sys
import paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
v = paramiko.SSHClient()
v.set_missing_host_key_policy(paramiko.AutoAddPolicy())
v.connect("107.173.30.245", 22, "root", "Xiao4669805", timeout=40, allow_agent=False, look_for_keys=False)
def vr(cmd, t=60):
_, o, e = v.exec_command(cmd, timeout=t)
return (o.read() + e.read()).decode("utf-8", "replace")
print("=== Caddy dy neko ===")
print(vr(
"awk '/dy\\.nomadro\\.com|neko|920|1920|1820/{print NR\":\"$0}' /etc/caddy/Caddyfile | head -80; "
"echo '--- blocks ---'; "
"grep -n 'dy.nomadro.com\\|dylive.nomadro.com\\|handle_path /neko\\|reverse_proxy.*92' /etc/caddy/Caddyfile | head -60"
))
print("=== listeners ===")
print(vr(
"ss -ltn | grep -E ':92|:182|:192' | sort; "
"systemctl status dy-frp-http-aux --no-pager -l | head -35; "
"ps aux | grep -E 'frp|ssh.*920|ssh.*1920' | grep -v grep | head -20"
))
print("=== curl map ===")
print(vr(
"for p in 9200 9201 19200 19201 18200 18201; do "
" echo -n $p:; curl -sS -m 2 -o /dev/null -w '%{http_code}' http://127.0.0.1:$p/ || echo x; echo; "
"done"
))
# soft neko bounce on phys with proper sudo docker
print("=== phys soft neko + port check ===")
p = paramiko.SSHClient()
p.set_missing_host_key_policy(paramiko.AutoAddPolicy())
p.connect("107.173.30.245", 4014, "eric", "4669805", timeout=40, allow_agent=False, look_for_keys=False)
pw = "4669805"
_, o, e = p.exec_command(
f"echo '{pw}' | sudo -S -p '' bash /dev/stdin <<'EOS'\n"
"set +e\n"
"wg show wg-dy-cn | egrep 'handshake|transfer'\n"
"ping -c1 -W2 10.9.0.1 | tail -2\n"
"for p in 9200 9201 9202 9203 9204 9205 9206 9207 18200 18201; do\n"
" code=$(curl -sS -m 2 -o /dev/null -w '%{http_code}' http://127.0.0.1:$p/ || echo x)\n"
" echo port_$p=$code\n"
"done\n"
"for N in douyinweb-neko-1 douyinweb-neko-2 douyinweb-neko-3 douyinweb-ops-neko-1; do\n"
" echo ==$N==\n"
" docker exec \"$N\" supervisorctl status 2>/dev/null | head -8\n"
"done\n"
"EOS",
timeout=90,
)
print((o.read() + e.read()).decode("utf-8", "replace"))
p.close()
v.close()