mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-11 10:05:41 +00:00
Merge pull request #157 from mCaptcha/fix-154
fix: exit loop when paginated DB query in easy PoW auto-enhance loop returns empty array
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user