diff --git a/example-config.yaml b/example-config.yaml index 685f135..78b59e7 100644 --- a/example-config.yaml +++ b/example-config.yaml @@ -36,6 +36,6 @@ policy-groups: - name: robots.txt first-line: "^GET /robots.txt " action: allow - - name: Favicon - first-line: "^GET /favicon.ico " - action: allow + - name: Test + first-line: "^GET /test/[a-z]+/" + action: challenge diff --git a/src/main.rs b/src/main.rs index f04a526..4ff87b7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -143,10 +143,9 @@ async fn main() { } } - let mut allow = false; let mut valid_challenge = false; - - if let (Some(req_challenge), Some(req_proof)) = (req_challenge, req_proof) { + let mut allow = false; + if let Some(req_challenge) = req_challenge { valid_challenge = challenge::verify_challenge_cookie( req_challenge, &secret, @@ -154,8 +153,15 @@ async fn main() { req_ip, config.challenge_timeout, ); - allow = valid_challenge - && challenge::check_challenge(req_challenge, req_proof, TARGET_ZEROS); + + if let Some(req_proof) = req_proof { + allow = valid_challenge + && challenge::check_challenge( + req_challenge, + req_proof, + TARGET_ZEROS, + ); + } } if allow {