add a Packet type alias and comment out debug thingies :<

This commit is contained in:
zedddie 2026-03-17 00:01:42 +01:00 committed by tuturuu
parent 81e1ed42a0
commit 2eb03ac768
No known key found for this signature in database
GPG key ID: B352C3C2894405A7

View file

@ -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 GenericError = Box<dyn std::error::Error + Send + Sync + 'static>;
type SniffedPacket = Result<PacketInfo, 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; let ver = packet[0] >> 4;
dbg!(ver);
match ver { match ver {
4 => { 4 => {
let dst_port = Port::from_be_bytes([packet[22], packet[23]]); 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(_)) { if !matches!(v4.protocol(), Protocol::Unsupported(_)) {
println!("{v4:?}"); println!("{v4:?}");
} else { } 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) Ok(v4)
}, },
6 => { 6 => {
println!("im in 6!");
let dst_port = Port::from_be_bytes([packet[22], packet[23]]); let dst_port = Port::from_be_bytes([packet[22], packet[23]]);
let dns; let dns;
if dst_port == 53 { dns = true; } else { dns = false; }; 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(_)) { if !matches!(v6.protocol(), Protocol::Unsupported(_)) {
println!("{v6:?}"); println!("{v6:?}");
} else { } 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) Ok(v6)
}, },