Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
channel = "stable"
components = ["clippy", "rustfmt"]
7 changes: 3 additions & 4 deletions src/adapters/acme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 16 additions & 12 deletions src/adapters/http_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
}

Expand All @@ -289,6 +293,7 @@ impl HyperHandler {
}
}

#[allow(clippy::collapsible_if)]
async fn apply_body_actions_to_request(
req: &mut Request<AxumBody>,
actions_config_opt: Option<&BodyActions>,
Expand Down Expand Up @@ -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."
Expand Down
22 changes: 14 additions & 8 deletions src/config/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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<ValidationError>> {
let mut errors = Vec::new();

Expand Down Expand Up @@ -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 {
Expand All @@ -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(),
});
})
}
_ => {}
}
}
}
Expand Down Expand Up @@ -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
Expand Down
Loading