diff --git a/rumqttd/CHANGELOG.md b/rumqttd/CHANGELOG.md index e05da5cea..a84cce346 100644 --- a/rumqttd/CHANGELOG.md +++ b/rumqttd/CHANGELOG.md @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - MQTT keep alive interval - record client id for remote link's span - session present flag in connack +- (MQTT v5) handle connack and unsuback packets properly instead of panic. ### Security diff --git a/rumqttd/src/protocol/v4/mod.rs b/rumqttd/src/protocol/v4/mod.rs index aa454663d..41ff44da3 100644 --- a/rumqttd/src/protocol/v4/mod.rs +++ b/rumqttd/src/protocol/v4/mod.rs @@ -334,7 +334,6 @@ impl Protocol for V4 { // v4 Disconnect packet gets handled in the previous check, this branch gets hit when // Disconnect packet has properties which is only valid for v5 PacketType::Disconnect => return Err(Error::InvalidProtocol), - _ => unreachable!(), }; Ok(packet) diff --git a/rumqttd/src/protocol/v5/mod.rs b/rumqttd/src/protocol/v5/mod.rs index b8916ae55..fa2bd6c27 100644 --- a/rumqttd/src/protocol/v5/mod.rs +++ b/rumqttd/src/protocol/v5/mod.rs @@ -388,6 +388,10 @@ impl Protocol for V5 { connect::read(fixed_header, packet)?; Packet::Connect(connect, properties, will, willproperties, login) } + PacketType::ConnAck => { + let (puback, properties) = connack::read(fixed_header, packet)?; + Packet::ConnAck(puback, properties) + } PacketType::Publish => { let (publish, properties) = publish::read(fixed_header, packet)?; Packet::Publish(publish, properties) @@ -408,6 +412,10 @@ impl Protocol for V5 { let (unsubscribe, properties) = unsubscribe::read(fixed_header, packet)?; Packet::Unsubscribe(unsubscribe, properties) } + PacketType::UnsubAck => { + let (unsuback, properties) = unsuback::read(fixed_header, packet)?; + Packet::UnsubAck(unsuback, properties) + } PacketType::PingReq => Packet::PingReq(PingReq), PacketType::PingResp => Packet::PingResp(PingResp), PacketType::Disconnect => { @@ -426,7 +434,6 @@ impl Protocol for V5 { let (pubcomp, properties) = pubcomp::read(fixed_header, packet)?; Packet::PubComp(pubcomp, properties) } - _ => unreachable!(), }; Ok(packet)