diff options
author | Kelvin Zhang <zhangxp1998@gmail.com> | 2020-01-12 18:47:31 -0500 |
---|---|---|
committer | Kelvin Zhang <zhangxp1998@gmail.com> | 2020-01-13 15:36:26 -0500 |
commit | a5255332b83642de9d72b59787ce437a3ae1e5f1 (patch) | |
tree | c1f2fb792a730a0868cda89095d43856648caa7b /src/display | |
parent | e6c58c6021ffad2d0af6434e0d4521342a0d4b42 (diff) |
Sniff Ipv6 packets
Diffstat (limited to 'src/display')
-rw-r--r-- | src/display/components/table.rs | 9 | ||||
-rw-r--r-- | src/display/ui.rs | 6 | ||||
-rw-r--r-- | src/display/ui_state.rs | 4 |
3 files changed, 8 insertions, 11 deletions
diff --git a/src/display/components/table.rs b/src/display/components/table.rs index 2b823d7..ff5a148 100644 --- a/src/display/components/table.rs +++ b/src/display/components/table.rs @@ -9,7 +9,7 @@ use ::tui::widgets::{Block, Borders, Row, Widget}; use crate::display::{Bandwidth, DisplayBandwidth, UIState}; use crate::network::{display_connection_string, display_ip_or_host}; -use ::std::net::Ipv4Addr; +use ::std::net::IpAddr; use std::iter::FromIterator; const FIRST_WIDTH_BREAKPOINT: u16 = 50; @@ -54,10 +54,7 @@ pub struct Table<'a> { } impl<'a> Table<'a> { - pub fn create_connections_table( - state: &UIState, - ip_to_host: &HashMap<Ipv4Addr, String>, - ) -> Self { + pub fn create_connections_table(state: &UIState, ip_to_host: &HashMap<IpAddr, String>) -> Self { let mut connections_list = Vec::from_iter(&state.connections); sort_by_bandwidth(&mut connections_list); let connections_rows = connections_list @@ -105,7 +102,7 @@ impl<'a> Table<'a> { } pub fn create_remote_addresses_table( state: &UIState, - ip_to_host: &HashMap<Ipv4Addr, String>, + ip_to_host: &HashMap<IpAddr, String>, ) -> Self { let mut remote_addresses_list = Vec::from_iter(&state.remote_addresses); sort_by_bandwidth(&mut remote_addresses_list); diff --git a/src/display/ui.rs b/src/display/ui.rs index 0c4d36a..2c44d23 100644 --- a/src/display/ui.rs +++ b/src/display/ui.rs @@ -7,7 +7,7 @@ use crate::display::components::{HelpText, Layout, Table, TotalBandwidth}; use crate::display::UIState; use crate::network::{display_connection_string, display_ip_or_host, LocalSocket, Utilization}; -use ::std::net::Ipv4Addr; +use ::std::net::IpAddr; use chrono::prelude::*; @@ -17,7 +17,7 @@ where { terminal: Terminal<B>, state: UIState, - ip_to_host: HashMap<Ipv4Addr, String>, + ip_to_host: HashMap<IpAddr, String>, } impl<B> Ui<B> @@ -101,7 +101,7 @@ where &mut self, connections_to_procs: HashMap<LocalSocket, String>, utilization: Utilization, - ip_to_host: HashMap<Ipv4Addr, String>, + ip_to_host: HashMap<IpAddr, String>, ) { self.state.update(connections_to_procs, utilization); self.ip_to_host.extend(ip_to_host); diff --git a/src/display/ui_state.rs b/src/display/ui_state.rs index 7a22c6d..7e8bb78 100644 --- a/src/display/ui_state.rs +++ b/src/display/ui_state.rs @@ -65,7 +65,7 @@ pub struct UtilizationData { #[derive(Default)] pub struct UIState { pub processes: BTreeMap<String, NetworkData>, - pub remote_addresses: BTreeMap<Ipv4Addr, NetworkData>, + pub remote_addresses: BTreeMap<IpAddr, NetworkData>, pub connections: BTreeMap<Connection, ConnectionData>, pub total_bytes_downloaded: u128, pub total_bytes_uploaded: u128, @@ -106,7 +106,7 @@ impl UIState { self.utilization_data.pop_front(); } let mut processes: BTreeMap<String, NetworkData> = BTreeMap::new(); - let mut remote_addresses: BTreeMap<Ipv4Addr, NetworkData> = BTreeMap::new(); + let mut remote_addresses: BTreeMap<IpAddr, NetworkData> = BTreeMap::new(); let mut connections: BTreeMap<Connection, ConnectionData> = BTreeMap::new(); let mut total_bytes_downloaded: u128 = 0; let mut total_bytes_uploaded: u128 = 0; |