diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c8b4e317..38e910f89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## Added * CI: include generated assets in release archive #359 - @cyqsimon +* Add PID column to the process table #379 - @notjedi ## Changed * CI: strip release binaries for all targets #358 - @cyqsimon diff --git a/src/display/components/table.rs b/src/display/components/table.rs index 59193a02f..0f1e7fd9a 100644 --- a/src/display/components/table.rs +++ b/src/display/components/table.rs @@ -28,7 +28,10 @@ pub enum DisplayLayout { C2([u16; 2]), /// Show 3 columns. C3([u16; 3]), + /// Show 4 columns. + C4([u16; 4]), } + impl Index for DisplayLayout { type Output = u16; @@ -36,28 +39,35 @@ impl Index for DisplayLayout { match self { Self::C2(arr) => &arr[i], Self::C3(arr) => &arr[i], + Self::C4(arr) => &arr[i], } } } + impl DisplayLayout { #[inline] fn columns_count(&self) -> usize { match self { Self::C2(_) => 2, Self::C3(_) => 3, + Self::C4(_) => 4, } } + #[inline] fn iter(&self) -> impl Iterator { match self { Self::C2(ws) => ws.iter(), Self::C3(ws) => ws.iter(), + Self::C4(ws) => ws.iter(), } } + #[inline] fn widths_sum(&self) -> u16 { self.iter().sum() } + /// Returns the computed actual width and the spacer width. /// /// See [`Table`] for layout rules. @@ -87,6 +97,17 @@ impl DisplayLayout { let w2_new = (w2 as f64 * m).trunc() as u16; Self::C3([available_without_spacers - w1_new - w2_new, w1_new, w2_new]) } + Self::C4([_w0, w1, w2, w3]) => { + let w1_new = (w1 as f64 * m).trunc() as u16; + let w2_new = (w2 as f64 * m).trunc() as u16; + let w3_new = (w3 as f64 * m).trunc() as u16; + Self::C4([ + available_without_spacers - w1_new - w2_new - w3_new, + w1_new, + w2_new, + w3_new, + ]) + } }; (computed, spacer) @@ -101,26 +122,41 @@ impl DisplayLayout { enum TableData { /// A table with 3 columns. C3(NColsTableData<3>), + /// A table with 4 columns. + C4(NColsTableData<4>), } + impl From> for TableData { fn from(data: NColsTableData<3>) -> Self { Self::C3(data) } } + +impl From> for TableData { + fn from(data: NColsTableData<4>) -> Self { + Self::C4(data) + } +} + impl TableData { fn column_names(&self) -> &[&str] { match self { Self::C3(inner) => &inner.column_names, + Self::C4(inner) => &inner.column_names, } } + fn rows(&self) -> Vec<&[String]> { match self { Self::C3(inner) => inner.rows.iter().map(|r| r.as_slice()).collect(), + Self::C4(inner) => inner.rows.iter().map(|r| r.as_slice()).collect(), } } + fn column_selector(&self) -> &dyn Fn(&DisplayLayout) -> Vec { match self { Self::C3(inner) => inner.column_selector.as_ref(), + Self::C4(inner) => inner.column_selector.as_ref(), } } } @@ -171,6 +207,7 @@ pub struct Table { width_cutoffs: Vec<(u16, DisplayLayout)>, data: TableData, } + impl Table { pub fn create_connections_table(state: &UIState, ip_to_host: &HashMap) -> Self { use DisplayLayout as D; @@ -214,6 +251,7 @@ impl Table { let column_selector = Rc::new(|layout: &D| match layout { D::C2(_) => vec![0, 2], D::C3(_) => vec![0, 1, 2], + D::C4(_) => unreachable!(), }); Table { @@ -236,11 +274,12 @@ impl Table { (0, D::C2([16, 18])), (50, D::C3([16, 12, 20])), (60, D::C3([24, 12, 20])), - (80, D::C3([36, 16, 24])), + (80, D::C4([28, 12, 12, 24])), ]; let column_names = [ "Process", + "PID", "Connections", if state.cumulative_mode { "Data (Up / Down)" @@ -251,9 +290,10 @@ impl Table { let rows = state .processes .iter() - .map(|(process_name, data_for_process)| { + .map(|(proc_info, data_for_process)| { [ - (*process_name).to_string(), + proc_info.name.to_string(), + proc_info.pid.to_string(), data_for_process.connection_count.to_string(), display_upload_and_download( data_for_process, @@ -264,8 +304,9 @@ impl Table { }) .collect(); let column_selector = Rc::new(|layout: &D| match layout { - D::C2(_) => vec![0, 2], - D::C3(_) => vec![0, 1, 2], + D::C2(_) => vec![0, 3], + D::C3(_) => vec![0, 2, 3], + D::C4(_) => vec![0, 1, 2, 3], }); Table { @@ -322,6 +363,7 @@ impl Table { let column_selector = Rc::new(|layout: &D| match layout { D::C2(_) => vec![0, 2], D::C3(_) => vec![0, 1, 2], + D::C4(_) => unreachable!(), }); Table { diff --git a/src/display/ui.rs b/src/display/ui.rs index 4a2866e81..e9df82d16 100644 --- a/src/display/ui.rs +++ b/src/display/ui.rs @@ -10,6 +10,7 @@ use crate::{ UIState, }, network::{display_connection_string, display_ip_or_host, LocalSocket, Utilization}, + os::ProcessInfo, }; pub struct Ui @@ -53,9 +54,10 @@ where let output_process_data = |write_to_stdout: &mut (dyn FnMut(String) + Send), no_traffic: &mut bool| { - for (process, process_network_data) in &state.processes { + for (proc_info, process_network_data) in &state.processes { write_to_stdout(format!( - "process: <{timestamp}> \"{process}\" up/down Bps: {}/{} connections: {}", + "process: <{timestamp}> \"{}\" up/down Bps: {}/{} connections: {}", + proc_info.name, process_network_data.total_bytes_uploaded, process_network_data.total_bytes_downloaded, process_network_data.connection_count @@ -173,7 +175,7 @@ where pub fn update_state( &mut self, - connections_to_procs: HashMap, + connections_to_procs: HashMap, utilization: Utilization, ip_to_host: HashMap, ) { diff --git a/src/display/ui_state.rs b/src/display/ui_state.rs index 8b73571c7..20085d07c 100644 --- a/src/display/ui_state.rs +++ b/src/display/ui_state.rs @@ -9,6 +9,7 @@ use crate::{ display::BandwidthUnitFamily, mt_log, network::{Connection, LocalSocket, Utilization}, + os::ProcessInfo, }; static RECALL_LENGTH: usize = 5; @@ -72,7 +73,7 @@ impl Bandwidth for ConnectionData { } pub struct UtilizationData { - connections_to_procs: HashMap, + connections_to_procs: HashMap, network_utilization: Utilization, } @@ -80,7 +81,7 @@ pub struct UtilizationData { pub struct UIState { /// The interface name in single-interface mode. `None` means all interfaces. pub interface_name: Option, - pub processes: Vec<(String, NetworkData)>, + pub processes: Vec<(ProcessInfo, NetworkData)>, pub remote_addresses: Vec<(IpAddr, NetworkData)>, pub connections: Vec<(Connection, ConnectionData)>, pub total_bytes_downloaded: u128, @@ -88,7 +89,7 @@ pub struct UIState { pub cumulative_mode: bool, pub unit_family: BandwidthUnitFamily, pub utilization_data: VecDeque, - pub processes_map: HashMap, + pub processes_map: HashMap, pub remote_addresses_map: HashMap, pub connections_map: HashMap, /// Used for reducing logging noise. @@ -98,7 +99,7 @@ pub struct UIState { impl UIState { pub fn update( &mut self, - connections_to_procs: HashMap, + connections_to_procs: HashMap, network_utilization: Utilization, ) { self.utilization_data.push_back(UtilizationData { @@ -108,7 +109,7 @@ impl UIState { if self.utilization_data.len() > RECALL_LENGTH { self.utilization_data.pop_front(); } - let mut processes: HashMap = HashMap::new(); + let mut processes: HashMap = HashMap::new(); let mut remote_addresses: HashMap = HashMap::new(); let mut connections: HashMap = HashMap::new(); let mut total_bytes_downloaded: u128 = 0; @@ -140,11 +141,10 @@ impl UIState { let data_for_process = { let local_socket = connection.local_socket; - let process_name = get_proc_name(connections_to_procs, &local_socket); + let proc_info = get_proc_info(connections_to_procs, &local_socket); // only log each orphan connection once - if process_name.is_none() && !self.known_orphan_sockets.contains(&local_socket) - { + if proc_info.is_none() && !self.known_orphan_sockets.contains(&local_socket) { // newer connections go in the front so that searches are faster // basically recency bias self.known_orphan_sockets.push_front(local_socket); @@ -155,17 +155,18 @@ impl UIState { .find(|(&LocalSocket { port, protocol, .. }, _)| { port == local_socket.port && protocol == local_socket.protocol }) - .and_then(|(local_conn_lookalike, name)| { + .and_then(|(local_conn_lookalike, info)| { network_utilization .connections .keys() .find(|conn| &conn.local_socket == local_conn_lookalike) - .map(|conn| (conn, name)) + .map(|conn| (conn, info)) }) { - Some((lookalike, name)) => { + Some((lookalike, proc_info)) => { mt_log!( warn, - r#""{name}" owns a similar looking connection, but its local ip doesn't match."# + r#""{0}" owns a similar looking connection, but its local ip doesn't match."#, + proc_info.name ); mt_log!(warn, "Looking for: {connection:?}; found: {lookalike:?}"); } @@ -175,9 +176,11 @@ impl UIState { }; } - let process_display_name = process_name.unwrap_or("").to_owned(); - connection_data.process_name = process_display_name.clone(); - processes.entry(process_display_name).or_default() + let proc_info = proc_info + .cloned() + .unwrap_or_else(|| ProcessInfo::new("", 0)); + connection_data.process_name = proc_info.name.clone(); + processes.entry(proc_info).or_default() }; data_for_process.total_bytes_downloaded += connection_info.total_bytes_downloaded; @@ -221,10 +224,10 @@ impl UIState { } } -fn get_proc_name<'a>( - connections_to_procs: &'a HashMap, +fn get_proc_info<'a>( + connections_to_procs: &'a HashMap, local_socket: &LocalSocket, -) -> Option<&'a str> { +) -> Option<&'a ProcessInfo> { connections_to_procs // direct match .get(local_socket) @@ -252,7 +255,6 @@ fn get_proc_name<'a>( ..*local_socket }) }) - .map(String::as_str) } fn merge_bandwidth(self_map: &mut HashMap, other_map: HashMap) diff --git a/src/main.rs b/src/main.rs index a6a00d973..756e46d4e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -34,6 +34,7 @@ use ratatui::backend::{Backend, CrosstermBackend}; use simplelog::WriteLogger; use crate::cli::Opt; +use crate::os::ProcessInfo; const DISPLAY_DELTA: Duration = Duration::from_millis(1000); @@ -89,7 +90,7 @@ fn main() -> anyhow::Result<()> { } pub struct OpenSockets { - sockets_to_procs: HashMap, + sockets_to_procs: HashMap, } pub struct OsInputOutput { diff --git a/src/os/linux.rs b/src/os/linux.rs index d1813ab6f..fdd5ec181 100644 --- a/src/os/linux.rs +++ b/src/os/linux.rs @@ -4,6 +4,7 @@ use procfs::process::FDTarget; use crate::{ network::{LocalSocket, Protocol}, + os::ProcessInfo, OpenSockets, }; @@ -15,10 +16,11 @@ pub(crate) fn get_open_sockets() -> OpenSockets { for process in all_procs.filter_map(|res| res.ok()) { let Ok(fds) = process.fd() else { continue }; let Ok(stat) = process.stat() else { continue }; - let procname = stat.comm; + let proc_name = stat.comm; + let proc_info = ProcessInfo::new(&proc_name, stat.pid as u32); for fd in fds.filter_map(|res| res.ok()) { if let FDTarget::Socket(inode) = fd.target { - inode_to_procname.insert(inode, procname.clone()); + inode_to_procname.insert(inode, proc_info.clone()); } } } @@ -29,14 +31,14 @@ pub(crate) fn get_open_sockets() -> OpenSockets { tcp.append(&mut tcp6); } for entry in tcp.into_iter() { - if let Some(procname) = inode_to_procname.get(&entry.inode) { + if let Some(proc_info) = inode_to_procname.get(&entry.inode) { open_sockets.insert( LocalSocket { ip: entry.local_address.ip(), port: entry.local_address.port(), protocol: Protocol::Tcp, }, - procname.clone(), + proc_info.clone(), ); }; } @@ -47,14 +49,14 @@ pub(crate) fn get_open_sockets() -> OpenSockets { udp.append(&mut udp6); } for entry in udp.into_iter() { - if let Some(procname) = inode_to_procname.get(&entry.inode) { + if let Some(proc_info) = inode_to_procname.get(&entry.inode) { open_sockets.insert( LocalSocket { ip: entry.local_address.ip(), port: entry.local_address.port(), protocol: Protocol::Udp, }, - procname.clone(), + proc_info.clone(), ); }; } diff --git a/src/os/lsof.rs b/src/os/lsof.rs index 088d9cfd4..aec444d9f 100644 --- a/src/os/lsof.rs +++ b/src/os/lsof.rs @@ -2,7 +2,7 @@ use crate::{os::lsof_utils::get_connections, OpenSockets}; pub(crate) fn get_open_sockets() -> OpenSockets { let sockets_to_procs = get_connections() - .filter_map(|raw| raw.as_local_socket().map(|s| (s, raw.process_name))) + .filter_map(|raw| raw.as_local_socket().map(|s| (s, raw.proc_info))) .collect(); OpenSockets { sockets_to_procs } diff --git a/src/os/lsof_utils.rs b/src/os/lsof_utils.rs index ad441e773..6fd61f881 100644 --- a/src/os/lsof_utils.rs +++ b/src/os/lsof_utils.rs @@ -6,6 +6,7 @@ use regex::Regex; use crate::{ mt_log, network::{LocalSocket, Protocol}, + os::ProcessInfo, }; #[allow(dead_code)] @@ -16,7 +17,7 @@ pub struct RawConnection { local_port: String, remote_port: String, protocol: String, - pub process_name: String, + pub proc_info: ProcessInfo, } fn get_null_addr(ip_type: &str) -> &str { @@ -36,8 +37,9 @@ impl RawConnection { return None; } let process_name = columns[0].replace("\\x20", " "); + let pid = columns[1].parse().ok()?; + let proc_info = ProcessInfo::new(&process_name, pid); // Unneeded - // let pid = columns[1]; // let username = columns[2]; // let fd = columns[3]; @@ -74,7 +76,7 @@ impl RawConnection { remote_ip, remote_port, protocol, - process_name, + proc_info, }; Some(connection) } else if let Some(caps) = LISTEN_REGEX.captures(connection_str) { @@ -97,7 +99,7 @@ impl RawConnection { remote_ip, remote_port, protocol, - process_name, + proc_info, }; Some(connection) } else { @@ -118,7 +120,7 @@ impl RawConnection { } pub fn as_local_socket(&self) -> Option { - let process = &self.process_name; + let process = &self.proc_info.name; let Some(ip) = self.get_local_ip() else { mt_log!( @@ -259,6 +261,6 @@ com.apple 590 etoledom 204u IPv4 0x28ffb9c04111253f 0t0 TCP 192.168.1. } fn test_raw_connection_parse_process_name(raw_line: &str) { let connection = RawConnection::new(raw_line).unwrap(); - assert_eq!(connection.process_name, String::from("ProcessName")); + assert_eq!(connection.proc_info.name, String::from("ProcessName")); } } diff --git a/src/os/shared.rs b/src/os/shared.rs index ed9787811..d8dd477fb 100644 --- a/src/os/shared.rs +++ b/src/os/shared.rs @@ -19,6 +19,21 @@ use crate::os::lsof::get_open_sockets; #[cfg(target_os = "windows")] use crate::os::windows::get_open_sockets; +#[derive(Clone, Debug, Default, Hash, PartialEq, Eq)] +pub struct ProcessInfo { + pub name: String, + pub pid: u32, +} + +impl ProcessInfo { + pub fn new(name: &str, pid: u32) -> Self { + Self { + name: name.to_string(), + pid, + } + } +} + pub struct TerminalEvents; impl Iterator for TerminalEvents { diff --git a/src/os/windows.rs b/src/os/windows.rs index a0d78234a..620a4bad3 100644 --- a/src/os/windows.rs +++ b/src/os/windows.rs @@ -5,6 +5,7 @@ use sysinfo::{Pid, System}; use crate::{ network::{LocalSocket, Protocol}, + os::ProcessInfo, OpenSockets, }; @@ -20,13 +21,12 @@ pub(crate) fn get_open_sockets() -> OpenSockets { if let Ok(sockets_info) = sockets_info { for si in sockets_info { - let mut procname = String::new(); - for pid in si.associated_pids { - if let Some(process) = sysinfo.process(Pid::from_u32(pid)) { - procname = String::from(process.name()); - break; - } - } + let proc_info = si + .associated_pids + .into_iter() + .find_map(|pid| sysinfo.process(Pid::from_u32(pid))) + .map(|p| ProcessInfo::new(p.name(), p.pid().as_u32())) + .unwrap_or_default(); match si.protocol_socket_info { ProtocolSocketInfo::Tcp(tcp_si) => { @@ -36,7 +36,7 @@ pub(crate) fn get_open_sockets() -> OpenSockets { port: tcp_si.local_port, protocol: Protocol::Tcp, }, - procname, + proc_info, ); } ProtocolSocketInfo::Udp(udp_si) => { @@ -46,7 +46,7 @@ pub(crate) fn get_open_sockets() -> OpenSockets { port: udp_si.local_port, protocol: Protocol::Udp, }, - procname, + proc_info, ); } } diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__basic_only_processes.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__basic_only_processes.snap index 1910f6acb..7eebb2f89 100644 --- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__basic_only_processes.snap +++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__basic_only_processes.snap @@ -4,7 +4,7 @@ expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR --- IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B ┌Utilization by process name─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ -│Process Connections Rate (Up / Down) │ +│Process PID Connections Rate (Up / Down) │ │ │ │ │ │ │ @@ -51,5 +51,4 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B │ │ │ │ └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ - Press to pause. Use to rearrange tables. (DNS queries hidden). - + Press to pause. Use to rearrange tables. (DNS queries hidden). diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__basic_processes_with_dns_queries.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__basic_processes_with_dns_queries.snap index 7fea4345a..952d8feda 100644 --- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__basic_processes_with_dns_queries.snap +++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__basic_processes_with_dns_queries.snap @@ -4,7 +4,7 @@ expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR --- IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B ┌Utilization by process name─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ -│Process Connections Rate (Up / Down) │ +│Process PID Connections Rate (Up / Down) │ │ │ │ │ │ │ @@ -51,5 +51,4 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B │ │ │ │ └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ - Press to pause. Use to rearrange tables. (DNS queries shown). - + Press to pause. Use to rearrange tables. (DNS queries shown). diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__basic_startup.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__basic_startup.snap index f8c72d422..c34cf3b41 100644 --- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__basic_startup.snap +++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__basic_startup.snap @@ -4,7 +4,7 @@ expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR --- IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B ┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐ -│Process Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ +│Process PID Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ │ ││ │ │ ││ │ │ ││ │ @@ -51,5 +51,4 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B │ │ │ │ └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ - Press to pause. Use to rearrange tables. (DNS queries hidden). - + Press to pause. Use to rearrange tables. (DNS queries hidden). diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__bi_directional_traffic.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__bi_directional_traffic.snap index 68295bf09..426ac0893 100644 --- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__bi_directional_traffic.snap +++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__bi_directional_traffic.snap @@ -4,7 +4,7 @@ expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR --- IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B ┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐ -│Process Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ +│Process PID Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ │ ││ │ │ ││ │ │ ││ │ @@ -57,7 +57,7 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B 24. 0B / 25.00B - 1 1 24.00B / 25.00B 1.1.1.1 1 24.00B / 25.00B + 1 1 1 24.00B / 25.00B 1.1.1.1 1 24.00B / 25.00B @@ -81,27 +81,4 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B - :443 => 1.1.1.1:12345 (tcp) 1 24.00B / 25.00B - - - - - - - - - - - - - - - - - - - - - - - + :443 => 1.1.1.1:12345 (tcp) 1 24.00B / 25.00B diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout-full-width-under-30-height-draw_events.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout-full-width-under-30-height-draw_events.snap index 809920d5a..f2a0e8a71 100644 --- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout-full-width-under-30-height-draw_events.snap +++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout-full-width-under-30-height-draw_events.snap @@ -4,7 +4,7 @@ expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR --- IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B ┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐ -│Process Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ +│Process PID Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ │ ││ │ │ ││ │ │ ││ │ @@ -36,30 +36,7 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B 98. 0B - 5 1 0.00B / 28.00B 3.3.3.3 1 0.00B / 28.00B - 4 1 0.00B / 26.00B 2.2.2.2 1 0.00B / 26.00B - 1 1 0.00B / 22.00B 1.1.1.1 1 0.00B / 22.00B - 2 1 0.00B / 21.00B 4.4.4.4 1 0.00B / 21.00B - - - - - - - - - - - - - - - - - - - - - - - + 5 5 1 0.00B / 28.00B 3.3.3.3 1 0.00B / 28.00B + 4 4 1 0.00B / 26.00B 2.2.2.2 1 0.00B / 26.00B + 1 1 1 0.00B / 22.00B 1.1.1.1 1 0.00B / 22.00B + 2 2 1 0.00B / 21.00B 4.4.4.4 1 0.00B / 21.00B diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout-under-120-width-full-height-draw_events.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout-under-120-width-full-height-draw_events.snap index 9a49d509f..d90273554 100644 --- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout-under-120-width-full-height-draw_events.snap +++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout-under-120-width-full-height-draw_events.snap @@ -4,7 +4,7 @@ expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR --- IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B ┌Utilization by process name──────────────────────────────────────────────────────────────────────────────────────────┐ -│Process Connections Rate (Up / Down) │ +│Process PID Connections Rate (Up / Down) │ │ │ │ │ │ │ @@ -57,10 +57,10 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B 98. 0B - 5 1 0.00B / 28.00B - 4 1 0.00B / 26.00B - 1 1 0.00B / 22.00B - 2 1 0.00B / 21.00B + 5 5 1 0.00B / 28.00B + 4 4 1 0.00B / 26.00B + 1 1 1 0.00B / 22.00B + 2 2 1 0.00B / 21.00B @@ -84,24 +84,4 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B 3.3.3.3 1 0.00B / 28.00B 2.2.2.2 1 0.00B / 26.00B 1.1.1.1 1 0.00B / 22.00B - 4.4.4.4 1 0.00B / 21.00B - - - - - - - - - - - - - - - - - - - - + 4.4.4.4 1 0.00B / 21.00B diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout-under-120-width-under-30-height-draw_events.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout-under-120-width-under-30-height-draw_events.snap index bbd632605..f978b860c 100644 --- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout-under-120-width-under-30-height-draw_events.snap +++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout-under-120-width-under-30-height-draw_events.snap @@ -4,7 +4,7 @@ expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR --- IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B ┌Utilization by process name──────────────────────────────────────────────────────────────────────────────────────────┐ -│Process Connections Rate (Up / Down) │ +│Process PID Connections Rate (Up / Down) │ │ │ │ │ │ │ @@ -36,30 +36,7 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B 98. 0B - 5 1 0.00B / 28.00B - 4 1 0.00B / 26.00B - 1 1 0.00B / 22.00B - 2 1 0.00B / 21.00B - - - - - - - - - - - - - - - - - - - - - - - + 5 5 1 0.00B / 28.00B + 4 4 1 0.00B / 26.00B + 1 1 1 0.00B / 22.00B + 2 2 1 0.00B / 21.00B diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout-under-50-width-under-50-height-draw_events.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout-under-50-width-under-50-height-draw_events.snap index 39c158ea9..75a73641d 100644 --- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout-under-50-width-under-50-height-draw_events.snap +++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout-under-50-width-under-50-height-draw_events.snap @@ -84,24 +84,4 @@ IF: interface_name | Total Rate (Up / Down): 0.00B 3.3.3.3 0.00B / 28.00B 2.2.2.2 0.00B / 26.00B 1.1.1.1 0.00B / 22.00B - 4.4.4.4 0.00B / 21.00B - - - - - - - - - - - - - - - - - - - - + 4.4.4.4 0.00B / 21.00B diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout-under-70-width-under-30-height-draw_events.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout-under-70-width-under-30-height-draw_events.snap index 7f384709a..5614e7e78 100644 --- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout-under-70-width-under-30-height-draw_events.snap +++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout-under-70-width-under-30-height-draw_events.snap @@ -39,27 +39,4 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B 5 1 0.00B / 28.00B 4 1 0.00B / 26.00B 1 1 0.00B / 22.00B - 2 1 0.00B / 21.00B - - - - - - - - - - - - - - - - - - - - - - - + 2 1 0.00B / 21.00B diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__multiple_connections_from_remote_address.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__multiple_connections_from_remote_address.snap index 93a42d324..6adaa9995 100644 --- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__multiple_connections_from_remote_address.snap +++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__multiple_connections_from_remote_address.snap @@ -4,7 +4,7 @@ expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR --- IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B ┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐ -│Process Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ +│Process PID Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ │ ││ │ │ ││ │ │ ││ │ @@ -57,7 +57,7 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B 47. 0B - 1 2 0.00B / 47.00B 1.1.1.1 2 0.00B / 47.00B + 1 1 2 0.00B / 47.00B 1.1.1.1 2 0.00B / 47.00B @@ -82,26 +82,4 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B :443 => 1.1.1.1:12346 (tcp) 1 0.00B / 25.00B - :443 => 1.1.1.1:12345 (tcp) 1 0.00B / 22.00B - - - - - - - - - - - - - - - - - - - - - - + :443 => 1.1.1.1:12345 (tcp) 1 0.00B / 22.00B diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__multiple_packets_of_traffic_from_different_connections.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__multiple_packets_of_traffic_from_different_connections.snap index 7a833b103..66aac1421 100644 --- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__multiple_packets_of_traffic_from_different_connections.snap +++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__multiple_packets_of_traffic_from_different_connections.snap @@ -4,7 +4,7 @@ expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR --- IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B ┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐ -│Process Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ +│Process PID Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ │ ││ │ │ ││ │ │ ││ │ @@ -57,8 +57,8 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B 41. 0B - 1 1 0.00B / 22.00B 2.2.2.2 2 0.00B / 41.00B - 4 1 0.00B / 19.00B + 1 1 1 0.00B / 22.00B 2.2.2.2 2 0.00B / 41.00B + 4 4 1 0.00B / 19.00B @@ -82,26 +82,4 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B :443 => 2.2.2.2:12345 (tcp) 1 0.00B / 22.00B - :4434 => 2.2.2.2:54321 (tcp) 4 0.00B / 19.00B - - - - - - - - - - - - - - - - - - - - - - + :4434 => 2.2.2.2:54321 (tcp) 4 0.00B / 19.00B diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__multiple_packets_of_traffic_from_single_connection.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__multiple_packets_of_traffic_from_single_connection.snap index 0b1b04a4b..63f8fd759 100644 --- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__multiple_packets_of_traffic_from_single_connection.snap +++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__multiple_packets_of_traffic_from_single_connection.snap @@ -4,7 +4,7 @@ expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR --- IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B ┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐ -│Process Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ +│Process PID Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ │ ││ │ │ ││ │ │ ││ │ @@ -57,7 +57,7 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B 45. 0B - 1 1 0.00B / 45.00B 1.1.1.1 1 0.00B / 45.00B + 1 1 1 0.00B / 45.00B 1.1.1.1 1 0.00B / 45.00B @@ -81,27 +81,4 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B - :443 => 1.1.1.1:12345 (tcp) 1 0.00B / 45.00B - - - - - - - - - - - - - - - - - - - - - - - + :443 => 1.1.1.1:12345 (tcp) 1 0.00B / 45.00B diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__multiple_processes_with_multiple_connections.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__multiple_processes_with_multiple_connections.snap index 60380206a..233bb7ccf 100644 --- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__multiple_processes_with_multiple_connections.snap +++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__multiple_processes_with_multiple_connections.snap @@ -4,7 +4,7 @@ expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR --- IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B ┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐ -│Process Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ +│Process PID Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ │ ││ │ │ ││ │ │ ││ │ @@ -57,10 +57,10 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B 98. 0B - 5 1 0.00B / 28.00B 3.3.3.3 1 0.00B / 28.00B - 4 1 0.00B / 26.00B 2.2.2.2 1 0.00B / 26.00B - 1 1 0.00B / 22.00B 1.1.1.1 1 0.00B / 22.00B - 2 1 0.00B / 21.00B 4.4.4.4 1 0.00B / 21.00B + 5 5 1 0.00B / 28.00B 3.3.3.3 1 0.00B / 28.00B + 4 4 1 0.00B / 26.00B 2.2.2.2 1 0.00B / 26.00B + 1 1 1 0.00B / 22.00B 1.1.1.1 1 0.00B / 22.00B + 2 2 1 0.00B / 21.00B 4.4.4.4 1 0.00B / 21.00B @@ -84,24 +84,4 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B :4435 => 3.3.3.3:1337 (tcp) 5 0.00B / 28.00B :4434 => 2.2.2.2:54321 (tcp) 4 0.00B / 26.00B :443 => 1.1.1.1:12345 (tcp) 1 0.00B / 22.00B - :4432 => 4.4.4.4:1337 (tcp) 2 0.00B / 21.00B - - - - - - - - - - - - - - - - - - - - + :4432 => 4.4.4.4:1337 (tcp) 2 0.00B / 21.00B diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__no_resolve_mode.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__no_resolve_mode.snap index 4896df3bd..64243ffb4 100644 --- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__no_resolve_mode.snap +++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__no_resolve_mode.snap @@ -4,7 +4,7 @@ expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR --- IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B ┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐ -│Process Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ +│Process PID Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ │ ││ │ │ ││ │ │ ││ │ @@ -57,8 +57,8 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B 45. 0B / 49.00B - 1 1 28.00B / 30.00B 1.1.1.1 1 28.00B / 30.00B - 5 1 17.00B / 18.00B 3.3.3.3 1 17.00B / 18.00B + 1 1 1 28.00B / 30.00B 1.1.1.1 1 28.00B / 30.00B + 5 5 1 17.00B / 18.00B 3.3.3.3 1 17.00B / 18.00B @@ -134,26 +134,4 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B 31 2 - 22 27 - - - - - - - - - - - - - - - - - - - - - - + 22 27 diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__one_packet_of_traffic.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__one_packet_of_traffic.snap index 2554d3866..44a1a6fc8 100644 --- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__one_packet_of_traffic.snap +++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__one_packet_of_traffic.snap @@ -4,7 +4,7 @@ expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR --- IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B ┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐ -│Process Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ +│Process PID Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ │ ││ │ │ ││ │ │ ││ │ @@ -57,7 +57,7 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B 21. 0B / 0. 0B - 1 1 21.00B / 0.00B 1.1.1.1 1 21.00B / 0.00B + 1 1 1 21.00B / 0.00B 1.1.1.1 1 21.00B / 0.00B @@ -81,27 +81,4 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B - :443 => 1.1.1.1:12345 (tcp) 1 21.00B / 0.00B - - - - - - - - - - - - - - - - - - - - - - - + :443 => 1.1.1.1:12345 (tcp) 1 21.00B / 0.00B diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__one_process_with_multiple_connections.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__one_process_with_multiple_connections.snap index 1cb3f7650..8c345bf10 100644 --- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__one_process_with_multiple_connections.snap +++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__one_process_with_multiple_connections.snap @@ -4,7 +4,7 @@ expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR --- IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B ┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐ -│Process Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ +│Process PID Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ │ ││ │ │ ││ │ │ ││ │ @@ -57,7 +57,7 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B 46. 0B - 1 2 0.00B / 46.00B 1.1.1.1 2 0.00B / 46.00B + 1 1 2 0.00B / 46.00B 1.1.1.1 2 0.00B / 46.00B @@ -82,26 +82,4 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B :443 => 1.1.1.1:12346 (tcp) 1 0.00B / 24.00B - :443 => 1.1.1.1:12345 (tcp) 1 0.00B / 22.00B - - - - - - - - - - - - - - - - - - - - - - + :443 => 1.1.1.1:12345 (tcp) 1 0.00B / 22.00B diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__pause_by_space.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__pause_by_space.snap index d03a751dc..a760c9546 100644 --- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__pause_by_space.snap +++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__pause_by_space.snap @@ -4,7 +4,7 @@ expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR --- IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B ┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐ -│Process Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ +│Process PID Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ │ ││ │ │ ││ │ │ ││ │ @@ -106,54 +106,3 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B [PAUSED] resume. Use to rea range tables. (DNS queries hi den). --- SECTION SEPARATOR --- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__rearranged_by_tab.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__rearranged_by_tab.snap index 91ca72dea..73a4a94dc 100644 --- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__rearranged_by_tab.snap +++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__rearranged_by_tab.snap @@ -4,7 +4,7 @@ expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR --- IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B ┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐ -│Process Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ +│Process PID Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ │ ││ │ │ ││ │ │ ││ │ @@ -57,7 +57,7 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B 22. 0B - 1 1 0.00B / 22.00B 1.1.1.1 1 0.00B / 22.00B + 1 1 1 0.00B / 22.00B 1.1.1.1 1 0.00B / 22.00B @@ -108,7 +108,7 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B --- SECTION SEPARATOR --- remote addr ss connection──── - Remote Address Connections Rate (Up / Down) Connection Process Rate (Up / Down) + Remote Address Connecti s Rate (Up / Down) Connection Process Rate (Up / Down) .1.1.1 1 0.00B / 22.00B :443 => 1.1.1.1:12345 (tcp) 1 0 / 22.00B @@ -132,8 +132,8 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B proc ss name - Proc ss Connections Rate (Up / Down) - 1 1 0.00B / 22.00B + Proc ss PID Connections Rate (Up / Down) + 1 1 1 0.00B / 22.00B @@ -237,27 +237,4 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B - 1 - - - - - - - - - - - - - - - - - - - - - - - + 1 diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_multiple_processes.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_multiple_processes.snap index 086588f95..8e9762208 100644 --- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_multiple_processes.snap +++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_multiple_processes.snap @@ -4,7 +4,7 @@ expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR --- IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B ┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐ -│Process Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ +│Process PID Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ │ ││ │ │ ││ │ │ ││ │ @@ -57,8 +57,8 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B 41. 0B - 1 1 0.00B / 22.00B 1.1.1.1 1 0.00B / 22.00B - 5 1 0.00B / 19.00B 3.3.3.3 1 0.00B / 19.00B + 1 1 1 0.00B / 22.00B 1.1.1.1 1 0.00B / 22.00B + 5 5 1 0.00B / 19.00B 3.3.3.3 1 0.00B / 19.00B @@ -134,26 +134,4 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B 35 - 30 - - - - - - - - - - - - - - - - - - - - - - + 30 diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_multiple_processes_bi_directional.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_multiple_processes_bi_directional.snap index 4896df3bd..64243ffb4 100644 --- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_multiple_processes_bi_directional.snap +++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_multiple_processes_bi_directional.snap @@ -4,7 +4,7 @@ expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR --- IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B ┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐ -│Process Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ +│Process PID Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ │ ││ │ │ ││ │ │ ││ │ @@ -57,8 +57,8 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B 45. 0B / 49.00B - 1 1 28.00B / 30.00B 1.1.1.1 1 28.00B / 30.00B - 5 1 17.00B / 18.00B 3.3.3.3 1 17.00B / 18.00B + 1 1 1 28.00B / 30.00B 1.1.1.1 1 28.00B / 30.00B + 5 5 1 17.00B / 18.00B 3.3.3.3 1 17.00B / 18.00B @@ -134,26 +134,4 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B 31 2 - 22 27 - - - - - - - - - - - - - - - - - - - - - - + 22 27 diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_multiple_processes_bi_directional_total.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_multiple_processes_bi_directional_total.snap index 302581394..505f3143c 100644 --- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_multiple_processes_bi_directional_total.snap +++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_multiple_processes_bi_directional_total.snap @@ -4,7 +4,7 @@ expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR --- IF: interface_name | Total Data (Up / Down): 0.00B / 0.00B ┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐ -│Process Connections Data (Up / Down) ││Remote Address Connections Data (Up / Down) │ +│Process PID Connections Data (Up / Down) ││Remote Address Connections Data (Up / Down) │ │ ││ │ │ ││ │ │ ││ │ @@ -57,8 +57,8 @@ IF: interface_name | Total Data (Up / Down): 0.00B / 0.00B 45. 0B / 49.00B - 1 1 28.00B / 30.00B 1.1.1.1 1 28.00B / 30.00B - 5 1 17.00B / 18.00B 3.3.3.3 1 17.00B / 18.00B + 1 1 1 28.00B / 30.00B 1.1.1.1 1 28.00B / 30.00B + 5 5 1 17.00B / 18.00B 3.3.3.3 1 17.00B / 18.00B @@ -134,26 +134,4 @@ IF: interface_name | Total Data (Up / Down): 0.00B / 0.00B 59 62 - 39 45 - - - - - - - - - - - - - - - - - - - - - - + 39 45 diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_multiple_processes_total.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_multiple_processes_total.snap index d427f0fb9..7c703dd75 100644 --- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_multiple_processes_total.snap +++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_multiple_processes_total.snap @@ -4,7 +4,7 @@ expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR --- IF: interface_name | Total Data (Up / Down): 0.00B / 0.00B ┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐ -│Process Connections Data (Up / Down) ││Remote Address Connections Data (Up / Down) │ +│Process PID Connections Data (Up / Down) ││Remote Address Connections Data (Up / Down) │ │ ││ │ │ ││ │ │ ││ │ @@ -57,8 +57,8 @@ IF: interface_name | Total Data (Up / Down): 0.00B / 0.00B 41. 0B - 1 1 0.00B / 22.00B 1.1.1.1 1 0.00B / 22.00B - 5 1 0.00B / 19.00B 3.3.3.3 1 0.00B / 19.00B + 1 1 1 0.00B / 22.00B 1.1.1.1 1 0.00B / 22.00B + 5 5 1 0.00B / 19.00B 3.3.3.3 1 0.00B / 19.00B @@ -134,26 +134,4 @@ IF: interface_name | Total Data (Up / Down): 0.00B / 0.00B 57 - 4 - - - - - - - - - - - - - - - - - - - - - - + 4 diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_one_process.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_one_process.snap index 6aad651b4..c1766b63d 100644 --- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_one_process.snap +++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_one_process.snap @@ -4,7 +4,7 @@ expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR --- IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B ┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐ -│Process Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ +│Process PID Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ │ ││ │ │ ││ │ │ ││ │ @@ -57,7 +57,7 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B 22. 0B - 1 1 0.00B / 22.00B 1.1.1.1 1 0.00B / 22.00B + 1 1 1 0.00B / 22.00B 1.1.1.1 1 0.00B / 22.00B @@ -133,27 +133,4 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B - 31 - - - - - - - - - - - - - - - - - - - - - - - + 31 diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_one_process_total.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_one_process_total.snap index e36f3eea3..764e34257 100644 --- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_one_process_total.snap +++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_one_process_total.snap @@ -4,7 +4,7 @@ expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR --- IF: interface_name | Total Data (Up / Down): 0.00B / 0.00B ┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐ -│Process Connections Data (Up / Down) ││Remote Address Connections Data (Up / Down) │ +│Process PID Connections Data (Up / Down) ││Remote Address Connections Data (Up / Down) │ │ ││ │ │ ││ │ │ ││ │ @@ -57,7 +57,7 @@ IF: interface_name | Total Data (Up / Down): 0.00B / 0.00B 22. 0B - 1 1 0.00B / 22.00B 1.1.1.1 1 0.00B / 22.00B + 1 1 1 0.00B / 22.00B 1.1.1.1 1 0.00B / 22.00B @@ -133,27 +133,4 @@ IF: interface_name | Total Data (Up / Down): 0.00B / 0.00B - 53 - - - - - - - - - - - - - - - - - - - - - - - + 53 diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__traffic_with_host_names.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__traffic_with_host_names.snap index 87aeb6187..dd3d1fa94 100644 --- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__traffic_with_host_names.snap +++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__traffic_with_host_names.snap @@ -4,7 +4,7 @@ expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR --- IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B ┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐ -│Process Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ +│Process PID Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ │ ││ │ │ ││ │ │ ││ │ @@ -57,8 +57,8 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B 45. 0B / 49.00B - 1 1 28.00B / 30.00B 1.1.1.1 1 28.00B / 30.00B - 5 1 17.00B / 18.00B 3.3.3.3 1 17.00B / 18.00B + 1 1 1 28.00B / 30.00B 1.1.1.1 1 28.00B / 30.00B + 5 5 1 17.00B / 18.00B 3.3.3.3 1 17.00B / 18.00B @@ -134,26 +134,4 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B one one.one.one:12345 (tcp) 31 2 - three three.three.three:1337 (tcp) 22 27 - - - - - - - - - - - - - - - - - - - - - - + three three.three.three:1337 (tcp) 22 27 diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__traffic_with_winch_event.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__traffic_with_winch_event.snap index 32d3ec2b6..909ae2f78 100644 --- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__traffic_with_winch_event.snap +++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__traffic_with_winch_event.snap @@ -4,7 +4,7 @@ expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR --- IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B ┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐ -│Process Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ +│Process PID Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ │ ││ │ │ ││ │ │ ││ │ @@ -57,7 +57,7 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B 21. 0B / 0. 0B - 1 1 21.00B / 0.00B 1.1.1.1 1 21.00B / 0.00B + 1 1 1 21.00B / 0.00B 1.1.1.1 1 21.00B / 0.00B @@ -106,54 +106,3 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B --- SECTION SEPARATOR --- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__truncate_long_hostnames.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__truncate_long_hostnames.snap index ad558af20..e56e3e074 100644 --- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__truncate_long_hostnames.snap +++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__truncate_long_hostnames.snap @@ -4,7 +4,7 @@ expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR --- IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B ┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐ -│Process Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ +│Process PID Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │ │ ││ │ │ ││ │ │ ││ │ @@ -57,8 +57,8 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B 45. 0B / 49.00B - 1 1 28.00B / 30.00B 1.1.1.1 1 28.00B / 30.00B - 5 1 17.00B / 18.00B 3.3.3.3 1 17.00B / 18.00B + 1 1 1 28.00B / 30.00B 1.1.1.1 1 28.00B / 30.00B + 5 5 1 17.00B / 18.00B 3.3.3.3 1 17.00B / 18.00B @@ -134,26 +134,4 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B i am.not.too.long:12345 (tcp) 31 2 - i am.an.obnoxiosuly.long.hostname.why.would.anyone.do.this.really.i.ask:1337 (tcp) 22 27 - - - - - - - - - - - - - - - - - - - - - - + i am.an.obnoxiosuly.long.hostname.why.would.anyone.do.this.really.i.ask:1337 (tcp) 22 27 diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__two_packets_only_processes.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__two_packets_only_processes.snap index 9da4d6ee9..a7dccc8f7 100644 --- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__two_packets_only_processes.snap +++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__two_packets_only_processes.snap @@ -4,7 +4,7 @@ expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR --- IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B ┌Utilization by process name─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ -│Process Connections Rate (Up / Down) │ +│Process PID Connections Rate (Up / Down) │ │ │ │ │ │ │ @@ -57,51 +57,4 @@ IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B 24. 0B / 25.00B - 1 1 24.00B / 25.00B - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 1 1 1 24.00B / 25.00B diff --git a/src/tests/fakes/fake_input.rs b/src/tests/fakes/fake_input.rs index 146a85e13..9f2fb8049 100644 --- a/src/tests/fakes/fake_input.rs +++ b/src/tests/fakes/fake_input.rs @@ -16,6 +16,7 @@ use crate::{ dns::{self, Lookup}, Connection, Protocol, }, + os::ProcessInfo, OpenSockets, }; @@ -96,7 +97,7 @@ pub fn get_open_sockets() -> OpenSockets { 443, Protocol::Tcp, ), - String::from("1"), + ProcessInfo::new("1", 1), ); open_sockets.insert( Connection::new( @@ -105,7 +106,7 @@ pub fn get_open_sockets() -> OpenSockets { 4434, Protocol::Tcp, ), - String::from("4"), + ProcessInfo::new("4", 4), ); open_sockets.insert( Connection::new( @@ -114,7 +115,7 @@ pub fn get_open_sockets() -> OpenSockets { 4435, Protocol::Tcp, ), - String::from("5"), + ProcessInfo::new("5", 5), ); open_sockets.insert( Connection::new( @@ -123,7 +124,7 @@ pub fn get_open_sockets() -> OpenSockets { 4432, Protocol::Tcp, ), - String::from("2"), + ProcessInfo::new("2", 2), ); open_sockets.insert( Connection::new( @@ -132,12 +133,12 @@ pub fn get_open_sockets() -> OpenSockets { 443, Protocol::Tcp, ), - String::from("1"), + ProcessInfo::new("1", 1), ); 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); + for (connection, proc_info) in open_sockets { + local_socket_to_procs.insert(connection.local_socket, proc_info); connections.push(connection); }