=== GUIDA COMPLETA INSTALLAZIONE PANNELLO VPN ===

📦 REQUISITI SERVER PANNELLO:
- Ubuntu 20.04 o 22.04
- Python 3.8+
- MySQL/MariaDB
- pacchetti: pip, uvicorn, paramiko

📦 REQUISITI SERVER VPN REMOTI:
- Ubuntu 20.04+
- OpenVPN configurato
- cartella /root/vpn_agent con script agent.py, create.sh, revoke.sh
- easy-rsa installato in /etc/openvpn/easy-rsa/

🔧 INSTALLAZIONE PANNELLO:
1. Estrai questo ZIP in una cartella sul server Ubuntu
2. Crea un virtualenv:
   python3 -m venv venv && source venv/bin/activate
3. Installa dipendenze:
   pip install -r requirements.txt
4. Configura il database:
   mysql -u root -p
   CREATE DATABASE vpn_panel;
   USE vpn_panel;
   SOURCE setup/setup_mysql.sql;
5. Copia il file `.env.example` e rinominalo in `.env` → modifica user, password, host
6. Avvia il pannello:
   bash start.sh

🧑‍💻 LOGIN:
- Admin: http://<IP>:8000/templates/login.html
- Reseller: http://<IP>:8000/templates/reseller_login.html

🔐 DASHBOARD:
- Admin: http://<IP>:8000/admin/dashboard
  → Vedi tutti gli utenti
  → Revoca accesso
  → Scarica file .ovpn

- Rivenditore: http://<IP>:8000/reseller/dashboard
  → Vedi utenti propri
  → Crea nuovo utente
  → Revoca e scarica .ovpn

⚙️ CONFIGURAZIONE SERVER VPN REMOTO:
1. Copia la cartella `vpn_agent/` in /root sul server remoto
2. Dai permessi:
   chmod +x /root/vpn_agent/*.sh
3. Configura SSH (key o password) tra pannello e server VPN
4. Aggiungi nel file `vpn_remote.py`:
   {
     "vpn1": {
       "host": "1.2.3.4",
       "username": "root",
       "password": "tua_password",
       "path": "/root/vpn_agent"
     }
   }

📁 STRUTTURA FILE:
- routes/: rotte FastAPI
- templates/: HTML pannello
- downloads/: file .ovpn da scaricare
- vpn_remote.py: connessione SSH
- static/: immagini/logo
- .env: configurazione ambiente

🚀 FLUSSO COMPLETO:
1. Admin crea rivenditori nel DB
2. Rivenditore accede e crea utenti
3. Viene generato file .ovpn via SSH
4. L'utente scarica e usa il file nel client OpenVPN

Buon lavoro fratm 🐫
🌍 SUPPORTO MULTI-SERVER VPN
----------------------------
Nel file vpn_remote.py puoi configurare più server VPN:

VPN_SERVERS = {
    "vpn1": {
        "host": "1.2.3.4",
        "username": "root",
        "password": "pass1",
        "remote_path": "/root/vpn_agent",
        "download_path": "/etc/openvpn/client-configs/files"
    },
    "vpn2": {
        "host": "5.6.7.8",
        "username": "root",
        "password": "pass2",
        "remote_path": "/root/vpn_agent",
        "download_path": "/etc/openvpn/client-configs/files"
    }
}

Il rivenditore potrà selezionare il server VPN direttamente dalla dashboard tramite un menu a tendina.

Il sistema eseguirà lo script create.sh via SSH sul server selezionato e scaricherà il file .ovpn corrispondente nella cartella /downloads.