remove psutil which is too old

This commit is contained in:
rustdesk
2022-01-15 13:47:57 +08:00
parent d069b73303
commit f47dcd1a8b
6 changed files with 157 additions and 88 deletions

View File

@@ -30,6 +30,7 @@ filetime = "0.2"
sodiumoxide = "0.2"
regex = "1.4"
tokio-socks = { git = "https://github.com/fufesou/tokio-socks" }
sysinfo = "0.22"
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
mac_address = "1.1"

View File

@@ -27,12 +27,13 @@ pub use anyhow::{self, bail};
pub use futures_util;
pub mod config;
pub mod fs;
pub use mac_address;
pub use regex;
pub use sodiumoxide;
pub use sysinfo;
pub use tokio_socks;
pub use tokio_socks::IntoTargetAddr;
pub use tokio_socks::TargetAddr;
pub use mac_address;
#[cfg(feature = "quic")]
pub type Stream = quic::Connection;
@@ -185,6 +186,17 @@ pub fn get_version_number(v: &str) -> i64 {
n
}
pub fn get_process(pid: i32) -> Option<sysinfo::Process> {
use sysinfo::{System, SystemExt};
let mut sys = System::new();
sys.refresh_processes();
sys.process(pid).cloned()
}
pub fn get_current_process() -> Option<sysinfo::Process> {
get_process(std::process::id() as _)
}
#[cfg(test)]
mod tests {
use super::*;