Skip to content

Commit

Permalink
add port range validation
Browse files Browse the repository at this point in the history
  • Loading branch information
pythops committed Jan 15, 2025
1 parent 3fc1961 commit 54f9f49
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions oryx-tui/src/section/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,20 @@ impl UserInput {
}),
Err(_) => {
let Some(caps) = re.captures(self.input.value()) else {
self.error = Some("Invalid Port --".to_string());
self.error = Some("Invalid Port(s)".to_string());
return Err("Validation Error".into());
};
Ok(Range {
start: caps["start"].parse()?,
end: caps["end"].parse()?,
})

let start: u16 = caps["start"].parse()?;
let end: u16 = caps["end"].parse()?;

// Empty range
if start >= end {
self.error = Some("Invalid Port Range".to_string());
return Err("Validation Error".into());
}

Ok(Range { start, end })
}
}
}
Expand Down Expand Up @@ -397,7 +404,7 @@ impl Metrics {
//TODO: Center
let rows = [
Row::new(vec![
Cell::from("Packet Counter".to_string())
Cell::from("Port Packet Counter".to_string())
.bg(Color::DarkGray)
.fg(Color::White),
Cell::from(self.user_input.input.value())
Expand Down

0 comments on commit 54f9f49

Please sign in to comment.