Files
One-KVM/src/web/handlers/config/mod.rs
2026-06-15 22:24:40 +08:00

63 lines
1.8 KiB
Rust

pub(crate) mod apply;
mod types;
mod atx;
mod audio;
mod auth;
mod hid;
#[cfg(unix)]
mod msd;
mod redfish;
mod rtsp;
mod rustdesk;
mod stream;
pub(crate) mod video;
mod web;
pub use atx::{get_atx_config, update_atx_config};
pub use audio::{get_audio_config, update_audio_config};
pub use auth::{get_auth_config, update_auth_config};
pub use hid::{get_hid_config, update_hid_config};
#[cfg(unix)]
pub use msd::{get_msd_config, update_msd_config};
pub use redfish::{get_redfish_config, update_redfish_config};
pub use rtsp::{
get_rtsp_config, get_rtsp_status, start_rtsp_service, stop_rtsp_service, update_rtsp_config,
};
pub use rustdesk::{
get_device_password, get_rustdesk_config, get_rustdesk_status, regenerate_device_id,
regenerate_device_password, start_rustdesk_service, stop_rustdesk_service,
update_rustdesk_config,
};
pub use stream::{get_stream_config, update_stream_config};
pub use video::{get_video_config, update_video_config};
pub use web::{get_web_config, update_web_config};
use axum::{extract::State, Json};
use std::sync::Arc;
use crate::config::AppConfig;
use crate::state::AppState;
fn sanitize_config_for_api(config: &mut AppConfig) {
config.auth.totp_secret = None;
config.stream.turn_password = None;
config.computer_use.openai_api_key = None;
config.rustdesk.device_password.clear();
config.rustdesk.relay_key = None;
config.rustdesk.public_key = None;
config.rustdesk.private_key = None;
config.rustdesk.signing_public_key = None;
config.rustdesk.signing_private_key = None;
config.rtsp.password = None;
}
pub async fn get_all_config(State(state): State<Arc<AppState>>) -> Json<AppConfig> {
let mut config = (*state.config.get()).clone();
sanitize_config_for_api(&mut config);
Json(config)
}