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

1054
src/rust/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -46,7 +46,7 @@ impl<'r> FromRequest<'r> for AuthGuard {
return Outcome::Success(AuthGuard::ReadOnly)
}
_ => {
return Outcome::Failure((
return Outcome::Error((
Status::Unauthorized,
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")))
}
}

View File

@@ -18,9 +18,7 @@ use std::{sync::atomic::AtomicBool, time::Duration};
/// it runs as part of start-up - and keeps running.
/// Designed to never return or fail on error.
pub async fn update_tracking() {
use sysinfo::CpuExt;
use sysinfo::System;
use sysinfo::SystemExt;
let mut sys = System::new_all();
spawn_blocking(|| {

View File

@@ -13,7 +13,7 @@ use std::{
mod blocking;
use anyhow::{Error, Result};
use blocking::run_query;
use sysinfo::{ProcessExt, System, SystemExt};
use sysinfo::System;
const LOCK_FILE: &str = "/run/lqos/libreqos.lock";

View File

@@ -3,7 +3,7 @@ mod version;
use std::{time::Duration, net::TcpStream, io::Write};
use lqos_bus::anonymous::{AnonymousUsageV1, build_stats};
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}};
const SLOW_START_SECS: u64 = 1;
@@ -30,7 +30,7 @@ fn anonymous_usage_dump() -> anyhow::Result<()> {
sys.refresh_all();
data.total_memory = sys.total_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.usable_cores = num_possible_cpus().unwrap_or(0);

View File

@@ -6,7 +6,7 @@ use std::{
io::{Read, Write},
path::Path,
};
use sysinfo::{ProcessExt, System, SystemExt};
use sysinfo::System;
const LOCK_PATH: &str = "/run/lqos/lqosd.lock";
const LOCK_DIR: &str = "/run/lqos";

View File

@@ -1,11 +1,10 @@
use once_cell::sync::Lazy;
use sysinfo::{System, SystemExt};
use sysinfo::System;
use tokio::sync::Mutex;
static SYS: Lazy<Mutex<System>> = Lazy::new(|| Mutex::new(System::new_all()));
pub(crate) async fn get_cpu_ram() -> (Vec<u32>, u32) {
use sysinfo::CpuExt;
let mut lock = SYS.lock().await;
lock.refresh_cpu();
lock.refresh_memory();