mirror of
https://github.com/GyulyVGC/sniffnet.git
synced 2025-12-23 22:29:01 -05:00
don't reset dropped_packets in the interval with no exchanged data
This commit is contained in:
@@ -432,7 +432,7 @@ fn maybe_send_tick_run_live(
|
||||
first_packet_ticks.and_then(|i| i.checked_add(Duration::from_millis(1000)));
|
||||
let _ = tx.send_blocking(BackendTrafficMessage::TickRun(
|
||||
cap_id,
|
||||
info_traffic_msg.take_but_leave_timestamp(),
|
||||
info_traffic_msg.take_but_leave_something(),
|
||||
new_hosts_to_send.lock().unwrap().drain(..).collect(),
|
||||
false,
|
||||
));
|
||||
@@ -460,7 +460,7 @@ fn maybe_send_tick_run_offline(
|
||||
next_packet_timestamp.secs() - info_traffic_msg.last_packet_timestamp.secs();
|
||||
let _ = tx.send_blocking(BackendTrafficMessage::TickRun(
|
||||
cap_id,
|
||||
info_traffic_msg.take_but_leave_timestamp(),
|
||||
info_traffic_msg.take_but_leave_something(),
|
||||
new_hosts_to_send.lock().unwrap().drain(..).collect(),
|
||||
false,
|
||||
));
|
||||
|
||||
@@ -158,9 +158,10 @@ pub fn add_packet(&mut self, bytes: u128, traffic_direction: TrafficDirection) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn take_but_leave_timestamp(&mut self) -> Self {
|
||||
pub fn take_but_leave_something(&mut self) -> Self {
|
||||
let info_traffic = Self {
|
||||
last_packet_timestamp: self.last_packet_timestamp,
|
||||
dropped_packets: self.dropped_packets,
|
||||
..Self::default()
|
||||
};
|
||||
std::mem::replace(self, info_traffic)
|
||||
|
||||
Reference in New Issue
Block a user