mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-07-29 17:41:45 +08:00
feat: 初步支持 USB 网卡桥接;删除 OTG 端点预算管理
This commit is contained in:
34
src/web/handlers/config/otg_network.rs
Normal file
34
src/web/handlers/config/otg_network.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use axum::{extract::State, Json};
|
||||
|
||||
use crate::config::OtgNetworkConfig;
|
||||
use crate::error::Result;
|
||||
use crate::otg::OtgNetworkStatus;
|
||||
use crate::state::AppState;
|
||||
|
||||
use super::otg::update_otg_config_inner;
|
||||
use super::types::{OtgConfigUpdate, OtgNetworkConfigUpdate};
|
||||
|
||||
pub async fn get_otg_network_config(State(state): State<Arc<AppState>>) -> Json<OtgNetworkConfig> {
|
||||
Json(state.config.get().otg_network.clone())
|
||||
}
|
||||
|
||||
pub async fn update_otg_network_config(
|
||||
State(state): State<Arc<AppState>>,
|
||||
Json(request): Json<OtgNetworkConfigUpdate>,
|
||||
) -> Result<Json<OtgNetworkConfig>> {
|
||||
let response = update_otg_config_inner(
|
||||
&state,
|
||||
OtgConfigUpdate {
|
||||
network: Some(request),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
Ok(Json(response.network))
|
||||
}
|
||||
|
||||
pub async fn get_otg_network_status(State(state): State<Arc<AppState>>) -> Json<OtgNetworkStatus> {
|
||||
Json(state.otg_service.network_status().await)
|
||||
}
|
||||
Reference in New Issue
Block a user