diff options
author | Kelvin Zhang <zhangxp1998@gmail.com> | 2020-01-06 17:38:00 -0500 |
---|---|---|
committer | Kelvin Zhang <zhangxp1998@gmail.com> | 2020-01-07 16:27:22 -0500 |
commit | 2a30061b68af040a1a28de8624b5df85571a0a78 (patch) | |
tree | d467edb1b249723bbf4f510c74c6967981380483 /src/tests/fakes | |
parent | 66c0347d8de8d54fab3d2b5e6104a911a584bbcb (diff) |
Use <local_ip, local_port, protocol> to indentify processes
Diffstat (limited to 'src/tests/fakes')
-rw-r--r-- | src/tests/fakes/fake_input.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/tests/fakes/fake_input.rs b/src/tests/fakes/fake_input.rs index 7f384f6..1294e4c 100644 --- a/src/tests/fakes/fake_input.rs +++ b/src/tests/fakes/fake_input.rs @@ -13,7 +13,7 @@ use ::termion::event::Event; use crate::{ network::{ dns::{self, Lookup}, - Connection, Protocol, + Connection, Protocol, LocalSocket }, os::OnSigWinch, }; @@ -85,7 +85,7 @@ impl DataLinkReceiver for NetworkFrames { } } -pub fn get_open_sockets() -> HashMap<Connection, String> { +pub fn get_open_sockets() -> (HashMap<LocalSocket, String>, std::vec::Vec<Connection>) { let mut open_sockets = HashMap::new(); let local_ip = IpAddr::V4(Ipv4Addr::new(10, 0, 0, 2)); open_sockets.insert( @@ -138,7 +138,14 @@ pub fn get_open_sockets() -> HashMap<Connection, String> { .unwrap(), String::from("3"), ); - open_sockets + let mut local_socket_to_procs = HashMap::new(); + let mut connections = std::vec::Vec::new(); + for (connection, process_name) in open_sockets { + local_socket_to_procs.insert(connection.local_socket, process_name); + connections.push(connection); + } + + (local_socket_to_procs, connections) } pub fn get_interfaces() -> Vec<NetworkInterface> { |