Improve pinger error handling

This commit is contained in:
Nils Andreas Svee committed 2022-10-13 17:16:01 +02:00
1 parent 290450ac1e
commit 9a1901b213
3 files changed
+29 -16

No files matched your search

+9 -5
View File
@@ -21,6 +21,12 @@ pub enum PingError {
InvalidNumber(#[from] io::Error),
#[error("Error parsing packet")]
InvalidPacket(#[from] ReadError),
#[error("Invalid protocol")]
InvalidProtocol(String),
#[error("Invalid packet type")]
InvalidType(String),
#[error("No transport")]
NoTransport,
#[error("Socket error")]
Socket(#[from] Errno),
#[error("Wrong ICMP identifier (expected {expected:?}, found {found:?})")]
@@ -98,11 +104,9 @@ pub trait PingListener {
let reply = match self.parse_packet(id, addr, buf) {
Ok(val) => val,
Err(e) => {
error!(
"Something went wrong while parsing packet: {}",
e.to_string()
);
Err(_) => {
// parse_packet will throw an error if it's an unknown protocol etc.
// so just quietly move on
continue;
}
};