Compare commits

...

3 Commits

Author SHA1 Message Date
Aravinth Manivannan
3a7e71b499 fix: exit loop when paginated DB query returns empty array
fixes: https://github.com/mCaptcha/mCaptcha/issues/154
2024-03-24 08:40:52 +05:30
Aravinth Manivannan
91955501e2 feat: enable easy PoW configuration auto-enhance by default 2024-03-24 08:37:26 +05:30
Aravinth Manivannan
cb72b0adfa Merge pull request #152 from mCaptcha/fix-151
fix: difficulty factor for "broke my site" should be greater than peak sustainable traffic"
2024-03-23 13:55:28 +05:30
2 changed files with 7 additions and 3 deletions

View File

@@ -34,11 +34,11 @@ enable_stats = true
[captcha.default_difficulty_strategy]
avg_traffic_difficulty = 50000 # almost instant solution
#avg_traffic_time = 1 # almost instant solution
avg_traffic_time = 1 # almost instant solution
peak_sustainable_traffic_difficulty = 3000000 # roughly 1.5s
#peak_sustainable_traffic_time = 3
peak_sustainable_traffic_time = 3
broke_my_site_traffic_difficulty = 5000000 # greater than 3.5s
#broke_my_site_traffic_time = 5
broke_my_site_traffic_time = 5
duration = 30 # cooldown period in seconds
[database]

View File

@@ -55,6 +55,9 @@ impl UpdateEasyCaptcha {
}
let mut patterns = data.db.get_all_easy_captchas(limit, offset).await?;
if patterns.is_empty() {
break;
}
for pattern in patterns.drain(0..) {
if !Self::can_run(rx) {
return Ok(());
@@ -85,6 +88,7 @@ impl UpdateEasyCaptcha {
}
page += 1;
}
Ok(())
}
fn can_run(rx: &mut Receiver<()>) -> bool {