Update cargo packages to latest releases, update rocket and sysinfo to newer syntaxes.

This commit is contained in:
Herbert Wolverson
2024-01-26 12:50:30 -06:00
parent 8cd8b7d404
commit b1b01b89a6
7 changed files with 553 additions and 518 deletions
+546 -508
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -46,7 +46,7 @@ impl<'r> FromRequest<'r> for AuthGuard {
return Outcome::Success(AuthGuard::ReadOnly) return Outcome::Success(AuthGuard::ReadOnly)
} }
_ => { _ => {
return Outcome::Failure(( return Outcome::Error((
Status::Unauthorized, Status::Unauthorized,
Error::msg("Invalid token"), Error::msg("Invalid token"),
)) ))
@@ -60,7 +60,7 @@ impl<'r> FromRequest<'r> for AuthGuard {
} }
} }
Outcome::Failure((Status::Unauthorized, Error::msg("Access Denied"))) Outcome::Error((Status::Unauthorized, Error::msg("Access Denied")))
} }
} }
@@ -18,9 +18,7 @@ use std::{sync::atomic::AtomicBool, time::Duration};
/// it runs as part of start-up - and keeps running. /// it runs as part of start-up - and keeps running.
/// Designed to never return or fail on error. /// Designed to never return or fail on error.
pub async fn update_tracking() { pub async fn update_tracking() {
use sysinfo::CpuExt;
use sysinfo::System; use sysinfo::System;
use sysinfo::SystemExt;
let mut sys = System::new_all(); let mut sys = System::new_all();
spawn_blocking(|| { spawn_blocking(|| {
+1 -1
View File
@@ -13,7 +13,7 @@ use std::{
mod blocking; mod blocking;
use anyhow::{Error, Result}; use anyhow::{Error, Result};
use blocking::run_query; use blocking::run_query;
use sysinfo::{ProcessExt, System, SystemExt}; use sysinfo::System;
const LOCK_FILE: &str = "/run/lqos/libreqos.lock"; const LOCK_FILE: &str = "/run/lqos/libreqos.lock";
+2 -2
View File
@@ -3,7 +3,7 @@ mod version;
use std::{time::Duration, net::TcpStream, io::Write}; use std::{time::Duration, net::TcpStream, io::Write};
use lqos_bus::anonymous::{AnonymousUsageV1, build_stats}; use lqos_bus::anonymous::{AnonymousUsageV1, build_stats};
use lqos_sys::num_possible_cpus; use lqos_sys::num_possible_cpus;
use sysinfo::{System, SystemExt, CpuExt}; use sysinfo::System;
use crate::{shaped_devices_tracker::{SHAPED_DEVICES, NETWORK_JSON}, stats::{HIGH_WATERMARK_DOWN, HIGH_WATERMARK_UP}}; use crate::{shaped_devices_tracker::{SHAPED_DEVICES, NETWORK_JSON}, stats::{HIGH_WATERMARK_DOWN, HIGH_WATERMARK_UP}};
const SLOW_START_SECS: u64 = 1; const SLOW_START_SECS: u64 = 1;
@@ -30,7 +30,7 @@ fn anonymous_usage_dump() -> anyhow::Result<()> {
sys.refresh_all(); sys.refresh_all();
data.total_memory = sys.total_memory(); data.total_memory = sys.total_memory();
data.available_memory = sys.available_memory(); data.available_memory = sys.available_memory();
if let Some(kernel) = sys.kernel_version() { if let Some(kernel) = sysinfo::System::kernel_version() {
data.kernel_version = kernel; data.kernel_version = kernel;
} }
data.usable_cores = num_possible_cpus().unwrap_or(0); data.usable_cores = num_possible_cpus().unwrap_or(0);
+1 -1
View File
@@ -6,7 +6,7 @@ use std::{
io::{Read, Write}, io::{Read, Write},
path::Path, path::Path,
}; };
use sysinfo::{ProcessExt, System, SystemExt}; use sysinfo::System;
const LOCK_PATH: &str = "/run/lqos/lqosd.lock"; const LOCK_PATH: &str = "/run/lqos/lqosd.lock";
const LOCK_DIR: &str = "/run/lqos"; const LOCK_DIR: &str = "/run/lqos";
@@ -1,11 +1,10 @@
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use sysinfo::{System, SystemExt}; use sysinfo::System;
use tokio::sync::Mutex; use tokio::sync::Mutex;
static SYS: Lazy<Mutex<System>> = Lazy::new(|| Mutex::new(System::new_all())); static SYS: Lazy<Mutex<System>> = Lazy::new(|| Mutex::new(System::new_all()));
pub(crate) async fn get_cpu_ram() -> (Vec<u32>, u32) { pub(crate) async fn get_cpu_ram() -> (Vec<u32>, u32) {
use sysinfo::CpuExt;
let mut lock = SYS.lock().await; let mut lock = SYS.lock().await;
lock.refresh_cpu(); lock.refresh_cpu();
lock.refresh_memory(); lock.refresh_memory();