mirror of
https://github.com/GyulyVGC/sniffnet.git
synced 2025-12-23 22:29:01 -05:00
minor improvements and refactoring
This commit is contained in:
@@ -231,7 +231,7 @@ fn get_addresses_row(my_dev: &MyDevice, font: Font) -> Option<Row<'_, Message, S
|
||||
return None;
|
||||
}
|
||||
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();
|
||||
row = row.push(
|
||||
Container::new(Text::new(address_string).size(FONT_SIZE_FOOTER).font(font))
|
||||
|
||||
@@ -83,8 +83,8 @@ pub struct Sniffer {
|
||||
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)
|
||||
pub current_capture_rx: (usize, Option<Receiver<BackendTrafficMessage>>),
|
||||
/// Preview capture clone (to close the channel after every run)
|
||||
pub preview_capture_rx: Option<Receiver<TrafficPreview>>,
|
||||
/// Preview captures receiver clone (to close the channel when starting the analysis)
|
||||
pub preview_captures_rx: Option<Receiver<TrafficPreview>>,
|
||||
/// Capture data
|
||||
pub info_traffic: InfoTraffic,
|
||||
/// 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,
|
||||
welcome: Some((true, 0)),
|
||||
current_capture_rx: (0, None),
|
||||
preview_capture_rx: None,
|
||||
preview_captures_rx: None,
|
||||
info_traffic: InfoTraffic::default(),
|
||||
addresses_resolved: HashMap::new(),
|
||||
favorite_hosts: HashSet::new(),
|
||||
@@ -829,11 +829,11 @@ fn open_web(web_page: &WebPage) {
|
||||
}
|
||||
|
||||
fn start(&mut self) -> Task<Message> {
|
||||
// close capture preview channel to kill previous preview captures
|
||||
if let Some(rx) = &self.preview_capture_rx {
|
||||
// close captures preview channel to kill previous preview captures
|
||||
if let Some(rx) = &self.preview_captures_rx {
|
||||
rx.close();
|
||||
}
|
||||
self.preview_capture_rx = None;
|
||||
self.preview_captures_rx = None;
|
||||
|
||||
if matches!(&self.capture_source, CaptureSource::Device(_)) {
|
||||
let current_device_name = &self.capture_source.get_name();
|
||||
@@ -928,7 +928,7 @@ fn start_traffic_previews(&mut self) -> Task<Message> {
|
||||
traffic_preview(&tx);
|
||||
})
|
||||
.log_err(location!());
|
||||
self.preview_capture_rx = Some(rx.clone());
|
||||
self.preview_captures_rx = Some(rx.clone());
|
||||
Task::run(rx, |traffic_preview| {
|
||||
Message::TrafficPreview(traffic_preview)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user