diff options
author | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-11-06 15:34:44 +0100 |
---|---|---|
committer | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-11-06 15:34:44 +0100 |
commit | 4bbdd0e194da6d15913535dce5e36a18ff76260d (patch) | |
tree | 450e634010cecf2c22428227fb1a8400b8b27067 | |
parent | 63eb651d6dfe667682ee208a43d359fd47096d00 (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.rs | 22 |
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"), + } } } |