diff --git a/src/components/discovery.rs b/src/components/discovery.rs index 627f005..f364587 100644 --- a/src/components/discovery.rs +++ b/src/components/discovery.rs @@ -13,8 +13,8 @@ use pnet::packet::{ use pnet::util::MacAddr; use core::str; -use ratatui::{prelude::*, widgets::*}; use ratatui::layout::Position; +use ratatui::{prelude::*, widgets::*}; use std::net::{IpAddr, Ipv4Addr}; use std::string; use std::time::{Duration, Instant}; @@ -35,12 +35,12 @@ use crate::{ tui::Frame, utils::{count_ipv4_net_length, get_ips4_from_cidr}, }; +use crossterm::event::Event; use crossterm::event::{KeyCode, KeyEvent}; use mac_oui::Oui; use rand::random; use tui_input::backend::crossterm::EventHandler; use tui_input::Input; -use crossterm::event::Event; static POOL_SIZE: usize = 32; static INPUT_SIZE: usize = 30; @@ -102,7 +102,7 @@ impl Discovery { pub fn get_scanned_ips(&self) -> &Vec { &self.scanned_ips - } + } fn set_cidr(&mut self, cidr_str: String, scan: bool) { match cidr_str.parse::() { @@ -137,7 +137,9 @@ impl Discovery { Ok(_) => { if let Some(tx_action) = &self.action_tx { tx_action - .send(Action::Error("Unknown or unsupported channel type".into())) + .send(Action::Error( + "Unknown or unsupported channel type".into(), + )) .unwrap(); } return; diff --git a/src/components/packetdump.rs b/src/components/packetdump.rs index ac36b4b..d9bc24a 100644 --- a/src/components/packetdump.rs +++ b/src/components/packetdump.rs @@ -849,11 +849,7 @@ impl PacketDump { rows } - fn make_table( - rows: Vec, - packet_type: PacketTypeEnum, - dump_paused: bool, - ) -> Table { + fn make_table(rows: Vec, packet_type: PacketTypeEnum, dump_paused: bool) -> Table { let header = Row::new(vec!["time", "packet log"]) .style(Style::default().fg(Color::Yellow)) .top_margin(1) diff --git a/src/components/sniff.rs b/src/components/sniff.rs index eabb199..afe546c 100644 --- a/src/components/sniff.rs +++ b/src/components/sniff.rs @@ -343,12 +343,14 @@ impl Component for Sniffer { self.tab_changed(tab).unwrap(); } - if let Action::Down = action { - self.scroll_down(); - } + if self.active_tab == TabsEnum::Traffic { + if let Action::Down = action { + self.scroll_down(); + } - if let Action::Up = action { - self.scroll_up(); + if let Action::Up = action { + self.scroll_up(); + } } if let Action::ActiveInterface(ref interface) = action { diff --git a/src/components/tabs.rs b/src/components/tabs.rs index dd7e9f5..518ec50 100644 --- a/src/components/tabs.rs +++ b/src/components/tabs.rs @@ -111,13 +111,11 @@ impl Component for Tabs { self.next_tab(); } - Action::TabChange(tab_enum) => { - TabsEnum::iter().enumerate().for_each(|(idx, t)| { - if tab_enum == t { - self.tab_index = idx; - } - }) - } + Action::TabChange(tab_enum) => TabsEnum::iter().enumerate().for_each(|(idx, t)| { + if tab_enum == t { + self.tab_index = idx; + } + }), _ => {} } diff --git a/src/components/wifi_scan.rs b/src/components/wifi_scan.rs index 1b890f8..799d5e3 100644 --- a/src/components/wifi_scan.rs +++ b/src/components/wifi_scan.rs @@ -10,10 +10,10 @@ use ratatui::{prelude::*, widgets::*}; use super::Component; use crate::{ action::Action, + config::DEFAULT_BORDER_STYLE, layout::{get_horizontal_layout, get_vertical_layout}, mode::Mode, tui::Frame, - config::DEFAULT_BORDER_STYLE, }; #[derive(Debug, PartialEq, Clone)] @@ -42,7 +42,6 @@ pub struct WifiScan { pub wifis: Vec, pub signal_tick: [f64; 2], show_graph: bool, - // pub mode: Mode, } impl Default for WifiScan {