docker exec marzban-marzban-1 sh -c '
xray run -config /tmp/hifi-test.json >/tmp/hifi-test-run.log 2>&1 &
PID=$!
sleep 2
python3 - << "PY"
import socket, ssl
proxy = ("127.0.0.1", 10808)
target = ("api.ipify.org", 443)
s = socket.create_connection(proxy, timeout=10)
# SOCKS5 handshake
s.sendall(b"\x05\x01\x00")
if s.recv(2) != b"\x05\x00":
raise RuntimeError("SOCKS5 handshake failed")
# CONNECT api.ipify.org:443
host = target[0].encode()
port = target[1]
req = b"\x05\x01\x00\x03" + bytes([len(host)]) + host + port.to_bytes(2, "big")
s.sendall(req)
resp = s.recv(10)
if len(resp) < 2 or resp[1] != 0:
raise RuntimeError("SOCKS5 CONNECT failed: " + repr(resp))
# TLS через SOCKS5
ctx = ssl.create_default_context()
tls = ctx.wrap_socket(s, server_hostname=target[0])
tls.sendall(
b"GET / HTTP/1.1\r\n"
b"Host: api.ipify.org\r\n"
b"Connection: close\r\n\r\n"
)
data = b""
while True:
chunk = tls.recv(4096)
if not chunk:
break
data += chunk
print("=== RESPONSE ===")
print(data.decode(errors="replace"))
tls.close()
PY
STATUS=$?
echo
echo "=== XRAY LOG ==="
cat /tmp/hifi-test-run.log
kill $PID 2>/dev/null
exit $STATUS
'