78 lines
3.1 KiB
Python
78 lines
3.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Why hysteria5 times out while tuic works. Check hop ports + firewall + tls."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
import time
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace", line_buffering=True)
|
|
|
|
|
|
def connect(port=22, user="root", pw="Xiao4669805"):
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect("107.173.30.245", port, user, pw, timeout=25, banner_timeout=40, allow_agent=False, look_for_keys=False)
|
|
print(f"connected :{port}", flush=True)
|
|
return c
|
|
|
|
|
|
def run(c, cmd, t=60):
|
|
print(f"\n$ {cmd[:220]}", flush=True)
|
|
_i, o, e = c.exec_command(cmd, timeout=t)
|
|
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)
|
|
|
|
|
|
print("## VPS hysteria inbound detail + firewall", flush=True)
|
|
v = connect(22)
|
|
run(
|
|
v,
|
|
"python3 - <<'PY'\n"
|
|
"import json\n"
|
|
"from pathlib import Path\n"
|
|
"for p in [Path('/etc/v2ray-agent/sing-box/conf/config.json'), *Path('/etc/v2ray-agent/sing-box/conf').glob('*.json')]:\n"
|
|
" try: d=json.loads(p.read_text())\n"
|
|
" except Exception: continue\n"
|
|
" items=d if isinstance(d,list) else ([d] if 'type' in d else d.get('inbounds') or [])\n"
|
|
" if isinstance(d,dict) and 'inbounds' not in d and d.get('type'): items=[d]\n"
|
|
" for ib in items:\n"
|
|
" if not isinstance(ib,dict): continue\n"
|
|
" if 'hysteria' not in str(ib.get('type','')).lower() and 'hysteria' not in str(ib.get('tag','')).lower():\n"
|
|
" continue\n"
|
|
" print('FILE', p)\n"
|
|
" print(json.dumps({k:ib.get(k) for k in ('type','tag','listen','listen_port','up_mbps','down_mbps','tls','obfs','users','masquerade')}, indent=2)[:2500])\n"
|
|
"PY\n"
|
|
"echo '--- ufw ---'; ufw status | grep -E '21825|30000|16113|32000|UDP' | head -30; "
|
|
"echo '--- iptables ---'; iptables -L INPUT -n | grep -E '21825|30000|16113' | head -20; "
|
|
"journalctl -u sing-box --since '10 min ago' --no-pager | grep -i hysteria | tail -30",
|
|
t=50,
|
|
)
|
|
v.close()
|
|
|
|
print("## physical: client yaml snippet + delay without hop?", flush=True)
|
|
g = connect(4014, "eric", "4669805")
|
|
run(
|
|
g,
|
|
"echo 4669805 | sudo -S -p '' bash -lc '"
|
|
"sed -n \"177,218p\" /tmp/ShellCrash/config.yaml; "
|
|
"echo ---; "
|
|
# force delay again
|
|
"curl -sS -m 12 -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 12 -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"
|
|
"'",
|
|
t=40,
|
|
)
|
|
g.close()
|
|
print("DONE", flush=True)
|