aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHimbeerserverDE <himbeerserverde@gmail.com>2023-11-06 15:34:44 +0100
committerHimbeerserverDE <himbeerserverde@gmail.com>2023-11-06 15:34:44 +0100
commit4bbdd0e194da6d15913535dce5e36a18ff76260d (patch)
tree450e634010cecf2c22428227fb1a8400b8b27067
parent63eb651d6dfe667682ee208a43d359fd47096d00 (diff)
fix accepted_naks iterator being consumed after applying it to the first requested option
The RCN event now behaves properly if multiple options are nak'd.
-rw-r--r--src/proto.rs22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/proto.rs b/src/proto.rs
index e8813c2..0953ad9 100644
--- a/src/proto.rs
+++ b/src/proto.rs
@@ -1181,19 +1181,19 @@ impl<O: ProtocolOption> NegotiationProtocol<O> {
});
match packet.ty {
- PacketType::ConfigureNak => {
- for option in self.request.iter_mut() {
- if let Some(nak) = accepted_naks.find(|nak| nak.has_same_type(option)) {
- *option = nak.clone();
- }
- }
+ PacketType::ConfigureNak => {
+ for option in self.request.iter_mut() {
+ if let Some(nak) = accepted_naks.clone().find(|nak| nak.has_same_type(option)) {
+ *option = nak.clone();
}
- PacketType::ConfigureReject => self.request.retain(|option| {
- !accepted_naks
- .any(|nak| nak.has_same_type(option))
- }),
- _ => panic!("NegotiationProtocol::rcn called on packet type other than Configure-Nak or Configure-Reject"),
}
+ }
+ PacketType::ConfigureReject => self.request.retain(|option| {
+ !accepted_naks
+ .any(|nak| nak.has_same_type(option))
+ }),
+ _ => panic!("NegotiationProtocol::rcn called on packet type other than Configure-Nak or Configure-Reject"),
+ }
}
}