Skip to content

Commit

Permalink
handle more cases of duplicate rules
Browse files Browse the repository at this point in the history
  • Loading branch information
pythops committed Oct 7, 2024
1 parent 534609b commit 8b19b07
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions oryx-tui/src/section/firewall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ impl Firewall {
{
let new_port =
BlockedPort::from_str(user_input.port.field.value()).unwrap();

if exiting_rule_with_same_ip.port == new_port {
Notification::send(
"Duplicate Rule",
Expand All @@ -321,6 +322,28 @@ impl Firewall {
)?;
return Err("Rule validation error".into());
}

match exiting_rule_with_same_ip.port {
BlockedPort::Single(_) => {
if new_port == BlockedPort::All {
Notification::send(
"Duplicate Rule",
crate::notification::NotificationLevel::Warning,
sender.clone(),
)?;
return Err("Rule validation error".into());
}
}

BlockedPort::All => {
Notification::send(
"Duplicate Rule",
crate::notification::NotificationLevel::Warning,
sender.clone(),
)?;
return Err("Rule validation error".into());
}
}
}

let rule = FirewallRule {
Expand Down

0 comments on commit 8b19b07

Please sign in to comment.