minor improvements and refactoring

This commit is contained in:
GyulyVGC
2025-12-19 11:51:09 +01:00
parent 14dfd70356
commit 7bd2b18c33
2 changed files with 8 additions and 8 deletions

View File

@@ -231,7 +231,7 @@ fn get_addresses_row(my_dev: &MyDevice, font: Font) -> Option<Row<'_, Message, S
return None; return None;
} }
let mut row = Row::new().spacing(5); let mut row = Row::new().spacing(5);
for addr in my_dev.get_addresses() { for addr in addresses {
let address_string = addr.addr.to_string(); let address_string = addr.addr.to_string();
row = row.push( row = row.push(
Container::new(Text::new(address_string).size(FONT_SIZE_FOOTER).font(font)) Container::new(Text::new(address_string).size(FONT_SIZE_FOOTER).font(font))

View File

@@ -83,8 +83,8 @@ pub struct Sniffer {
pub welcome: Option<(bool, u8)>, pub welcome: Option<(bool, u8)>,
/// Capture receiver clone (to close the channel after every run), with the current capture id (to ignore pending messages from previous captures) /// Capture receiver clone (to close the channel after every run), with the current capture id (to ignore pending messages from previous captures)
pub current_capture_rx: (usize, Option<Receiver<BackendTrafficMessage>>), pub current_capture_rx: (usize, Option<Receiver<BackendTrafficMessage>>),
/// Preview capture clone (to close the channel after every run) /// Preview captures receiver clone (to close the channel when starting the analysis)
pub preview_capture_rx: Option<Receiver<TrafficPreview>>, pub preview_captures_rx: Option<Receiver<TrafficPreview>>,
/// Capture data /// Capture data
pub info_traffic: InfoTraffic, pub info_traffic: InfoTraffic,
/// Map of the resolved addresses with their full rDNS value and the corresponding host /// Map of the resolved addresses with their full rDNS value and the corresponding host
@@ -148,7 +148,7 @@ pub fn new(conf: Conf) -> Self {
conf, conf,
welcome: Some((true, 0)), welcome: Some((true, 0)),
current_capture_rx: (0, None), current_capture_rx: (0, None),
preview_capture_rx: None, preview_captures_rx: None,
info_traffic: InfoTraffic::default(), info_traffic: InfoTraffic::default(),
addresses_resolved: HashMap::new(), addresses_resolved: HashMap::new(),
favorite_hosts: HashSet::new(), favorite_hosts: HashSet::new(),
@@ -829,11 +829,11 @@ fn open_web(web_page: &WebPage) {
} }
fn start(&mut self) -> Task<Message> { fn start(&mut self) -> Task<Message> {
// close capture preview channel to kill previous preview captures // close captures preview channel to kill previous preview captures
if let Some(rx) = &self.preview_capture_rx { if let Some(rx) = &self.preview_captures_rx {
rx.close(); rx.close();
} }
self.preview_capture_rx = None; self.preview_captures_rx = None;
if matches!(&self.capture_source, CaptureSource::Device(_)) { if matches!(&self.capture_source, CaptureSource::Device(_)) {
let current_device_name = &self.capture_source.get_name(); let current_device_name = &self.capture_source.get_name();
@@ -928,7 +928,7 @@ fn start_traffic_previews(&mut self) -> Task<Message> {
traffic_preview(&tx); traffic_preview(&tx);
}) })
.log_err(location!()); .log_err(location!());
self.preview_capture_rx = Some(rx.clone()); self.preview_captures_rx = Some(rx.clone());
Task::run(rx, |traffic_preview| { Task::run(rx, |traffic_preview| {
Message::TrafficPreview(traffic_preview) Message::TrafficPreview(traffic_preview)
}) })