]> git.openstreetmap.org Git - nominatim.git/blobdiff - utils/cron_banip.py
log UA blocks properly
[nominatim.git] / utils / cron_banip.py
index 36d0be4ebc07130066a831e5d9b9bfec331c97b2..714df2831c5e81e74ac676ccbee0b621daa42ec7 100755 (executable)
@@ -129,13 +129,16 @@ cur.execute("""
 
 bulkips = {}
 emergencyblocks = []
 
 bulkips = {}
 emergencyblocks = []
+useragentblocks = []
 
 for c in cur:
     if c[0] not in WHITELIST and c[0] not in BLACKLIST:
         missing_agent = not c[2] or c[2].startswith('Java/1.')
         if (missing_agent or c[1] > BLOCK_UPPER) and c[0] not in prevblocks:
             newblocks.add(c[0])
 
 for c in cur:
     if c[0] not in WHITELIST and c[0] not in BLACKLIST:
         missing_agent = not c[2] or c[2].startswith('Java/1.')
         if (missing_agent or c[1] > BLOCK_UPPER) and c[0] not in prevblocks:
             newblocks.add(c[0])
-            if c[0] not in prevbulks:
+            if missing_agent:
+                useragentblocks.append(c[0])
+            else:
                 emergencyblocks.append(c[0])
         else:
             bulkips[c[0]] = c[1]
                 emergencyblocks.append(c[0])
         else:
             bulkips[c[0]] = c[1]
@@ -218,6 +221,8 @@ if bulkips:
     fd.write(logstr % ('new bulks:', ', '.join(bulkips.keys())))
 if emergencyblocks:
     fd.write(logstr % ('dir.block:', ', '.join(emergencyblocks)))
     fd.write(logstr % ('new bulks:', ', '.join(bulkips.keys())))
 if emergencyblocks:
     fd.write(logstr % ('dir.block:', ', '.join(emergencyblocks)))
+if useragentblocks:
+    fd.write(logstr % (' ua block:', ', '.join(useragentblocks)))
 if newlyblocked:
     fd.write(logstr % ('new block:', ', '.join(newlyblocked)))
 fd.close()
 if newlyblocked:
     fd.write(logstr % ('new block:', ', '.join(newlyblocked)))
 fd.close()