use crate::uploads::UploadSessions; use crate::auth::SessionStore; use openpxe_core::{ AdminStore, BootLog, BrandingStore, ClientRegistry, DeploymentQueue, HostBindings, LogBus, Metrics, SettingsStore, SsoStore, }; use openpxe_iso_store::{IsoStore, SmbManager, SmbShareManager}; use std::sync::Arc; use time::OffsetDateTime; #[derive(Clone)] pub struct AppState { pub iso_store: IsoStore, pub clients: Arc, pub settings: Arc, pub queue: Arc, /// Per-MAC iPXE script overrides. When a client matching one of /// these MACs requests `/boot.ipxe`, we chain straight to the /// configured target instead of rendering the menu. pub hosts: HostBindings, /// Persistent boot-event log surfaced under the Hosts tab. Records /// every `/boot/.ipxe` chain that goes on to serve a script /// (i.e. an image actually starting to install on a machine). pub boot_log: BootLog, /// Operator-controlled UI overrides (custom logo). When the /// operator hasn't uploaded anything, the WebUI serves the bundled /// rainbow-horizon mark. pub branding: BrandingStore, /// Forms-auth admin record + first-run bootstrap state. When /// `admin.is_configured() == false`, the auth middleware passes /// every request through and `/api/me` reports `setup_required`. pub admin: AdminStore, /// In-memory session table for active operator logins. Cleared on /// process restart (sessions are tied to UI state, not persisted — /// matches Sonarr/Radarr behaviour). pub sessions: SessionStore, /// SAML SSO configuration. v0.4.5 stores it; the actual SSO login /// flow ships in a later release. pub sso: SsoStore, /// Lock-free metrics counters surfaced at `/metrics` in Prometheus /// text format. Cheap to clone (handles to atomics). pub metrics: Metrics, /// Optional SMB manager. Present when the binary was given a writable /// `smb_dir` at startup; `None` in pure-Linux-only deployments where /// Windows support is not wired in. Settings toggle drives start/stop. pub smb: Option>, /// v0.4.65: SMB share manager — userspace consumer of remote SMB /// shares via Samba's `smbclient` CLI. Replaces the kernel-mount /// NFS path that v0.4.64 shipped; that path didn't work on hosts /// (Unraid, etc.) whose kernel ships without the nfs/cifs client /// modules, and no container-side configuration could fix it. /// `smbclient` does the SMB protocol over a plain TCP socket in /// userspace — works in any container, no special caps required. pub smb_shares: SmbShareManager, /// Browser chunked upload state. Multipart uploads still go straight /// through `IsoStore`, but the UI uses sessions so large ISO transfers /// can show deterministic progress and leave visible partial files. pub uploads: UploadSessions, /// Live log bus consumed by the Terminal tab via SSE. Operator-issued /// terminal commands also push synthetic lines onto it so the tail /// shows them inline. pub log_bus: Arc, /// Wall-clock instant the server bound — used for the uptime chip. pub started_at: OffsetDateTime, /// Base URL advertised to PXE clients (e.g. `http://10.0.0.5`). Used when /// rendering iPXE scripts so every URL resolves offline. pub public_base_url: String, /// Name of the network interface auto-detected at startup (e.g. /// `enp1s0`). Surfaced read-only on the Network tab. Empty if the /// interface couldn't be identified. pub nic_name: String, /// Subnet mask of the public interface in dotted-quad form. pub subnet_mask: String, /// Default gateway IPv4 address. pub gateway: String, }