From 18c6f7f2e3826e423a7a9f226c6b80a0ce158e7e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 7 Aug 2025 20:55:37 +0000 Subject: [PATCH 1/7] chore(deps): bump quiche from 0.24.4 to 0.24.5 Bumps [quiche](https://github.com/cloudflare/quiche) from 0.24.4 to 0.24.5. - [Release notes](https://github.com/cloudflare/quiche/releases) - [Commits](https://github.com/cloudflare/quiche/compare/0.24.4...0.24.5) --- updated-dependencies: - dependency-name: quiche dependency-version: 0.24.5 dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3eafe8b..d32160e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1915,9 +1915,9 @@ dependencies = [ [[package]] name = "quiche" -version = "0.24.4" +version = "0.24.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1074d39fd8de884478ab94220330f3127c7308475d537a42719914e9ae870cd5" +checksum = "88fa45f0d2e3fc7ca8b4306408f8b15df9a3b5ac70197f84dfc6ebf58fb7e26a" dependencies = [ "cdylib-link-lines", "cmake", diff --git a/Cargo.toml b/Cargo.toml index 92526a5..9c005a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -63,7 +63,7 @@ rcgen = "0.13" prometheus = { version = "0.14.0", features = ["process"] } # HTTP/3 support -quiche = { version = "0.24.4", features = ["boringssl-vendored", "ffi", "qlog"] } +quiche = { version = "0.24.5", features = ["boringssl-vendored", "ffi", "qlog"] } [dev-dependencies] tempfile = "3.13" From 80bc7caff6e279b0f9da7f936ebeb9527b16b851 Mon Sep 17 00:00:00 2001 From: Chahine-tech Date: Mon, 25 Aug 2025 14:54:08 +0200 Subject: [PATCH 2/7] refactor: simplify condition checks in AcmeService and HyperHandler --- src/adapters/acme.rs | 7 +++---- src/adapters/http_handler.rs | 40 +++++++++++++++++++----------------- src/config/validation.rs | 37 +++++++++++++++------------------ 3 files changed, 41 insertions(+), 43 deletions(-) diff --git a/src/adapters/acme.rs b/src/adapters/acme.rs index ba3783c..0d71a1a 100644 --- a/src/adapters/acme.rs +++ b/src/adapters/acme.rs @@ -464,10 +464,9 @@ impl AcmeService { /// Check if any of the configured domains has an expired certificate pub fn has_expired_certificate(&self) -> bool { for domain in &self.config.domains { - if let Some(cert_info) = self.check_certificate(domain) { - if cert_info.is_expired() { - return true; - } + match self.check_certificate(domain) { + Some(cert_info) if cert_info.is_expired() => return true, + _ => {} } } false diff --git a/src/adapters/http_handler.rs b/src/adapters/http_handler.rs index 464859a..8265d15 100644 --- a/src/adapters/http_handler.rs +++ b/src/adapters/http_handler.rs @@ -255,15 +255,18 @@ impl HyperHandler { ) { if let Some(actions_config) = actions_config_opt { if let Some(condition) = &actions_config.condition { - if let Some(ctx) = condition_check_ctx { - if !Self::check_condition(ctx, condition) { - return; // Condition not met, skip actions + match condition_check_ctx { + Some(ctx) => { + if !Self::check_condition(ctx, condition) { + return; // Condition not met, skip actions + } + } + None => { + tracing::warn!( + "Condition specified for header actions, but no context provided for check. Skipping actions." + ); + return; } - } else { - tracing::warn!( - "Condition specified for header actions, but no context provided for check. Skipping actions." - ); - return; } } @@ -361,21 +364,20 @@ impl HyperHandler { None => return Ok(response_to_modify), }; - if let Some(condition) = &actions_config.condition { - match initial_req_ctx_opt { - Some(ctx) => { - if !Self::check_condition(ctx, condition) { + if let Some(condition) = &actions_config.condition { + match initial_req_ctx_opt { + Some(ctx) if !Self::check_condition(ctx, condition) => { + return Ok(response_to_modify); + } + Some(_) => {} + None => { + tracing::warn!( + "Condition specified for response body actions, but no context provided for check. Skipping actions." + ); return Ok(response_to_modify); } - } - None => { - tracing::warn!( - "Condition specified for response body actions, but no context provided for check. Skipping actions." - ); - return Ok(response_to_modify); } } - } if actions_config.set_text.is_none() && actions_config.set_json.is_none() { return Ok(response_to_modify); diff --git a/src/config/validation.rs b/src/config/validation.rs index 0ad9a5f..d5e18eb 100644 --- a/src/config/validation.rs +++ b/src/config/validation.rs @@ -149,20 +149,19 @@ impl ConfigValidator { .. } => { if target.starts_with("http://") || target.starts_with("https://") { - if let Err(e) = - Self::validate_url(target, &format!("route '{path}' redirect target")) - { + if let Err(e) = Self::validate_url(target, &format!("route '{path}' redirect target")) { errors.push(e); } } - if let Some(code) = status_code { - if !Self::is_valid_redirect_status_code(*code) { + match status_code { + Some(code) if !Self::is_valid_redirect_status_code(*code) => { errors.push(ValidationError::InvalidField { field: format!("route '{path}' redirect status_code"), message: format!("Status code {code} is not a valid redirect code. Use 301, 302, 307, or 308"), }); } + _ => {} } } RouteConfig::Websocket { @@ -178,23 +177,21 @@ impl ConfigValidator { errors.push(e); } - if let Some(frame_size) = max_frame_size { - if *frame_size == 0 { - errors.push(ValidationError::InvalidField { - field: format!("route '{path}' max_frame_size"), - message: "WebSocket max frame size must be greater than 0".to_string(), - }); - } + match max_frame_size { + Some(frame_size) if *frame_size == 0 => errors.push(ValidationError::InvalidField { + field: format!("route '{path}' max_frame_size"), + message: "WebSocket max frame size must be greater than 0".to_string(), + }), + _ => {} } - if let Some(message_size) = max_message_size { - if *message_size == 0 { - errors.push(ValidationError::InvalidField { - field: format!("route '{path}' max_message_size"), - message: "WebSocket max message size must be greater than 0" - .to_string(), - }); - } + match max_message_size { + Some(message_size) if *message_size == 0 => errors.push(ValidationError::InvalidField { + field: format!("route '{path}' max_message_size"), + message: "WebSocket max message size must be greater than 0" + .to_string(), + }), + _ => {} } } } From c38ba5187d01eef5763ba8e654d9fb4f50327b07 Mon Sep 17 00:00:00 2001 From: Chahine-tech Date: Mon, 25 Aug 2025 14:54:50 +0200 Subject: [PATCH 3/7] refactor: improve readability of condition checks in HyperHandler and ConfigValidator --- src/adapters/http_handler.rs | 24 ++++++++++++------------ src/config/validation.rs | 26 ++++++++++++++++---------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/adapters/http_handler.rs b/src/adapters/http_handler.rs index 8265d15..4ff47ad 100644 --- a/src/adapters/http_handler.rs +++ b/src/adapters/http_handler.rs @@ -364,20 +364,20 @@ impl HyperHandler { None => return Ok(response_to_modify), }; - if let Some(condition) = &actions_config.condition { - match initial_req_ctx_opt { - Some(ctx) if !Self::check_condition(ctx, condition) => { - return Ok(response_to_modify); - } - Some(_) => {} - None => { - tracing::warn!( - "Condition specified for response body actions, but no context provided for check. Skipping actions." - ); - return Ok(response_to_modify); - } + if let Some(condition) = &actions_config.condition { + match initial_req_ctx_opt { + Some(ctx) if !Self::check_condition(ctx, condition) => { + return Ok(response_to_modify); + } + Some(_) => {} + None => { + tracing::warn!( + "Condition specified for response body actions, but no context provided for check. Skipping actions." + ); + return Ok(response_to_modify); } } + } if actions_config.set_text.is_none() && actions_config.set_json.is_none() { return Ok(response_to_modify); diff --git a/src/config/validation.rs b/src/config/validation.rs index d5e18eb..62b7c90 100644 --- a/src/config/validation.rs +++ b/src/config/validation.rs @@ -149,7 +149,9 @@ impl ConfigValidator { .. } => { if target.starts_with("http://") || target.starts_with("https://") { - if let Err(e) = Self::validate_url(target, &format!("route '{path}' redirect target")) { + if let Err(e) = + Self::validate_url(target, &format!("route '{path}' redirect target")) + { errors.push(e); } } @@ -178,19 +180,23 @@ impl ConfigValidator { } match max_frame_size { - Some(frame_size) if *frame_size == 0 => errors.push(ValidationError::InvalidField { - field: format!("route '{path}' max_frame_size"), - message: "WebSocket max frame size must be greater than 0".to_string(), - }), + Some(frame_size) if *frame_size == 0 => { + errors.push(ValidationError::InvalidField { + field: format!("route '{path}' max_frame_size"), + message: "WebSocket max frame size must be greater than 0".to_string(), + }) + } _ => {} } match max_message_size { - Some(message_size) if *message_size == 0 => errors.push(ValidationError::InvalidField { - field: format!("route '{path}' max_message_size"), - message: "WebSocket max message size must be greater than 0" - .to_string(), - }), + Some(message_size) if *message_size == 0 => { + errors.push(ValidationError::InvalidField { + field: format!("route '{path}' max_message_size"), + message: "WebSocket max message size must be greater than 0" + .to_string(), + }) + } _ => {} } } From c0faedf2cda5c09c3346be22cf967b00e527d013 Mon Sep 17 00:00:00 2001 From: Chahine-tech Date: Mon, 25 Aug 2025 15:00:07 +0200 Subject: [PATCH 4/7] refactor: streamline error handling in route validation --- src/config/validation.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/config/validation.rs b/src/config/validation.rs index 62b7c90..c23f161 100644 --- a/src/config/validation.rs +++ b/src/config/validation.rs @@ -149,9 +149,7 @@ impl ConfigValidator { .. } => { if target.starts_with("http://") || target.starts_with("https://") { - if let Err(e) = - Self::validate_url(target, &format!("route '{path}' redirect target")) - { + if let Err(e) = Self::validate_url(target, &format!("route '{path}' redirect target")) { errors.push(e); } } From 9cacbd9637dcd297a316b801a9123b6bef92c569 Mon Sep 17 00:00:00 2001 From: Chahine-tech Date: Mon, 25 Aug 2025 15:01:01 +0200 Subject: [PATCH 5/7] refactor: improve formatting of error handling in redirect target validation --- src/config/validation.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/config/validation.rs b/src/config/validation.rs index c23f161..62b7c90 100644 --- a/src/config/validation.rs +++ b/src/config/validation.rs @@ -149,7 +149,9 @@ impl ConfigValidator { .. } => { if target.starts_with("http://") || target.starts_with("https://") { - if let Err(e) = Self::validate_url(target, &format!("route '{path}' redirect target")) { + if let Err(e) = + Self::validate_url(target, &format!("route '{path}' redirect target")) + { errors.push(e); } } From 581f583253ea15d79309307762c5d69394d421ee Mon Sep 17 00:00:00 2001 From: Chahine-tech Date: Mon, 25 Aug 2025 15:05:32 +0200 Subject: [PATCH 6/7] refactor: allow collapsible if warnings in HyperHandler and ConfigValidator --- src/adapters/http_handler.rs | 2 ++ src/config/validation.rs | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/adapters/http_handler.rs b/src/adapters/http_handler.rs index 4ff47ad..09b033f 100644 --- a/src/adapters/http_handler.rs +++ b/src/adapters/http_handler.rs @@ -181,6 +181,7 @@ impl HyperHandler { Self::build_redirect_response(status, redirect_url) } + #[allow(clippy::collapsible_if)] fn check_condition(ctx: &RequestConditionContext, condition_config: &RequestCondition) -> bool { if let Some(path_regex_str) = &condition_config.path_matches { if let Ok(regex) = Regex::new(path_regex_str) { @@ -292,6 +293,7 @@ impl HyperHandler { } } + #[allow(clippy::collapsible_if)] async fn apply_body_actions_to_request( req: &mut Request, actions_config_opt: Option<&BodyActions>, diff --git a/src/config/validation.rs b/src/config/validation.rs index 62b7c90..aa4194e 100644 --- a/src/config/validation.rs +++ b/src/config/validation.rs @@ -52,6 +52,7 @@ pub struct ConfigValidator; impl ConfigValidator { /// Validate a complete server configuration + #[allow(clippy::collapsible_if)] pub fn validate(config: &ServerConfig) -> ValidationResult<()> { let mut errors = Vec::new(); @@ -104,6 +105,7 @@ impl ConfigValidator { /// Validate all route configurations /// Validate a single route configuration + #[allow(clippy::collapsible_if)] fn validate_single_route(path: &str, config: &RouteConfig) -> Result<(), Vec> { let mut errors = Vec::new(); @@ -391,6 +393,7 @@ impl ConfigValidator { } /// Validate ACME configuration + #[allow(clippy::collapsible_if)] fn validate_acme_config(config: &AcmeConfig) -> ValidationResult<()> { if !config.enabled { return Ok(()); // Skip validation if ACME is disabled From b138f5cd99817ba329a62d793957302954ca14ea Mon Sep 17 00:00:00 2001 From: Chahine-tech Date: Mon, 25 Aug 2025 15:09:47 +0200 Subject: [PATCH 7/7] chore: add rust-toolchain configuration for stable channel and components --- rust-toolchain.toml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 rust-toolchain.toml diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..d0ead5e --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "stable" +components = ["clippy", "rustfmt"]