From 2eb03ac7688387e15d3b210f1946896380d38080 Mon Sep 17 00:00:00 2001 From: zedddie Date: Tue, 17 Mar 2026 00:01:42 +0100 Subject: add a Packet type alias and comment out debug thingies :< --- src/sniffing/headers.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/sniffing') diff --git a/src/sniffing/headers.rs b/src/sniffing/headers.rs index 050f2d3..a5b0480 100644 --- a/src/sniffing/headers.rs +++ b/src/sniffing/headers.rs @@ -43,12 +43,13 @@ impl PacketInfo { } } +// TODO: move these to some appropriate file for code readability. type GenericError = Box; type SniffedPacket = Result>; +type Packet = [u8]; -pub fn sniff_raw_packets(packet: &[u8]) -> SniffedPacket { +pub fn sniff_raw_packets(packet: &Packet) -> SniffedPacket { let ver = packet[0] >> 4; - dbg!(ver); match ver { 4 => { let dst_port = Port::from_be_bytes([packet[22], packet[23]]); @@ -70,12 +71,13 @@ pub fn sniff_raw_packets(packet: &[u8]) -> SniffedPacket { if !matches!(v4.protocol(), Protocol::Unsupported(_)) { println!("{v4:?}"); } else { - println!("oppsie unsupported"); + // TODO: make --debug option which will include this diagnostic, for general use this + // should be off + // println!("oppsie unsupported protocol: {:?}", v4.protocol()); } Ok(v4) }, 6 => { - println!("im in 6!"); let dst_port = Port::from_be_bytes([packet[22], packet[23]]); let dns; if dst_port == 53 { dns = true; } else { dns = false; }; @@ -94,7 +96,9 @@ pub fn sniff_raw_packets(packet: &[u8]) -> SniffedPacket { if !matches!(v6.protocol(), Protocol::Unsupported(_)) { println!("{v6:?}"); } else { - println!("oppsie unsupported"); + // TODO: make --debug option which will include this diagnostic, for general use this + // should be off + // println!("oppsie unsupported protocol: {:?}", v6.protocol()); } Ok(v6) }, -- cgit v1.2.3