From 049421ffacbe5278f2ac65832ec2d3614ab15aaa Mon Sep 17 00:00:00 2001 From: PlexSheep Date: Sat, 12 Oct 2024 17:25:10 +0200 Subject: [PATCH] refactor(cli): simplify the cli, starting admin and all channenges no challenge id in cli anymore, give a base addr for the challenges and an admin addr --- src/config.rs | 14 +++++++------- src/meta/mod.rs | 4 +--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/config.rs b/src/config.rs index 1270e28..51fb346 100644 --- a/src/config.rs +++ b/src/config.rs @@ -46,13 +46,14 @@ pub const ENV_SECRET: &str = "WOOLY_SECRET"; long_about, help_template = libpt::cli::args::HELP_TEMPLATE)] pub struct Config { - /// Index of the challenge - pub challenge: u16, - /// Network address to host the challenge on + /// Network address to host the challenges on + /// + /// The port will be the port for challenge 0. Challenge 1 will be hosted on port+1 and so on. + #[arg(short = 'c', long = "challenge")] pub addr: SocketAddr, - /// Network address to host the challenge on + /// Network address to host the admin interface on #[arg(short = 'a', long = "admin")] - pub addr_admin: Option, + pub addr_admin: SocketAddr, #[command(flatten)] pub verbosity: VerbosityLevel, } @@ -60,10 +61,9 @@ pub struct Config { impl Default for Config { fn default() -> Self { Self { - challenge: 1, addr: SocketAddr::from_str("127.0.0.1:1337").unwrap(), verbosity: VerbosityLevel::default(), - addr_admin: Option::default(), + addr_admin: SocketAddr::from_str("127.0.0.1:8080").unwrap(), } } } diff --git a/src/meta/mod.rs b/src/meta/mod.rs index 3954953..b15b3f4 100644 --- a/src/meta/mod.rs +++ b/src/meta/mod.rs @@ -77,9 +77,7 @@ pub async fn serve(challenges: Vec<(ChallengeDesc, VaultRef)>, config: Config) - ) })); - warp::serve(routes) - .run(service.config.addr_admin.unwrap()) - .await; + warp::serve(routes).run(service.config.addr_admin).await; warn!("exited the admin interface"); Ok(())