@@ -49,7 +49,7 @@ use crate::networking::types::capture_context::{CaptureContext, CaptureSource, M
4949use crate :: networking:: types:: filters:: Filters ;
5050use crate :: networking:: types:: host:: { Host , HostMessage } ;
5151use crate :: networking:: types:: host_data_states:: HostDataStates ;
52- use crate :: networking:: types:: info_traffic:: InfoTrafficMessage ;
52+ use crate :: networking:: types:: info_traffic:: InfoTraffic ;
5353use crate :: networking:: types:: ip_collection:: AddressCollection ;
5454use crate :: networking:: types:: my_device:: MyDevice ;
5555use crate :: networking:: types:: port_collection:: PortCollection ;
@@ -68,7 +68,7 @@ use crate::utils::check_updates::set_newer_release_status;
6868use crate :: utils:: error_logger:: { ErrorLogger , Location } ;
6969use crate :: utils:: types:: file_info:: FileInfo ;
7070use crate :: utils:: types:: web_page:: WebPage ;
71- use crate :: { ConfigSettings , Configs , InfoTraffic , StyleType , TrafficChart , location} ;
71+ use crate :: { ConfigSettings , Configs , StyleType , TrafficChart , location} ;
7272
7373pub const FONT_FAMILY_NAME : & str = "Sarasa Mono SC for Sniffnet" ;
7474pub const ICON_FONT_FAMILY_NAME : & str = "Icons for Sniffnet" ;
@@ -686,25 +686,23 @@ impl Sniffer {
686686 }
687687 }
688688
689- fn refresh_data ( & mut self , msg : InfoTrafficMessage , no_more_packets : bool ) {
690- self . info_traffic . refresh ( msg, & self . favorite_hosts ) ;
691- self . update_thresholds ( ) ;
692- let info_traffic = & self . info_traffic ;
693- if info_traffic. tot_data_info . tot_packets ( ) == 0 {
694- return ;
695- }
689+ fn refresh_data ( & mut self , msg : InfoTraffic , no_more_packets : bool ) {
690+ self . traffic_chart . update_charts_data ( & msg, no_more_packets) ;
696691 let emitted_notifications = notify_and_log (
697692 & mut self . logged_notifications ,
698693 self . configs . settings . notifications ,
699- info_traffic,
694+ & msg,
695+ & self . favorite_hosts ,
700696 & self . capture_source ,
701697 ) ;
702- self . info_traffic . favorites_last_interval = HashSet :: new ( ) ;
698+ self . info_traffic . refresh ( msg) ;
699+ self . update_thresholds ( ) ;
700+ if self . info_traffic . tot_data_info . tot_packets ( ) == 0 {
701+ return ;
702+ }
703703 if self . thumbnail || self . running_page . ne ( & RunningPage :: Notifications ) {
704704 self . unread_notifications += emitted_notifications;
705705 }
706- self . traffic_chart
707- . update_charts_data ( & self . info_traffic , no_more_packets) ;
708706
709707 if let CaptureSource :: Device ( device) = & self . capture_source {
710708 let current_device_name = device. get_name ( ) . clone ( ) ;
@@ -1117,13 +1115,6 @@ impl Sniffer {
11171115
11181116 // update host data states including the new host
11191117 self . host_data_states . data . update ( & host) ;
1120-
1121- // check if the newly resolved host was featured in the favorites (possible in case of already existing host)
1122- if self . favorite_hosts . contains ( & host) {
1123- self . info_traffic
1124- . favorites_last_interval
1125- . insert ( ( host, data_info_host) ) ;
1126- }
11271118 }
11281119
11291120 fn register_sigint_handler ( ) -> Task < Message > {
@@ -1160,7 +1151,7 @@ mod tests {
11601151 use crate :: gui:: types:: timing_events:: TimingEvents ;
11611152 use crate :: networking:: types:: data_info:: DataInfo ;
11621153 use crate :: networking:: types:: host:: Host ;
1163- use crate :: networking:: types:: info_traffic:: InfoTrafficMessage ;
1154+ use crate :: networking:: types:: info_traffic:: InfoTraffic ;
11641155 use crate :: networking:: types:: traffic_direction:: TrafficDirection ;
11651156 use crate :: notifications:: types:: logged_notification:: {
11661157 DataThresholdExceeded , LoggedNotification ,
@@ -1704,12 +1695,7 @@ mod tests {
17041695 . add_packet ( 0 , TrafficDirection :: Outgoing ) ;
17051696
17061697 // Simulate a tick to apply the settings
1707- sniffer. update ( Message :: TickRun (
1708- 0 ,
1709- InfoTrafficMessage :: default ( ) ,
1710- vec ! [ ] ,
1711- false ,
1712- ) ) ;
1698+ sniffer. update ( Message :: TickRun ( 0 , InfoTraffic :: default ( ) , vec ! [ ] , false ) ) ;
17131699 }
17141700 let mut sniffer = Sniffer :: new ( Configs :: default ( ) ) ;
17151701
@@ -1921,14 +1907,14 @@ mod tests {
19211907 #[ parallel] // needed to not collide with other tests generating configs files
19221908 fn test_clear_all_notifications ( ) {
19231909 let mut sniffer = Sniffer :: new ( Configs :: default ( ) ) ;
1924- sniffer. logged_notifications =
1925- VecDeque :: from ( [ LoggedNotification :: PacketsThresholdExceeded (
1926- DataThresholdExceeded {
1927- threshold : 0 ,
1928- data_info : DataInfo :: default ( ) ,
1929- timestamp : "" . to_string ( ) ,
1930- } ,
1931- ) ] ) ;
1910+ sniffer. logged_notifications = VecDeque :: from ( [ LoggedNotification :: DataThresholdExceeded (
1911+ DataThresholdExceeded {
1912+ chart_type : ChartType :: Packets ,
1913+ threshold : 0 ,
1914+ data_info : DataInfo :: default ( ) ,
1915+ timestamp : "" . to_string ( ) ,
1916+ } ,
1917+ ) ] ) ;
19321918
19331919 assert_eq ! ( sniffer. modal, None ) ;
19341920 sniffer. update ( Message :: ShowModal ( MyModal :: ClearAll ) ) ;
0 commit comments