mirror of
https://github.com/GyulyVGC/sniffnet.git
synced 2026-10-23 07:31:34 +00:00
solved root directory macOS bundle and added info on filters in waiting screen
This commit is contained in:
parent
e81881fe4b
commit
f1b84c00dc
2 changed files with 23 additions and 11 deletions
|
|
@ -116,8 +116,8 @@ pub fn run_page(sniffer: &mut Sniffer) -> Column<Message> {
|
|||
|
||||
let tot_packets_text = Text::new(format!("Total intercepted packets: {}\n\n\
|
||||
Filtered packets: 0\n\n\
|
||||
Some packets have been intercepted, but still none has been selected according to the filters you specified...",
|
||||
observed.separate_with_spaces())).font(font);
|
||||
Some packets have been intercepted, but still none has been selected according to the filters you specified...\n\n{}",
|
||||
observed.separate_with_spaces(), get_active_filters_string_nobr(sniffer.filters.clone()))).font(font);
|
||||
|
||||
body = body
|
||||
.push(Row::new().height(Length::FillPortion(1)))
|
||||
|
|
@ -128,7 +128,6 @@ pub fn run_page(sniffer: &mut Sniffer) -> Column<Message> {
|
|||
}
|
||||
|
||||
(observed, filtered) => { //observed > filtered > 0 || observed = filtered > 0
|
||||
let filters_string = get_active_filters_string(sniffer.filters.clone());
|
||||
|
||||
let percentage_string_packets =
|
||||
if format!("{:.1}", 100.0*(filtered) as f32/observed as f32).eq("0.0") {
|
||||
|
|
@ -176,7 +175,7 @@ pub fn run_page(sniffer: &mut Sniffer) -> Column<Message> {
|
|||
.width(Length::FillPortion(1))
|
||||
.padding(10)
|
||||
//.push(iced::Text::new(std::env::current_dir().unwrap().to_str().unwrap()).font(font))
|
||||
.push(Text::new(filters_string).font(font))
|
||||
.push(Text::new(get_active_filters_string(sniffer.filters.clone())).font(font))
|
||||
.push(Text::new(" "))
|
||||
.push(Text::new(format!("Filtered packets:\n {} ({} of the total)",
|
||||
filtered.separate_with_spaces(), percentage_string_packets)).font(font))
|
||||
|
|
@ -315,7 +314,7 @@ fn get_active_filters_string(filters: Arc<Mutex<Filters>>) -> String {
|
|||
else {
|
||||
let mut ret_val = "Active filters:".to_string();
|
||||
if filters_lock.ip != "no filter" {
|
||||
ret_val.push_str(&format!("\n {}", filters_lock.ip.replace('v', "V")));
|
||||
ret_val.push_str(&format!("\n {}", filters_lock.ip.replace("ip", "IP")));
|
||||
}
|
||||
if filters_lock.transport.ne(&TransProtocol::Other) {
|
||||
ret_val.push_str(&format!("\n {}", filters_lock.transport));
|
||||
|
|
@ -328,6 +327,22 @@ fn get_active_filters_string(filters: Arc<Mutex<Filters>>) -> String {
|
|||
}
|
||||
|
||||
|
||||
fn get_active_filters_string_nobr(filters: Arc<Mutex<Filters>>) -> String {
|
||||
let filters_lock = filters.lock().unwrap();
|
||||
let mut ret_val = "Active filters:".to_string();
|
||||
if filters_lock.ip != "no filter" {
|
||||
ret_val.push_str(&format!(" {}", filters_lock.ip.replace("ip", "IP")));
|
||||
}
|
||||
if filters_lock.transport.ne(&TransProtocol::Other) {
|
||||
ret_val.push_str(&format!(" {}", filters_lock.transport));
|
||||
}
|
||||
if filters_lock.application.ne(&AppProtocol::Other) {
|
||||
ret_val.push_str(&format!(" {}", filters_lock.application));
|
||||
}
|
||||
ret_val
|
||||
}
|
||||
|
||||
|
||||
fn get_connection_color(traffic_type: TrafficType) -> Color {
|
||||
if traffic_type == TrafficType::Incoming
|
||||
|| traffic_type == TrafficType::Multicast {
|
||||
|
|
|
|||
|
|
@ -58,11 +58,8 @@ pub fn sleep_and_write_report_loop(current_capture_id: Arc<Mutex<u16>>,
|
|||
// .arg("./sniffnet_report/report.txt")
|
||||
// .spawn()
|
||||
// .unwrap();
|
||||
// #[cfg(target_os = "macos")]
|
||||
// std::process::Command::new("cd")
|
||||
// .args('~`)
|
||||
// .spawn()
|
||||
// .unwrap();
|
||||
#[cfg(target_os = "macos")]
|
||||
std::env::set_current_dir(std::env::var("HOME").unwrap()).unwrap();
|
||||
// #[cfg(target_os = "linux")]
|
||||
// std::process::Command::new("explorer")
|
||||
// .arg("./sniffnet_report/report.txt")
|
||||
|
|
@ -195,7 +192,7 @@ pub fn get_app_count_string(app_count: HashMap<AppProtocol, u128>, tot_packets:
|
|||
let spaces_string_2 = " ".to_string()
|
||||
.repeat(10-percentage_string.len());
|
||||
|
||||
ret_val.push_str(&format!(" {}:{}{}{}{}\n",
|
||||
ret_val.push_str(&format!(" {}:{}{}{}{} \n",
|
||||
app_proto_string,
|
||||
spaces_string_1,
|
||||
num_string,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue