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" 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"] 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..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) { @@ -255,15 +256,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; } } @@ -289,6 +293,7 @@ impl HyperHandler { } } + #[allow(clippy::collapsible_if)] async fn apply_body_actions_to_request( req: &mut Request, actions_config_opt: Option<&BodyActions>, @@ -363,11 +368,10 @@ impl HyperHandler { 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(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." diff --git a/src/config/validation.rs b/src/config/validation.rs index 0ad9a5f..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(); @@ -156,13 +158,14 @@ impl ConfigValidator { } } - 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 +181,25 @@ impl ConfigValidator { errors.push(e); } - if let Some(frame_size) = max_frame_size { - if *frame_size == 0 { + 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 { + 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(), - }); + }) } + _ => {} } } } @@ -388,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