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

66 lines
1.7 KiB
Python

# -*- coding: utf-8 -*-
"""Confirm external UDP/TCP packets hit eth0 for Neko ports."""
from __future__ import annotations
import socket
import sys
import threading
import time
import paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
HOST = "108.174.50.68"
PASS = "Xiao4669805"
def main() -> None:
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect(HOST, 22, "root", PASS, timeout=45, allow_agent=False, look_for_keys=False)
# start tcpdump in background
cmd = (
"timeout 8 tcpdump -ni eth0 -c 30 "
"'(udp port 52300 or udp port 52000 or tcp port 52300) and not host 127.0.0.1' "
"2>&1 || true"
)
chan = c.get_transport().open_session()
chan.exec_command(cmd)
time.sleep(1.2)
def blast() -> None:
for _ in range(3):
# TCP
try:
s = socket.create_connection((HOST, 52300), timeout=2)
s.close()
except Exception:
pass
for port in (52300, 52000, 52050):
try:
u = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
u.sendto(b"NEKO-PROBE", (HOST, port))
u.close()
except Exception:
pass
time.sleep(0.3)
t = threading.Thread(target=blast)
t.start()
t.join()
time.sleep(6)
out = b""
while chan.recv_ready():
out += chan.recv(65535)
while chan.recv_stderr_ready():
out += chan.recv_stderr(65535)
print(out.decode("utf-8", "replace"))
print("exit", chan.recv_exit_status())
c.close()
if __name__ == "__main__":
main()