feat: 初步支持 USB 网卡桥接;删除 OTG 端点预算管理

This commit is contained in:
mofeng-git
2026-07-16 19:19:24 +08:00
parent 63c2bb4ca2
commit 213359b6c8
35 changed files with 2367 additions and 727 deletions

View File

@@ -5,8 +5,8 @@ use crate::config::MsdConfig;
use crate::error::Result;
use crate::state::AppState;
use super::apply::{apply_msd_config, try_apply_lock, ConfigApplyOptions};
use super::types::MsdConfigUpdate;
use super::otg::update_otg_config_inner;
use super::types::{MsdConfigUpdate, OtgConfigUpdate};
pub async fn get_msd_config(State(state): State<Arc<AppState>>) -> Json<MsdConfig> {
Json(state.config.get().msd.clone())
@@ -16,28 +16,13 @@ pub async fn update_msd_config(
State(state): State<Arc<AppState>>,
Json(req): Json<MsdConfigUpdate>,
) -> Result<Json<MsdConfig>> {
req.validate()?;
let _apply_guard = try_apply_lock(&state.config_apply_locks.otg, "otg")?;
let old_msd_config = state.config.get().msd.clone();
state
.config
.update(|config| {
req.apply_to(&mut config.msd);
config.enforce_invariants();
})
.await?;
let new_msd_config = state.config.get().msd.clone();
apply_msd_config(
let response = update_otg_config_inner(
&state,
&old_msd_config,
&new_msd_config,
ConfigApplyOptions::forced(),
OtgConfigUpdate {
msd: Some(req),
..Default::default()
},
)
.await?;
Ok(Json(new_msd_config))
Ok(Json(response.msd))
}