#!/usr/bin/env python3 """Neko optimization + CN ICE path probes (read-only).""" from __future__ import annotations import sys import time import httpx import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") def ssh(host, port, user, pw): c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect(host, port, user, pw, timeout=45, banner_timeout=120, allow_agent=False, look_for_keys=False) return c def run(c, cmd, t=90): _i, o, e = c.exec_command(cmd, timeout=t) o.channel.recv_exit_status() print((o.read() + e.read()).decode("utf-8", "replace"), flush=True) print("===== CN ops-neko HTTP + ICE ports reachability =====", flush=True) with httpx.Client(follow_redirects=False, timeout=15) as cl: for url in [ "https://dy.nomadro.cn/ops-neko/1/", "https://dy.nomadro.cn/ops-neko/2/", "https://dy.nomadro.cn/neko/1/", "https://dy.nomadro.cn/neko/3/", ]: try: r = cl.get(url) print(f"{r.status_code} {url}", flush=True) except Exception as ex: print(f"ERR {url} {ex}", flush=True) # Can we TCP-reach Tencent NAT mux from outside? (ICE candidate IP) # 62300 = ops-neko-1 UDPMUX; don't send attack payloads — just TCP connect check if any import socket for host, port, label in [ ("82.157.112.245", 62300, "ops1-mux"), ("82.157.112.245", 62301, "ops2-mux"), ("82.157.112.245", 52300, "neko1-mux"), ("107.173.30.245", 62300, "vps-ops1-mux-should-fail-or-dnat"), ]: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.settimeout(4) try: s.connect((host, port)) print(f"TCP OK {label} {host}:{port}", flush=True) except Exception as ex: print(f"TCP FAIL {label} {host}:{port} {type(ex).__name__}", flush=True) finally: s.close() p = ssh("107.173.30.245", 4014, "eric", "4669805") print("===== PHYS neko fleet load + exclusive mode =====", flush=True) run( p, r""" echo '4669805' | sudo -S -p '' bash -lc ' set +e echo "--- docker stats snapshot ---" docker stats --no-stream --format "table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}" 2>/dev/null | grep -iE "neko|ops|NAME" | head -25 echo "--- how many chrome/neko ---" docker ps --format "{{.Names}} {{.Status}}" | grep -i neko echo "--- settings neko exclusive / bitrate ---" CS=$(mktemp) curl -sS -m 10 --noproxy "*" -c "$CS" -b "$CS" -X POST http://127.0.0.1:8014/api/auth/login \ -H "Content-Type: application/json" \ -d "{\"username\":\"hackrobot\",\"password\":\"Xiao4669805@\"}" >/dev/null curl -sS -m 10 --noproxy "*" -b "$CS" http://127.0.0.1:8014/api/settings | python3 -c " import sys,json d=json.load(sys.stdin) keys=[k for k in d if any(x in k.lower() for x in (\"neko\",\"exclusive\",\"bitrate\",\"fps\",\"screen\",\"solo\",\"single\"))] for k in sorted(keys): print(k, \"=\", d[k]) " echo "--- assign on physical (if any) ---" curl -sS -m 10 --noproxy "*" -b "$CS" http://127.0.0.1:8014/api/youtube/assign/groups 2>/dev/null | python3 -c " import sys,json raw=sys.stdin.read() d=json.loads(raw) rows=d if isinstance(d,list) else d.get(\"groups\") or [] print(\"phys groups\", len(rows)) en=sum(1 for g in rows if g.get(\"neko_enabled\")) print(\"neko_enabled\", en) " 2>/dev/null rm -f "$CS" echo "--- shellcrash 7890 ---" ss -lntp | grep 7890 || echo no7890 curl -sS -m 4 --noproxy "*" -o /dev/null -w "proxy_port=%{http_code}\n" http://127.0.0.1:7890/ || true ' """, ) p.close() v = ssh("107.173.30.245", 22, "root", "Xiao4669805") print("===== VPS: can local neko start? port conflict =====", flush=True) run( v, r""" set +e # try explain conflict ss -lntp | grep ':9202' docker start douyinweb-neko-3 2>&1 | tail -5 docker ps -a --filter name=douyinweb-neko-3 --format '{{.Names}} {{.Status}}' # recent error docker inspect douyinweb-neko-3 --format '{{.State.Error}} {{.State.Status}}' 2>/dev/null # dylive open for neko_enabled local group — what does HTTP actually serve? # Compare Set-Cookie / title only curl -sS -m 8 https://dylive.nomadro.com/neko/3/ | head -c 180; echo curl -sS -m 8 https://dy.nomadro.cn/neko/3/ | head -c 180; echo """, ) v.close() print("DONE", flush=True)