From 81829c61718478759313604de0b806fd61433b2c Mon Sep 17 00:00:00 2001 From: adrien gaultier Date: Tue, 8 Oct 2024 10:20:05 +0200 Subject: [PATCH] fix validate_duplicate_rules --- oryx-tui/src/section/firewall.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/oryx-tui/src/section/firewall.rs b/oryx-tui/src/section/firewall.rs index 2e7dbab..25fccbc 100644 --- a/oryx-tui/src/section/firewall.rs +++ b/oryx-tui/src/section/firewall.rs @@ -280,10 +280,13 @@ impl Firewall { } fn validate_duplicate_rules(rules: &[FirewallRule], user_input: &UserInput) -> AppResult<()> { - if let Some(exiting_rule_with_same_ip) = rules - .iter() - .find(|rule| rule.ip == IpAddr::from_str(user_input.ip.field.value()).unwrap()) - { + if let Some(exiting_rule_with_same_ip) = rules.iter().find(|rule| { + rule.ip == IpAddr::from_str(user_input.ip.field.value()).unwrap() + && match user_input.id { + Some(uuid) => rule.id != uuid, + None => true, + } + }) { let new_port = BlockedPort::from_str(user_input.port.field.value()).unwrap(); if exiting_rule_with_same_ip.port == new_port {