Skip to content

Commit

Permalink
Update sysinfo API calls
Browse files Browse the repository at this point in the history
- Fixes #420
  • Loading branch information
cyqsimon committed Aug 13, 2024
1 parent 4dba563 commit b76b905
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/os/windows.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::HashMap;

use netstat2::*;
use sysinfo::{Pid, System};
use sysinfo::{Pid, ProcessesToUpdate, System};

use crate::{
network::{LocalSocket, Protocol},
Expand All @@ -13,7 +13,7 @@ pub(crate) fn get_open_sockets() -> OpenSockets {
let mut open_sockets = HashMap::new();

let mut sysinfo = System::new_all();
sysinfo.refresh_processes();
sysinfo.refresh_processes(ProcessesToUpdate::All);

let af_flags = AddressFamilyFlags::IPV4 | AddressFamilyFlags::IPV6;
let proto_flags = ProtocolFlags::TCP | ProtocolFlags::UDP;
Expand All @@ -25,7 +25,7 @@ pub(crate) fn get_open_sockets() -> OpenSockets {
.associated_pids
.into_iter()
.find_map(|pid| sysinfo.process(Pid::from_u32(pid)))
.map(|p| ProcessInfo::new(p.name(), p.pid().as_u32()))
.map(|p| ProcessInfo::new(&p.name().to_string_lossy(), p.pid().as_u32()))
.unwrap_or_default();

match si.protocol_socket_info {
Expand Down

0 comments on commit b76b905

Please sign in to comment.