#!/usr/bin/env python3 # -*- coding: utf-8 -*- import sys import paramiko import httpx sys.stdout.reconfigure(encoding="utf-8", errors="replace") def ssh(h, p, u, pw): c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect(h, p, u, pw, timeout=45, allow_agent=False, look_for_keys=False) return c def run(c, cmd, t=40): _, o, e = c.exec_command(cmd, timeout=t) return (o.read() + e.read()).decode("utf-8", "replace") print("=== public ===") with httpx.Client(follow_redirects=False, timeout=20) as cl: for u in [ "https://dy.nomadro.cn/", "https://dy.nomadro.cn/api/health", "https://dy.nomadro.com/api/health", "https://dy.nomadro.com/neko/1/", "https://dylive.nomadro.com/api/health", ]: try: r = cl.get(u) print(u, r.status_code, r.headers.get("location", "")) except Exception as ex: print(u, "ERR", ex) v = ssh("107.173.30.245", 22, "root", "Xiao4669805") print("=== overseas DNAT ===") print(run(v, "iptables -t nat -S PREROUTING | grep NEKO | head -8")) v.close() d = ssh("82.157.112.245", 22, "ubuntu", "Xiao4669805") print("=== tencent DNAT ===") print(run(d, "sudo iptables -t nat -S PREROUTING | grep NEKO | head -8; echo ---; sudo ufw status | grep -E '5230|5200|5210|5220' | head -10")) d.close() g = ssh("107.173.30.245", 4014, "eric", "4669805") print("=== physical env ===") print( run( g, "echo 4669805 | sudo -S -p '' grep -E 'DY_NEKO|Environment=Environment' /etc/systemd/system/douyinweb-api.service | head -15", ) ) g.close()