Captute "type" byte for unknow message type (#3146)

Found it useful for debugging
This commit is contained in:
hashmap 2019-11-29 13:04:55 +01:00 committed by GitHub
parent 82b1ff905d
commit 3f528a8e66
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View file

@ -293,7 +293,11 @@ where
try_break!(conn_handle.send(resp_msg));
}
}
Some(MsgHeaderWrapper::Unknown(msg_len)) => {
Some(MsgHeaderWrapper::Unknown(msg_len, type_byte)) => {
debug!(
"Received unknown message header, type {:?}, len {}.",
type_byte, msg_len
);
// Increase received bytes counter
reader_tracker.inc_received(MsgHeader::LEN as u64 + msg_len);

View file

@ -205,7 +205,7 @@ pub fn read_message<T: Readable>(
Err(Error::BadMessage)
}
}
MsgHeaderWrapper::Unknown(msg_len) => {
MsgHeaderWrapper::Unknown(msg_len, _) => {
read_discard(msg_len, stream)?;
Err(Error::BadMessage)
}
@ -248,7 +248,7 @@ pub enum MsgHeaderWrapper {
/// A "known" msg type with deserialized msg header.
Known(MsgHeader),
/// An unknown msg type with corresponding msg size in bytes.
Unknown(u64),
Unknown(u64, u8),
}
/// Header of any protocol message, used to identify incoming messages.
@ -331,7 +331,7 @@ impl Readable for MsgHeaderWrapper {
return Err(ser::Error::TooLargeReadErr);
}
Ok(MsgHeaderWrapper::Unknown(msg_len))
Ok(MsgHeaderWrapper::Unknown(msg_len, t))
}
}
}