dbx/src-web/src/state.rs

20 lines
566 B
Rust

use dbx_core::connection::AppState;
use std::collections::{HashMap, HashSet};
use std::path::PathBuf;
use std::sync::Arc;
use tokio::sync::{broadcast, Mutex, RwLock};
pub struct LoginRateLimit {
pub fail_count: u32,
pub locked_until: Option<std::time::Instant>,
}
pub struct WebState {
pub app: Arc<AppState>,
pub data_dir: PathBuf,
pub password_hash: RwLock<Option<String>>,
pub sessions: RwLock<HashSet<String>>,
pub sse_channels: RwLock<HashMap<String, broadcast::Sender<String>>>,
pub login_rate_limit: Mutex<LoginRateLimit>,
}