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("""
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: