#!/usr/bin/env python3 """Force Neko NAT1TO1 to public IP 108.174.50.68 on dy.nomadro.live.""" from __future__ import annotations import sys import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect( "108.174.50.68", 22, "root", "Xiao4669805", timeout=45, allow_agent=False, look_for_keys=False, banner_timeout=120, ) cmd = r""" set -euo pipefail # Persist correct public IP (avoid fake-ip 198.18.x from sing-box) grep -q '^DY_NEKO_NAT1TO1=' /etc/douyinweb.env \ && sed -i 's/^DY_NEKO_NAT1TO1=.*/DY_NEKO_NAT1TO1=108.174.50.68/' /etc/douyinweb.env \ || echo 'DY_NEKO_NAT1TO1=108.174.50.68' >> /etc/douyinweb.env # Also bake into API unit Environment if present if grep -q 'DY_NEKO_NAT1TO1=' /etc/systemd/system/douyinweb-api.service; then sed -i 's/Environment=DY_NEKO_NAT1TO1=.*/Environment=DY_NEKO_NAT1TO1=108.174.50.68/' /etc/systemd/system/douyinweb-api.service else # insert after EnvironmentFile if missing sed -i '/EnvironmentFile=-\/etc\/douyinweb.env/a Environment=DY_NEKO_NAT1TO1=108.174.50.68' /etc/systemd/system/douyinweb-api.service || true fi systemctl daemon-reload systemctl restart douyinweb-api sleep 3 cd /opt/douyinWEB/backend set -a; source /etc/douyinweb.env; set +a export DY_NEKO_NAT1TO1=108.174.50.68 ./.venv/bin/python - <<'PY' from app import youtube_neko as yn from app import config print('settings_nat', getattr(config.settings, 'neko_nat1to1', None)) print('detect', yn._detect_public_ip()) # recreate compose with correct NAT (containers Created only — no start) out = yn.ensure_capacity(4, start_instances=set(), reconcile_running=False) print(out) # show compose nat line from pathlib import Path text = (yn._compose_path()).read_text(encoding='utf-8') for ln in text.splitlines(): if 'NAT' in ln.upper() or 'nat1' in ln.lower() or 'NEKO_WEBRTC' in ln: print('compose', ln.strip()[:120]) PY """ _i, o, e = c.exec_command(cmd, timeout=180) print((o.read() + e.read()).decode("utf-8", "replace")) print("exit", o.channel.recv_exit_status()) c.close()