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

41 lines
1.6 KiB
Python

#!/usr/bin/env python3
"""Continue hysteria5 no-hop test after config edit."""
from __future__ import annotations
import sys
import time
import paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace", line_buffering=True)
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect("107.173.30.245", 4014, "eric", "4669805", timeout=25, banner_timeout=40, allow_agent=False, look_for_keys=False)
print("connected", flush=True)
cmd = r'''
echo 4669805 | sudo -S -p '' bash -lc '
grep -A12 "name: 1d2da142-singbox_hysteria5" /tmp/ShellCrash/config.yaml | head -14
systemctl restart shellcrash.service
sleep 5
systemctl is-active shellcrash
curl -sS -m 5 http://127.0.0.1:9999/version; echo
curl -sS -m 15 -G "http://127.0.0.1:9999/proxies/1d2da142-singbox_hysteria5/delay" --data-urlencode "url=http://www.gstatic.com/generate_204" --data-urlencode "timeout=8000"; echo
curl -sS -m 10 -G "http://127.0.0.1:9999/proxies/1d2da142-singbox_tuic5/delay" --data-urlencode "url=http://www.gstatic.com/generate_204" --data-urlencode "timeout=5000"; echo
'
'''
_i, o, e = c.exec_command(cmd, timeout=90)
while not o.channel.exit_status_ready():
if o.channel.recv_ready():
sys.stdout.write(o.channel.recv(4096).decode("utf-8", "replace"))
sys.stdout.flush()
if o.channel.recv_stderr_ready():
sys.stdout.write(o.channel.recv_stderr(4096).decode("utf-8", "replace"))
sys.stdout.flush()
time.sleep(0.1)
sys.stdout.write((o.read() + e.read()).decode("utf-8", "replace"))
sys.stdout.flush()
print("->", o.channel.recv_exit_status(), flush=True)
c.close()
print("DONE", flush=True)