From c70b09baa43a3a55b3546bcda66d97ed33390f1d Mon Sep 17 00:00:00 2001 From: shimun Date: Wed, 30 Nov 2022 15:06:54 +0100 Subject: [PATCH] added: feature flags --- Cargo.toml | 10 ++++++++-- src/api.rs | 5 +++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3b22404..5e63d4b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,13 +6,19 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[features] +default = [ "client", "reload" ] +reload = [] +client = [ "dep:url", "dep:reqwest" ] + + [dependencies] anyhow = "1.0.66" async-trait = "0.1.59" axum = { version = "0.6.1", features = ["http2"] } axum-extra = { version = "0.4.1", features = ["typed-routing"] } clap = { version = "4.0.29", features = ["env", "derive"] } -reqwest = "0.11.13" +reqwest = { version = "0.11.13", optional = true } serde = { version = "1.0.148", features = ["derive"] } ssh-key = { version = "0.5.1", features = ["ed25519", "p256", "p384", "rsa", "signature"] } tokio = { version = "1.22.0", features = ["io-std", "test-util", "tracing", "macros", "fs"] } @@ -20,7 +26,7 @@ tower = { version = "0.4.13", features = ["util"] } tower-http = { version = "0.3.4", features = ["map-request-body"] } tracing = "0.1.37" tracing-subscriber = "0.3.16" -url = "2.3.1" +url = { version = "2.3.1", optional = true } [patch.crates-io] ssh-key = { git = "https://github.com/a-dma/SSH.git", branch = "u2f_signatures" } diff --git a/src/api.rs b/src/api.rs index 23a4bee..df264e3 100644 --- a/src/api.rs +++ b/src/api.rs @@ -21,6 +21,7 @@ use ssh_key::{Certificate, PublicKey}; use tokio::sync::Mutex; use tower::ServiceBuilder; use tower_http::ServiceBuilderExt; +use tracing::debug; use self::extract::CertificateBody; @@ -87,7 +88,7 @@ pub async fn run( tokio::spawn(async move { loop { - tokio::time::sleep(Duration::from_secs(30)).await; + tokio::time::sleep(std::time::Duration::from_secs(30)).await; if let Ok(certs) = read_certs(&state.ca, &state.cert_dir).await { *state.certs.lock().await = certs .into_iter() @@ -108,7 +109,7 @@ pub async fn run( // run our app with hyper // `axum::Server` is a re-export of `hyper::Server` - tracing::debug!("listening on {}", address); + debug!("listening on {}", address); axum::Server::bind(&address) .serve(app.into_make_service()) .await