Skip to content

Commit

Permalink
pre-final update
Browse files Browse the repository at this point in the history
- add UP, DOWN, LEFT, RIGHT actions
- add packets grabing: TCP, UDP, ICMP, ARP
- add packets table
- add packets filtering / selecting
  • Loading branch information
Chleba committed Feb 17, 2024
1 parent e53aa5d commit e65c0d2
Show file tree
Hide file tree
Showing 6 changed files with 322 additions and 77 deletions.
4 changes: 3 additions & 1 deletion .config/config.json5
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"<p>": "Packets",
"<f>": "Interface",
"<up>": "Up",
"<down>": "Down"
"<down>": "Down",
"<left>": "Left",
"<right>": "Right"
},
"Input": {
"<Esc>": "NormalMode"
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ serde = { version = "1.0.188", features = ["derive"] }
serde_json = "1.0.107"
signal-hook = "0.3.17"
strip-ansi-escapes = "0.2.0"
strum = "0.26.1"
surge-ping = "0.8.0"
tokio = { version = "1.32.0", features = ["full"] }
tokio-util = "0.7.9"
Expand Down
9 changes: 7 additions & 2 deletions src/action.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::{fmt, net::Ipv4Addr};
use chrono::{Local, DateTime};
use pnet::util::MacAddr;
use pnet::datalink::NetworkInterface;
use ratatui::text::Line;
Expand Down Expand Up @@ -30,6 +31,8 @@ pub enum Action {
// -- custom actions
Up,
Down,
Left,
Right,
GraphToggle,
PacketToggle,
InterfaceSwitch,
Expand All @@ -40,7 +43,7 @@ pub enum Action {
PingIp(String),
CountIp,
CidrError,
PacketDump(String, PacketTypeEnum),
PacketDump(DateTime<Local>, String, PacketTypeEnum),
}

impl<'de> Deserialize<'de> for Action {
Expand All @@ -52,7 +55,7 @@ impl<'de> Deserialize<'de> for Action {

impl<'de> Visitor<'de> for ActionVisitor {
type Value = Action;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter.write_str("a valid string representation of Action")
}
Expand All @@ -70,6 +73,8 @@ impl<'de> Deserialize<'de> for Action {
"Interface" => Ok(Action::InterfaceSwitch),
"Up" => Ok(Action::Up),
"Down" => Ok(Action::Down),
"Left" => Ok(Action::Left),
"Right" => Ok(Action::Right),

// -- default actions
"Tick" => Ok(Action::Tick),
Expand Down
1 change: 1 addition & 0 deletions src/components/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ impl Discovery {
fn make_table(scanned_ips: Vec<ScannedIp>, ip_num: i32) -> Table<'static> {
let header = Row::new(vec!["ip", "hostname", "mac", "vendor"])
.style(Style::default().fg(Color::Yellow))
.top_margin(1)
.bottom_margin(1);
let mut rows = Vec::new();

Expand Down
Loading

0 comments on commit e65c0d2

Please sign in to comment.