mirror of
https://github.com/redstrate/Kawari.git
synced 2025-04-26 00:37:44 +00:00
Emit a better error message on packet parsing failure
This commit is contained in:
parent
3caf9d38c1
commit
2f996f0012
1 changed files with 36 additions and 32 deletions
|
@ -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]) {
|
||||
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);
|
||||
|
||||
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);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue