diff --git a/src/lib.rs b/src/lib.rs index 6656693..08ec190 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -73,6 +73,7 @@ pub async fn select_and_start_single( Ok(()) } +// TODO: actually use different vaults for the challenges #7 pub async fn start_all(config: Config, vault: VaultRef) -> anyhow::Result<()> { let c1 = challenge::c1::C1::new(config.clone(), vault.clone()); let c2 = challenge::c2::C2::new(config.clone(), vault.clone()); @@ -84,11 +85,10 @@ pub async fn start_all(config: Config, vault: VaultRef) -> anyhow::Result<()> { meta::serve( vec![ - challenge::c1::C1::text(), - challenge::c2::C2::text(), - challenge::c3::C3::text(), + (challenge::c1::C1::text(), vault.clone()), + (challenge::c2::C2::text(), vault.clone()), + (challenge::c3::C3::text(), vault.clone()), ], - vault.clone(), config.clone(), ) .await?; diff --git a/src/meta/mod.rs b/src/meta/mod.rs index bbdb244..69f00c3 100644 --- a/src/meta/mod.rs +++ b/src/meta/mod.rs @@ -1,3 +1,4 @@ +use std::collections::HashMap; use std::sync::Arc; use anyhow::Result; @@ -20,17 +21,15 @@ pub mod errors; #[derive(Clone)] pub struct Service<'tp> { - vault: VaultRef, config: Config, env: Environment<'tp>, - challenges: Vec, + challenges: Vec<(ChallengeDesc, VaultRef)>, } impl<'tp> Service<'tp> { - fn build(vault: VaultRef, config: Config, challenges: Vec) -> Result> { + fn build(config: Config, challenges: Vec<(ChallengeDesc, VaultRef)>) -> Result> { let mut env = Environment::new(); env.add_template("index", include_str!("../../data/www/admin.html"))?; Ok(Self { - vault, config, env, challenges, @@ -39,8 +38,8 @@ impl<'tp> Service<'tp> { } } -pub async fn serve(challenges: Vec, vault: VaultRef, config: Config) -> Result<()> { - let service = Service::build(vault, config, challenges)?; +pub async fn serve(challenges: Vec<(ChallengeDesc, VaultRef)>, config: Config) -> Result<()> { + let service = Service::build(config, challenges)?; let routes = Service::admin_routes(service.clone()) .or(Service::ressources_routes())