#!/bin/bash
# =============================================================================
# 1-Click Remote Desktop Host Agent for Mac & Linux
# Connects to https://rc.cheapkvm.net bridge
# =============================================================================

echo "=================================================================="
echo " Starting Remote Desktop Host Agent (rc.cheapkvm.net)..."
echo "=================================================================="

# Check Python 3
if ! command -v python3 &> /dev/null; then
    echo "Python 3 is required. Please install python3 to run the host agent."
    exit 1
fi

TMP_DIR="/tmp/rc_host"
mkdir -p "$TMP_DIR"
cd "$TMP_DIR"

echo "Downloading host agent runtime..."
curl -sSL -k "https://rc.cheapkvm.net/downloads/native_host.py" -o "$TMP_DIR/native_host.py" || {
    echo "Failed to download from rc.cheapkvm.net, using fallback..."
}

python3 "$TMP_DIR/native_host.py" --host rc.cheapkvm.net --port 443 --ssl "$@"
