diff options
| author | zedddie <rust@zedddie.rs> | 2026-03-17 00:01:42 +0100 |
|---|---|---|
| committer | tuturuu <zedddiezxc@gmail.com> | 2026-03-17 00:01:42 +0100 |
| commit | 2eb03ac7688387e15d3b210f1946896380d38080 (patch) | |
| tree | 894a077fe1c6b36282ae6b5b3055f9b6783f6a57 /src/sniffing | |
| parent | 81e1ed42a0d0ef0ee2cd6092b23a0238c46e0daa (diff) | |
add a Packet type alias and comment out debug thingies :<
Diffstat (limited to 'src/sniffing')
| -rw-r--r-- | src/sniffing/headers.rs | 14 |
1 files changed, 9 insertions, 5 deletions
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<dyn std::error::Error + Send + Sync + 'static>; type SniffedPacket = Result<PacketInfo, Box<dyn std::error::Error + Send + Sync + 'static>>; +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) }, |
