Skip to content

Commit

Permalink
fix: fix getting interface from empty vec
Browse files Browse the repository at this point in the history
  • Loading branch information
Chleba committed Aug 7, 2024
1 parent 1896d77 commit 81e0e8a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "netscanner"
version = "0.5.2"
version = "0.5.3"
edition = "2021"
description = "Network Scanner"
license = "MIT"
Expand Down
9 changes: 6 additions & 3 deletions src/components/interfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ use tokio::sync::mpsc::UnboundedSender;
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,
};

pub struct Interfaces {
Expand Down Expand Up @@ -98,14 +98,17 @@ impl Interfaces {
}

fn make_table(&mut self) -> Table {
let active_interface = &self.active_interfaces[self.active_interface_index];
let mut active_interface: Option<&NetworkInterface> = None;
if !self.active_interfaces.is_empty() {
active_interface = Some(&self.active_interfaces[self.active_interface_index]);
}
let header = Row::new(vec!["", "name", "mac", "ipv4", "ipv6"])
.style(Style::default().fg(Color::Yellow))
.height(1);
let mut rows = Vec::new();
for w in &self.interfaces {
let mut active = String::from("");
if active_interface == w {
if active_interface.is_some() && active_interface.unwrap() == w {
active = String::from("*");
}
let name = w.name.clone();
Expand Down

0 comments on commit 81e0e8a

Please sign in to comment.