1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-04-26 08:37:44 +00:00

Emit a better error message on packet parsing failure

This commit is contained in:
Joshua Goins 2025-03-08 15:29:38 -05:00
parent 3caf9d38c1
commit 2f996f0012

View file

@ -143,7 +143,9 @@ async fn send_packet(socket: &mut WriteHalf<TcpStream>, segments: &[PacketSegmen
pub async fn parse_packet(socket: &mut WriteHalf<TcpStream>, data: &[u8]) { pub async fn parse_packet(socket: &mut WriteHalf<TcpStream>, data: &[u8]) {
let mut cursor = Cursor::new(data); let mut cursor = Cursor::new(data);
if let Ok(packet) = Packet::read_le(&mut cursor) {
match Packet::read_le(&mut cursor) {
Ok(packet) => {
println!("{:#?}", packet); println!("{:#?}", packet);
if packet.header.size as usize != data.len() { if packet.header.size as usize != data.len() {
@ -176,9 +178,11 @@ pub async fn parse_packet(socket: &mut WriteHalf<TcpStream>, data: &[u8]) {
} }
} }
//dump("nothing", data); },
} else { Err(err) => {
println!("{err}");
dump("Failed to parse packet!", data); dump("Failed to parse packet!", data);
},
} }
} }