mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-09-13 02:54:26 +08:00
feat: 初步增加 Windows 支持
This commit is contained in:
28
src/config/schema/atx.rs
Normal file
28
src/config/schema/atx.rs
Normal file
@@ -0,0 +1,28 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use typeshare::typeshare;
|
||||
|
||||
pub use crate::atx::{ActiveLevel, AtxDriverType, AtxKeyConfig, AtxLedConfig};
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(default)]
|
||||
#[derive(Default)]
|
||||
pub struct AtxConfig {
|
||||
pub enabled: bool,
|
||||
pub power: AtxKeyConfig,
|
||||
pub reset: AtxKeyConfig,
|
||||
pub led: AtxLedConfig,
|
||||
pub wol_interface: String,
|
||||
}
|
||||
|
||||
impl AtxConfig {
|
||||
pub fn to_controller_config(&self) -> crate::atx::AtxControllerConfig {
|
||||
crate::atx::AtxControllerConfig {
|
||||
enabled: self.enabled,
|
||||
power: self.power.clone(),
|
||||
reset: self.reset.clone(),
|
||||
led: self.led.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
64
src/config/schema/common.rs
Normal file
64
src/config/schema/common.rs
Normal file
@@ -0,0 +1,64 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use typeshare::typeshare;
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(tag = "type", content = "value")]
|
||||
#[derive(Default)]
|
||||
pub enum BitratePreset {
|
||||
Speed,
|
||||
#[default]
|
||||
Balanced,
|
||||
Quality,
|
||||
Custom(u32),
|
||||
}
|
||||
|
||||
impl BitratePreset {
|
||||
pub fn bitrate_kbps(&self) -> u32 {
|
||||
match self {
|
||||
Self::Speed => 1000,
|
||||
Self::Balanced => 4000,
|
||||
Self::Quality => 8000,
|
||||
Self::Custom(kbps) => *kbps,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn gop_size(&self, fps: u32) -> u32 {
|
||||
match self {
|
||||
Self::Speed => (fps / 2).max(15),
|
||||
Self::Balanced => fps,
|
||||
Self::Quality => fps * 2,
|
||||
Self::Custom(_) => fps,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn quality_level(&self) -> &'static str {
|
||||
match self {
|
||||
Self::Speed => "low",
|
||||
Self::Balanced => "medium",
|
||||
Self::Quality => "high",
|
||||
Self::Custom(_) => "medium",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_kbps(kbps: u32) -> Self {
|
||||
match kbps {
|
||||
0..=1500 => Self::Speed,
|
||||
1501..=6000 => Self::Balanced,
|
||||
6001..=10000 => Self::Quality,
|
||||
_ => Self::Custom(kbps),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for BitratePreset {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Speed => write!(f, "Speed (1 Mbps)"),
|
||||
Self::Balanced => write!(f, "Balanced (4 Mbps)"),
|
||||
Self::Quality => write!(f, "Quality (8 Mbps)"),
|
||||
Self::Custom(kbps) => write!(f, "Custom ({} kbps)", kbps),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
309
src/config/schema/hid.rs
Normal file
309
src/config/schema/hid.rs
Normal file
@@ -0,0 +1,309 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use typeshare::typeshare;
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
#[derive(Default)]
|
||||
pub enum HidBackend {
|
||||
Otg,
|
||||
Ch9329,
|
||||
#[default]
|
||||
None,
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
pub struct OtgDescriptorConfig {
|
||||
pub vendor_id: u16,
|
||||
pub product_id: u16,
|
||||
pub manufacturer: String,
|
||||
pub product: String,
|
||||
pub serial_number: Option<String>,
|
||||
}
|
||||
|
||||
impl Default for OtgDescriptorConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
vendor_id: 0x1d6b,
|
||||
product_id: 0x0104,
|
||||
manufacturer: "One-KVM".to_string(),
|
||||
product: "One-KVM USB Device".to_string(),
|
||||
serial_number: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[derive(Default)]
|
||||
pub enum OtgHidProfile {
|
||||
#[default]
|
||||
#[serde(alias = "full_no_msd")]
|
||||
Full,
|
||||
#[serde(alias = "full_no_consumer_no_msd")]
|
||||
FullNoConsumer,
|
||||
LegacyKeyboard,
|
||||
LegacyMouseRelative,
|
||||
Custom,
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[derive(Default)]
|
||||
pub enum OtgEndpointBudget {
|
||||
#[default]
|
||||
Auto,
|
||||
Five,
|
||||
Six,
|
||||
Unlimited,
|
||||
}
|
||||
|
||||
impl OtgEndpointBudget {
|
||||
pub fn endpoint_limit_raw(&self) -> Option<u8> {
|
||||
match self {
|
||||
Self::Five => Some(5),
|
||||
Self::Six => Some(6),
|
||||
Self::Unlimited => None,
|
||||
Self::Auto => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(default)]
|
||||
pub struct OtgHidFunctions {
|
||||
pub keyboard: bool,
|
||||
pub mouse_relative: bool,
|
||||
pub mouse_absolute: bool,
|
||||
pub consumer: bool,
|
||||
}
|
||||
|
||||
impl OtgHidFunctions {
|
||||
pub fn full() -> Self {
|
||||
Self {
|
||||
keyboard: true,
|
||||
mouse_relative: true,
|
||||
mouse_absolute: true,
|
||||
consumer: true,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn full_no_consumer() -> Self {
|
||||
Self {
|
||||
keyboard: true,
|
||||
mouse_relative: true,
|
||||
mouse_absolute: true,
|
||||
consumer: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn legacy_keyboard() -> Self {
|
||||
Self {
|
||||
keyboard: true,
|
||||
mouse_relative: false,
|
||||
mouse_absolute: false,
|
||||
consumer: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn legacy_mouse_relative() -> Self {
|
||||
Self {
|
||||
keyboard: false,
|
||||
mouse_relative: true,
|
||||
mouse_absolute: false,
|
||||
consumer: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {
|
||||
!self.keyboard && !self.mouse_relative && !self.mouse_absolute && !self.consumer
|
||||
}
|
||||
|
||||
pub fn endpoint_cost(&self, keyboard_leds: bool) -> u8 {
|
||||
let mut endpoints = 0;
|
||||
if self.keyboard {
|
||||
endpoints += 1;
|
||||
if keyboard_leds {
|
||||
endpoints += 1;
|
||||
}
|
||||
}
|
||||
if self.mouse_relative {
|
||||
endpoints += 1;
|
||||
}
|
||||
if self.mouse_absolute {
|
||||
endpoints += 1;
|
||||
}
|
||||
if self.consumer {
|
||||
endpoints += 1;
|
||||
}
|
||||
endpoints
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for OtgHidFunctions {
|
||||
fn default() -> Self {
|
||||
Self::full()
|
||||
}
|
||||
}
|
||||
|
||||
impl OtgHidProfile {
|
||||
pub fn from_legacy_str(value: &str) -> Option<Self> {
|
||||
match value {
|
||||
"full" | "full_no_msd" => Some(Self::Full),
|
||||
"full_no_consumer" | "full_no_consumer_no_msd" => Some(Self::FullNoConsumer),
|
||||
"legacy_keyboard" => Some(Self::LegacyKeyboard),
|
||||
"legacy_mouse_relative" => Some(Self::LegacyMouseRelative),
|
||||
"custom" => Some(Self::Custom),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn resolve_functions(&self, custom: &OtgHidFunctions) -> OtgHidFunctions {
|
||||
match self {
|
||||
Self::Full => OtgHidFunctions::full(),
|
||||
Self::FullNoConsumer => OtgHidFunctions::full_no_consumer(),
|
||||
Self::LegacyKeyboard => OtgHidFunctions::legacy_keyboard(),
|
||||
Self::LegacyMouseRelative => OtgHidFunctions::legacy_mouse_relative(),
|
||||
Self::Custom => custom.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(default)]
|
||||
pub struct HidConfig {
|
||||
pub backend: HidBackend,
|
||||
pub otg_udc: Option<String>,
|
||||
#[serde(default)]
|
||||
pub otg_descriptor: OtgDescriptorConfig,
|
||||
#[serde(default)]
|
||||
pub otg_profile: OtgHidProfile,
|
||||
#[serde(default)]
|
||||
pub otg_endpoint_budget: OtgEndpointBudget,
|
||||
#[serde(default)]
|
||||
pub otg_functions: OtgHidFunctions,
|
||||
#[serde(default)]
|
||||
pub otg_keyboard_leds: bool,
|
||||
pub ch9329_port: String,
|
||||
pub ch9329_baudrate: u32,
|
||||
pub mouse_absolute: bool,
|
||||
}
|
||||
|
||||
impl Default for HidConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
backend: HidBackend::None,
|
||||
otg_udc: None,
|
||||
otg_descriptor: OtgDescriptorConfig::default(),
|
||||
otg_profile: OtgHidProfile::default(),
|
||||
otg_endpoint_budget: OtgEndpointBudget::default(),
|
||||
otg_functions: OtgHidFunctions::default(),
|
||||
otg_keyboard_leds: false,
|
||||
ch9329_port: "/dev/ttyUSB0".to_string(),
|
||||
ch9329_baudrate: 9600,
|
||||
mouse_absolute: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl HidConfig {
|
||||
pub fn effective_otg_functions(&self) -> OtgHidFunctions {
|
||||
self.otg_profile.resolve_functions(&self.otg_functions)
|
||||
}
|
||||
|
||||
pub fn effective_otg_keyboard_leds(&self) -> bool {
|
||||
self.otg_keyboard_leds && self.effective_otg_functions().keyboard
|
||||
}
|
||||
|
||||
pub fn constrained_otg_functions(&self) -> OtgHidFunctions {
|
||||
self.effective_otg_functions()
|
||||
}
|
||||
|
||||
pub fn effective_otg_required_endpoints(&self, msd_enabled: bool) -> u8 {
|
||||
let functions = self.effective_otg_functions();
|
||||
let mut endpoints = functions.endpoint_cost(self.effective_otg_keyboard_leds());
|
||||
if msd_enabled {
|
||||
endpoints += 2;
|
||||
}
|
||||
endpoints
|
||||
}
|
||||
|
||||
pub fn validate_otg_endpoint_budget(&self, msd_enabled: bool) -> crate::error::Result<()> {
|
||||
if self.backend != HidBackend::Otg {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let functions = self.effective_otg_functions();
|
||||
if functions.is_empty() {
|
||||
return Err(crate::error::AppError::BadRequest(
|
||||
"OTG HID functions cannot be empty".to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
let resolved_limit = self.resolved_otg_endpoint_limit();
|
||||
let required = self.effective_otg_required_endpoints(msd_enabled);
|
||||
if let Some(limit) = resolved_limit {
|
||||
if required > limit {
|
||||
return Err(crate::error::AppError::BadRequest(format!(
|
||||
"OTG selection requires {} endpoints, but the configured limit is {}",
|
||||
required, limit
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn resolved_otg_udc(&self) -> Option<String> {
|
||||
if self.backend != HidBackend::Otg {
|
||||
return None;
|
||||
}
|
||||
self.otg_udc
|
||||
.as_ref()
|
||||
.map(|s| s.trim().to_string())
|
||||
.filter(|s| !s.is_empty())
|
||||
.or_else(|| {
|
||||
#[cfg(unix)]
|
||||
{
|
||||
crate::otg::OtgGadgetManager::find_udc()
|
||||
}
|
||||
#[cfg(not(unix))]
|
||||
{
|
||||
None
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn resolved_otg_endpoint_limit(&self) -> Option<u8> {
|
||||
if self.backend != HidBackend::Otg {
|
||||
return None;
|
||||
}
|
||||
match self.otg_endpoint_budget {
|
||||
OtgEndpointBudget::Five => Some(5),
|
||||
OtgEndpointBudget::Six => Some(6),
|
||||
OtgEndpointBudget::Unlimited => None,
|
||||
OtgEndpointBudget::Auto => {
|
||||
#[cfg(unix)]
|
||||
let udc = self.resolved_otg_udc().unwrap_or_default();
|
||||
#[cfg(unix)]
|
||||
if crate::otg::configfs::is_low_endpoint_udc(&udc) {
|
||||
Some(5)
|
||||
} else {
|
||||
Some(6)
|
||||
}
|
||||
#[cfg(not(unix))]
|
||||
{
|
||||
Some(6)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
44
src/config/schema/mod.rs
Normal file
44
src/config/schema/mod.rs
Normal file
@@ -0,0 +1,44 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use typeshare::typeshare;
|
||||
|
||||
pub use crate::extensions::ExtensionsConfig;
|
||||
pub use crate::rustdesk::config::RustDeskConfig;
|
||||
|
||||
mod atx;
|
||||
mod common;
|
||||
mod hid;
|
||||
mod stream;
|
||||
mod web;
|
||||
|
||||
pub use atx::*;
|
||||
pub use common::*;
|
||||
pub use hid::*;
|
||||
pub use stream::*;
|
||||
pub use web::*;
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(default)]
|
||||
#[derive(Default)]
|
||||
pub struct AppConfig {
|
||||
pub initialized: bool,
|
||||
pub auth: AuthConfig,
|
||||
pub video: VideoConfig,
|
||||
pub hid: HidConfig,
|
||||
pub msd: MsdConfig,
|
||||
pub atx: AtxConfig,
|
||||
pub audio: AudioConfig,
|
||||
pub stream: StreamConfig,
|
||||
pub web: WebConfig,
|
||||
pub extensions: ExtensionsConfig,
|
||||
pub rustdesk: RustDeskConfig,
|
||||
pub rtsp: RtspConfig,
|
||||
pub redfish: RedfishConfig,
|
||||
}
|
||||
|
||||
impl AppConfig {
|
||||
pub fn apply_platform_defaults(&mut self) {
|
||||
crate::platform::defaults::apply(self);
|
||||
}
|
||||
}
|
||||
|
||||
149
src/config/schema/stream.rs
Normal file
149
src/config/schema/stream.rs
Normal file
@@ -0,0 +1,149 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use typeshare::typeshare;
|
||||
|
||||
use super::BitratePreset;
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
#[derive(Default)]
|
||||
pub enum StreamMode {
|
||||
WebRTC,
|
||||
#[default]
|
||||
Mjpeg,
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
#[derive(Default)]
|
||||
pub enum RtspCodec {
|
||||
#[default]
|
||||
H264,
|
||||
H265,
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(default)]
|
||||
pub struct RtspConfig {
|
||||
pub enabled: bool,
|
||||
pub bind: String,
|
||||
pub port: u16,
|
||||
pub path: String,
|
||||
pub allow_one_client: bool,
|
||||
pub codec: RtspCodec,
|
||||
pub username: Option<String>,
|
||||
#[typeshare(skip)]
|
||||
pub password: Option<String>,
|
||||
}
|
||||
|
||||
impl Default for RtspConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
enabled: false,
|
||||
bind: "0.0.0.0".to_string(),
|
||||
port: 8554,
|
||||
path: "live".to_string(),
|
||||
allow_one_client: true,
|
||||
codec: RtspCodec::H264,
|
||||
username: None,
|
||||
password: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
#[derive(Default)]
|
||||
pub enum EncoderType {
|
||||
#[default]
|
||||
Auto,
|
||||
Software,
|
||||
Vaapi,
|
||||
Nvenc,
|
||||
Qsv,
|
||||
Amf,
|
||||
Rkmpp,
|
||||
V4l2m2m,
|
||||
}
|
||||
|
||||
impl EncoderType {
|
||||
pub fn display_name(&self) -> &'static str {
|
||||
match self {
|
||||
EncoderType::Auto => "Auto (Recommended)",
|
||||
EncoderType::Software => "Software (CPU)",
|
||||
EncoderType::Vaapi => "VAAPI",
|
||||
EncoderType::Nvenc => "NVIDIA NVENC",
|
||||
EncoderType::Qsv => "Intel Quick Sync",
|
||||
EncoderType::Amf => "AMD AMF",
|
||||
EncoderType::Rkmpp => "Rockchip MPP",
|
||||
EncoderType::V4l2m2m => "V4L2 M2M",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(default)]
|
||||
pub struct StreamConfig {
|
||||
pub mode: StreamMode,
|
||||
pub encoder: EncoderType,
|
||||
pub bitrate_preset: BitratePreset,
|
||||
pub stun_server: Option<String>,
|
||||
pub turn_server: Option<String>,
|
||||
pub turn_username: Option<String>,
|
||||
pub turn_password: Option<String>,
|
||||
#[typeshare(skip)]
|
||||
pub auto_pause_enabled: bool,
|
||||
#[typeshare(skip)]
|
||||
pub auto_pause_delay_secs: u64,
|
||||
#[typeshare(skip)]
|
||||
pub client_timeout_secs: u64,
|
||||
}
|
||||
|
||||
impl Default for StreamConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
mode: StreamMode::Mjpeg,
|
||||
encoder: EncoderType::Auto,
|
||||
bitrate_preset: BitratePreset::Balanced,
|
||||
stun_server: None,
|
||||
turn_server: None,
|
||||
turn_username: None,
|
||||
turn_password: None,
|
||||
auto_pause_enabled: false,
|
||||
auto_pause_delay_secs: 10,
|
||||
client_timeout_secs: 30,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl StreamConfig {
|
||||
pub fn is_using_public_ice_servers(&self) -> bool {
|
||||
let no_custom_stun = self
|
||||
.stun_server
|
||||
.as_ref()
|
||||
.map_or(true, |s| s.trim().is_empty());
|
||||
let no_custom_turn = self
|
||||
.turn_server
|
||||
.as_ref()
|
||||
.map_or(true, |s| s.trim().is_empty());
|
||||
no_custom_stun && no_custom_turn
|
||||
}
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(default)]
|
||||
pub struct RedfishConfig {
|
||||
pub enabled: bool,
|
||||
}
|
||||
|
||||
impl Default for RedfishConfig {
|
||||
fn default() -> Self {
|
||||
Self { enabled: false }
|
||||
}
|
||||
}
|
||||
|
||||
129
src/config/schema/web.rs
Normal file
129
src/config/schema/web.rs
Normal file
@@ -0,0 +1,129 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use typeshare::typeshare;
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(default)]
|
||||
pub struct AuthConfig {
|
||||
pub session_timeout_secs: u32,
|
||||
pub single_user_allow_multiple_sessions: bool,
|
||||
pub totp_enabled: bool,
|
||||
pub totp_secret: Option<String>,
|
||||
}
|
||||
|
||||
impl Default for AuthConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
session_timeout_secs: 3600 * 24,
|
||||
single_user_allow_multiple_sessions: false,
|
||||
totp_enabled: false,
|
||||
totp_secret: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(default)]
|
||||
pub struct VideoConfig {
|
||||
pub device: Option<String>,
|
||||
pub format: Option<String>,
|
||||
pub width: u32,
|
||||
pub height: u32,
|
||||
pub fps: u32,
|
||||
pub quality: u32,
|
||||
}
|
||||
|
||||
impl Default for VideoConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
device: None,
|
||||
format: None,
|
||||
width: 1920,
|
||||
height: 1080,
|
||||
fps: 30,
|
||||
quality: 80,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(default)]
|
||||
pub struct MsdConfig {
|
||||
pub enabled: bool,
|
||||
pub msd_dir: String,
|
||||
}
|
||||
|
||||
impl Default for MsdConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
enabled: true,
|
||||
msd_dir: String::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl MsdConfig {
|
||||
pub fn msd_dir_path(&self) -> std::path::PathBuf {
|
||||
std::path::PathBuf::from(&self.msd_dir)
|
||||
}
|
||||
|
||||
pub fn images_dir(&self) -> std::path::PathBuf {
|
||||
self.msd_dir_path().join("images")
|
||||
}
|
||||
|
||||
pub fn ventoy_dir(&self) -> std::path::PathBuf {
|
||||
self.msd_dir_path().join("ventoy")
|
||||
}
|
||||
|
||||
pub fn drive_path(&self) -> std::path::PathBuf {
|
||||
self.ventoy_dir().join("ventoy.img")
|
||||
}
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(default)]
|
||||
pub struct AudioConfig {
|
||||
pub enabled: bool,
|
||||
pub device: String,
|
||||
pub quality: String,
|
||||
}
|
||||
|
||||
impl Default for AudioConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
enabled: false,
|
||||
device: String::new(),
|
||||
quality: "balanced".to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(default)]
|
||||
pub struct WebConfig {
|
||||
pub http_port: u16,
|
||||
pub https_port: u16,
|
||||
pub bind_addresses: Vec<String>,
|
||||
pub bind_address: String,
|
||||
pub https_enabled: bool,
|
||||
pub ssl_cert_path: Option<String>,
|
||||
pub ssl_key_path: Option<String>,
|
||||
}
|
||||
|
||||
impl Default for WebConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
http_port: 8080,
|
||||
https_port: 8443,
|
||||
bind_addresses: Vec::new(),
|
||||
bind_address: "0.0.0.0".to_string(),
|
||||
https_enabled: false,
|
||||
ssl_cert_path: None,
|
||||
ssl_key_path: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user