From 0bf99f786b0a82d6d253bf0e21707351f5743190 Mon Sep 17 00:00:00 2001 From: Giuliano Bellini s294739 Date: Sat, 2 Dec 2023 11:34:23 +0100 Subject: [PATCH] removed file write_report_file.rs --- src/secondary_threads/mod.rs | 1 - src/secondary_threads/write_report_file.rs | 77 ---------------------- 2 files changed, 78 deletions(-) delete mode 100644 src/secondary_threads/write_report_file.rs diff --git a/src/secondary_threads/mod.rs b/src/secondary_threads/mod.rs index 81b03094..abb91ca2 100644 --- a/src/secondary_threads/mod.rs +++ b/src/secondary_threads/mod.rs @@ -1,3 +1,2 @@ pub mod check_updates; pub mod parse_packets; -pub mod write_report_file; diff --git a/src/secondary_threads/write_report_file.rs b/src/secondary_threads/write_report_file.rs deleted file mode 100644 index e65f9bbf..00000000 --- a/src/secondary_threads/write_report_file.rs +++ /dev/null @@ -1,77 +0,0 @@ -// //! Module containing functions executed by the thread in charge of updating the output report every 1 second -// -// use std::collections::HashSet; -// use std::fs::File; -// use std::io::{BufWriter, Seek, SeekFrom, Write}; -// use std::sync::{Arc, Condvar, Mutex}; -// use std::thread; -// use std::time::Duration; -// -// use crate::gui::types::status::Status; -// use crate::utils::formatted_strings::get_default_report_directory; -// use crate::InfoTraffic; -// -// /// The calling thread enters in a loop in which it sleeps for 1 second and then -// /// updates the output report containing detailed traffic information -// pub fn sleep_and_write_report_loop( -// current_capture_id: &Arc>, -// info_traffic_mutex: &Arc>, -// status_pair: &Arc<(Mutex, Condvar)>, -// ) { -// let cvar = &status_pair.1; -// -// let path_report = get_default_report_directory(); -// -// let mut capture_id = *current_capture_id.lock().unwrap(); -// -// let mut output = -// BufWriter::new(File::create(path_report.clone()).expect("Error creating output file\n\r")); -// writeln!(output, "---------------------------------------------------------------------------------------------------------------------------------------------------------------------").expect("Error writing output file\n\r"); -// writeln!(output, "| Src IP address | Src port | Dst IP address | Dst port | Layer 4 | Layer 7 | Packets | Bytes | Initial timestamp | Final timestamp |").expect("Error writing output file\n\r"); -// writeln!(output, "---------------------------------------------------------------------------------------------------------------------------------------------------------------------").expect("Error writing output file\n\r"); -// -// loop { -// // sleep 1 second -// thread::sleep(Duration::from_secs(1)); -// -// let current_capture_id_lock = current_capture_id.lock().unwrap(); -// if *current_capture_id_lock != capture_id { -// capture_id = *current_capture_id_lock; -// output = BufWriter::new( -// File::create(path_report.clone()).expect("Error creating output file\n\r"), -// ); -// writeln!(output, "---------------------------------------------------------------------------------------------------------------------------------------------------------------------").expect("Error writing output file\n\r"); -// writeln!(output, "| Src IP address | Src port | Dst IP address | Dst port | Layer 4 | Layer 7 | Packets | Bytes | Initial timestamp | Final timestamp |").expect("Error writing output file\n\r"); -// writeln!(output, "---------------------------------------------------------------------------------------------------------------------------------------------------------------------").expect("Error writing output file\n\r"); -// } -// drop(current_capture_id_lock); -// -// let mut status = status_pair.0.lock().expect("Error acquiring mutex\n\r"); -// -// if *status == Status::Running { -// drop(status); -// -// let mut info_traffic = info_traffic_mutex -// .lock() -// .expect("Error acquiring mutex\n\r"); -// -// for index in &info_traffic.addresses_last_interval { -// let key_val = info_traffic.map.get_index(*index).unwrap(); -// let seek_pos = 166 * 3 + 206 * (*index) as u64; -// output.seek(SeekFrom::Start(seek_pos)).unwrap(); -// writeln!(output, "{}{}", key_val.0, key_val.1) -// .expect("Error writing output file\n\r"); -// } -// info_traffic.addresses_last_interval = HashSet::new(); // empty set -// -// drop(info_traffic); -// -// output.flush().expect("Error writing output file\n\r"); -// } else { -// //status is Init -// while *status == Status::Init { -// status = cvar.wait(status).expect("Error acquiring mutex\n\r"); -// } -// } -// } -// }