X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/14097fe1df35930481aea443a30a71cf3de3f922..de978c9987ddbb6595029b23b5dfd2823fc4ea3f:/utils/cron_banip.py diff --git a/utils/cron_banip.py b/utils/cron_banip.py index 17268bc1..53f5e5f1 100755 --- a/utils/cron_banip.py +++ b/utils/cron_banip.py @@ -114,6 +114,11 @@ BLOCK_LIMIT = max(BLOCK_LOWER, BLOCK_UPPER - BLOCK_LOADFAC * (dbload - 75)) BULKLONG_LIMIT = max(BULK_LOWER, BULKLONG_LIMIT - BULK_LOADFAC * (avgload - 14)) if len(prevbulks) > MAX_BULK_IPS: BLOCK_LIMIT = max(3600, BLOCK_LOWER - (len(prevbulks) - MAX_BULK_IPS)*10) +# if the bulk pool is still empty, clients will be faster, avoid having +# them blocked in this case +if len(prevbulks) < 10: + BLOCK_LIMIT = 2*BLOCK_UPPER + # get the new block candidates cur.execute(""" @@ -168,15 +173,16 @@ for ip in prevblocks: deblockcandidates.add(ip) for ip in prevbulks: - if ip in bulkips: - if bulkips[ip] > BLOCK_LIMIT: - newblocks.add(ip) - newlyblocked.append(ip) + if ip not in newblocks: + if ip in bulkips: + if bulkips[ip] > BLOCK_LIMIT: + newblocks.add(ip) + newlyblocked.append(ip) + else: + newbulks.add(ip) + del bulkips[ip] else: - newbulks.add(ip) - del bulkips[ip] - else: - debulkcandidates.add(ip) + debulkcandidates.add(ip) # cross-check deblock candidates if deblockcandidates: