blob: 77331ed45255c0e23cb5ff09aa199ead310bd019 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
use ::std::collections::HashMap;
use crate::network::LocalSocket;
use crate::OpenSockets;
use super::lsof_utils;
pub(crate) fn get_open_sockets() -> OpenSockets {
let mut open_sockets = HashMap::new();
let connections = lsof_utils::get_connections();
for raw_connection in connections {
open_sockets.insert(
LocalSocket {
ip: raw_connection.get_local_ip(),
port: raw_connection.get_local_port(),
protocol: raw_connection.get_protocol(),
},
raw_connection.process_name.clone(),
);
}
OpenSockets {
sockets_to_procs: open_sockets,
}
}
|