]> git.openstreetmap.org Git - nominatim.git/blobdiff - utils/cron_banip.py
ignore encoding errors when reading log files
[nominatim.git] / utils / cron_banip.py
index 17268bc15a48f0d49b90108442a6d9eca9c0b9ea..53f5e5f13ab64a1b5527466bc2d84de35b679e73 100755 (executable)
@@ -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: