summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorKelvin Zhang <zhangxp1998@gmail.com>2020-01-07 15:08:16 -0500
committerKelvin Zhang <zhangxp1998@gmail.com>2020-01-07 16:40:07 -0500
commit471fd861d5799b14f819e388246bf8a564ca98a6 (patch)
treece1cd5086abbe2de5037270702c7057c769fd850 /src/main.rs
parentcf772acba35467b25ab59fef644199839882bc4a (diff)
Address some comments on PR
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs
index b14227c..9ae11e6 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -79,10 +79,15 @@ fn try_main() -> Result<(), failure::Error> {
Ok(())
}
+pub struct OpenSockets {
+ sockets_to_procs: HashMap<LocalSocket, String>,
+ connections: Vec<Connection>,
+}
+
pub struct OsInputOutput {
pub network_interfaces: Vec<NetworkInterface>,
pub network_frames: Vec<Box<dyn DataLinkReceiver>>,
- pub get_open_sockets: fn() -> (HashMap<LocalSocket, String>, std::vec::Vec<Connection>),
+ pub get_open_sockets: fn() -> OpenSockets,
pub keyboard_events: Box<dyn Iterator<Item = Event> + Send>,
pub dns_client: Option<dns::Client>,
pub on_winch: Box<OnSigWinch>,
@@ -138,7 +143,10 @@ where
while running.load(Ordering::Acquire) {
let render_start_time = Instant::now();
let utilization = { network_utilization.lock().unwrap().clone_and_reset() };
- let (connections_to_procs, connections) = get_open_sockets();
+ let OpenSockets {
+ sockets_to_procs,
+ connections,
+ } = get_open_sockets();
let mut ip_to_host = IpTable::new();
if let Some(dns_client) = dns_client.as_mut() {
ip_to_host = dns_client.cache();
@@ -152,7 +160,7 @@ where
}
{
let mut ui = ui.lock().unwrap();
- ui.update_state(connections_to_procs, utilization, ip_to_host);
+ ui.update_state(sockets_to_procs, utilization, ip_to_host);
if raw_mode {
ui.output_text(&mut write_to_stdout);
} else {