Skip to content

Commit

Permalink
update interfaces table row height with more ips
Browse files Browse the repository at this point in the history
  • Loading branch information
Chleba committed Dec 12, 2023
1 parent db2be88 commit 9a72de2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "netscanner"
version = "0.2.0"
version = "0.2.1"
edition = "2021"
description = "WiFi Scanner of Networks signal"
description = "Network Scanner"
license = "MIT"
authors = ["Chleba <chlebik@gmail.com>"]

Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# netscanner

[![CI](https://github.com//netscanner/workflows/CI/badge.svg)](https://github.com//netscanner/actions)

WiFi Networks Scanner

must be run with sudo priviliges

## Install
```
cargo install netscanner
```

![netscanner screenshot](./netscanner.png?raw=true)
29 changes: 21 additions & 8 deletions src/components/interfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,15 @@ impl Interfaces {
for w in &self.interfaces {
let name = w.name.clone();
let mac = w.mac.unwrap().to_string();
let ipv4: Vec<Span> = w
let ipv4: Vec<Line> = w
.ips
.iter()
.filter(|f| f.is_ipv4())
.cloned()
.map(|ip| Span::from(ip.ip().to_string()))
.map(|ip| {
let ip_str = ip.ip().to_string();
Line::from(vec![Span::styled(format!("{ip_str:<2}"), Style::default().fg(Color::Blue))])
})
.collect();
let ipv6: Vec<Span> = w
.ips
Expand All @@ -67,12 +70,22 @@ impl Interfaces {
.map(|ip| Span::from(ip.ip().to_string()))
.collect();

rows.push(Row::new(vec![
Cell::from(name),
Cell::from(mac),
Cell::from(vec![Line::from(ipv4)]),
Cell::from(vec![Line::from(ipv6)]),
]));
let mut row_height = 1;
if ipv4.len() > 1 {
row_height = ipv4.clone().len() as u16;
}
rows.push(
Row::new(vec![
Cell::from(Span::styled(
format!("{name:<2}"),
Style::default().fg(Color::Green),
)),
Cell::from(mac),
Cell::from(ipv4.clone()),
Cell::from(vec![Line::from(ipv6)]),
])
.height(row_height), // .bottom_margin((ipv4.len()) as u16)
);
}

let table = Table::new(rows)
Expand Down

0 comments on commit 9a72de2

Please sign in to comment.