Skip to content

Commit

Permalink
fix validate_duplicate_rules
Browse files Browse the repository at this point in the history
  • Loading branch information
adgaultier committed Oct 8, 2024
1 parent dfeb8ac commit 81829c6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions oryx-tui/src/section/firewall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 81829c6

Please sign in to comment.