Can edit more network settings

This commit is contained in:
2023-12-06 15:30:30 +01:00
parent 7bf4e87df1
commit b7d44f3091
17 changed files with 384 additions and 77 deletions

View File

@ -5,7 +5,7 @@ use crate::controllers::{HttpResult, LibVirtReq};
use crate::extractors::local_auth_extractor::LocalAuthEnabled;
use crate::libvirt_rest_structures::HypervisorInfo;
use actix_web::{HttpResponse, Responder};
use sysinfo::{System, SystemExt};
use sysinfo::{NetworksExt, System, SystemExt};
pub async fn root_index() -> impl Responder {
HttpResponse::Ok().body("Hello world!")
@ -86,3 +86,16 @@ pub async fn server_info(client: LibVirtReq) -> HttpResult {
system,
}))
}
pub async fn networks_list() -> HttpResult {
let mut system = System::new();
system.refresh_networks_list();
Ok(HttpResponse::Ok().json(
system
.networks()
.iter()
.map(|n| n.0.to_string())
.collect::<Vec<_>>(),
))
}