Skip to content

Commit

Permalink
src: lib: cli: Add UDP server timeout CLI arg
Browse files Browse the repository at this point in the history
  • Loading branch information
joaoantoniocardoso committed Oct 22, 2024
1 parent 5b6f61e commit a17f551
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/lib/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ struct Args {

#[arg(long, default_value = "true")]
streamreq_disable: bool,

/// The timeout duration (in seconds) after which inactive UDP clients will be discarded.
#[arg(long, default_value = "10")]
udp_server_timeout: i16,
}

#[instrument(level = "trace")]
Expand Down Expand Up @@ -168,6 +172,17 @@ pub fn command_line() -> String {
format!("{:#?}", MANAGER.clap_matches)
}

#[instrument(level = "debug")]
pub fn udp_server_timeout() -> Option<tokio::time::Duration> {
let seconds = MANAGER.clap_matches.udp_server_timeout;

if seconds < 0 {
return None;
}

Some(tokio::time::Duration::from_secs(seconds as u64))
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down

0 comments on commit a17f551

Please sign in to comment.