use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct TunnelConfig {
    pub address: String,
    pub prefix: i32,
    pub dns: String,
    pub mtu: i32,
    pub killswitch_enabled: bool,
    pub excluded_apps: Vec<String>,
    pub excluded_domains: Vec<String>,
    #[serde(default)]
    pub allowed_apps: Vec<String>,
    /// Bearer-токен клиента для проверки авторизации на прокси
    /// (`--require-auth`); `None` — сервер не требует авторизацию, либо
    /// приложение ещё не залогинено.
    #[serde(default)]
    pub auth_token: Option<String>,
}

#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct StartVpnRequest {
    pub config: TunnelConfig,
    pub ip: String,
    pub port: i32,
    pub sni: String,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct StopVpnRequest {}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct StatusResponse {
    pub status: String,
}

#[derive(Serialize, Clone, Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TrafficStatsResponse {
    pub rx_bytes: u64,
    pub tx_bytes: u64,
    pub rx_packets: u64,
    pub tx_packets: u64,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AppInfo {
    pub app_name: String,
    pub package_name: String,
}
