diff --git a/src/gui/pages/inspect_page.rs b/src/gui/pages/inspect_page.rs index 3cd7db10..d2bfcac4 100644 --- a/src/gui/pages/inspect_page.rs +++ b/src/gui/pages/inspect_page.rs @@ -131,13 +131,9 @@ fn lazy_report(sniffer: &Sniffer) -> Container<'static, Message, Renderer InfoAddressPortPair { let now = Local::now(); let mut traffic_direction = TrafficDirection::default(); - let source_ip = &key.address1; - let destination_ip = &key.address2; - let very_long_address = source_ip.len() > 25 || destination_ip.len() > 25; if !info_traffic_mutex.lock().unwrap().map.contains_key(key) { // first occurrence of key @@ -188,6 +185,8 @@ pub fn modify_or_insert_in_map( } } // determine traffic direction + let source_ip = &key.address1; + let destination_ip = &key.address2; traffic_direction = get_traffic_direction(source_ip, destination_ip, &my_interface_addresses); }; @@ -212,7 +211,6 @@ pub fn modify_or_insert_in_map( initial_timestamp: now, final_timestamp: now, app_protocol: application_protocol, - very_long_address, traffic_direction, }) .clone(); diff --git a/src/networking/types/address_port_pair.rs b/src/networking/types/address_port_pair.rs index 6bb0f850..9e8f9549 100644 --- a/src/networking/types/address_port_pair.rs +++ b/src/networking/types/address_port_pair.rs @@ -42,10 +42,6 @@ impl AddressPortPair { trans_protocol, } } - - pub fn print_gui(&self) -> String { - self.to_string().replace('|', "") - } } impl fmt::Display for AddressPortPair { @@ -53,13 +49,13 @@ impl fmt::Display for AddressPortPair { if self.address1.len() > 25 || self.address2.len() > 25 { write!( f, - "|{:^45}|{:>8} |{:^45}|{:>8} | {} |", + "{:^45}{:>8} {:^45}{:>8} {} ", self.address1, self.port1, self.address2, self.port2, self.trans_protocol ) } else { write!( f, - "|{:^25}|{:>8} |{:^25}|{:>8} | {} |", + "{:^25}{:>8} {:^25}{:>8} {} ", self.address1, self.port1, self.address2, self.port2, self.trans_protocol ) } diff --git a/src/networking/types/info_address_port_pair.rs b/src/networking/types/info_address_port_pair.rs index 62deb394..ef7ad120 100644 --- a/src/networking/types/info_address_port_pair.rs +++ b/src/networking/types/info_address_port_pair.rs @@ -26,10 +26,8 @@ pub struct InfoAddressPortPair { pub initial_timestamp: DateTime, /// Last occurrence of information exchange featuring the associate address:port pair as a source or destination. pub final_timestamp: DateTime, - /// Set of application layer protocols carried by the associated address:port pair. + /// Application layer protocol carried by the associated address:port pair. pub app_protocol: AppProtocol, - /// Check if source or destination is an IPv6 address longer than 25 bytes (used for layout) - pub very_long_address: bool, /// Determines if the connection is incoming or outgoing pub traffic_direction: TrafficDirection, } @@ -44,22 +42,11 @@ impl Default for InfoAddressPortPair { initial_timestamp: DateTime::default(), final_timestamp: DateTime::default(), app_protocol: AppProtocol::Other, - very_long_address: false, traffic_direction: TrafficDirection::default(), } } } -impl InfoAddressPortPair { - pub fn print_gui(&self) -> String { - self.to_string() - .get(0..35) - .unwrap() - .to_string() - .replace('|', "") - } -} - impl fmt::Display for InfoAddressPortPair { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let bytes_string = get_formatted_bytes_string(self.transmitted_bytes); @@ -69,27 +56,10 @@ impl fmt::Display for InfoAddressPortPair { _ => self.app_protocol.to_string(), }; - if self.very_long_address { - write!( - f, - "{:^9}|{:>10} |{:>9} | {} | {} |", - app_string, - self.transmitted_packets, - bytes_string, - self.initial_timestamp.to_string().get(0..19).unwrap(), - self.final_timestamp.to_string().get(0..19).unwrap() - ) - } else { - write!( - f, - "{:^9}|{:>10} |{:>9} | {} | {} |{}", - app_string, - self.transmitted_packets, - bytes_string, - self.initial_timestamp.to_string().get(0..19).unwrap(), - self.final_timestamp.to_string().get(0..19).unwrap(), - " ".repeat(40) - ) - } + write!( + f, + "{:^9}{:>10} {:>9} ", + app_string, self.transmitted_packets, bytes_string, + ) } }