From dd85af1b610b7f55bbfb2940a4325337291372ee Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Fri, 12 Dec 2014 22:56:42 +0100 Subject: [PATCH] replace slow strptime with regex, fix typos --- utils/cron_ipanalyse.py | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/utils/cron_ipanalyse.py b/utils/cron_ipanalyse.py index 40afa2b8..2d0738af 100755 --- a/utils/cron_ipanalyse.py +++ b/utils/cron_ipanalyse.py @@ -30,9 +30,9 @@ BLACKLIST = '' UA_BLOCKLIST = () # time before a automatically blocked IP is allowed back -BLOCKCOOLOFF_PERIOD=timedelta(hours=1) +BLOCKCOOLOFF_DELTA=timedelta(hours=1) # quiet time before an IP is released from the bulk pool -BULKCOOLOFF_PERIOD=timedelta(minutes=15) +BULKCOOLOFF_DELTA=timedelta(minutes=15) BULKLONG_LIMIT=8000 BULKSHORT_LIMIT=2000 @@ -50,18 +50,22 @@ MAX_BULK_IPS=85 try: with open(BASEDIR + "/settings/ip_blocks.conf") as f: code = compile(f.read(), BASEDIR + "/settings/ip_blocks.conf", 'exec') - exec(code, global_vars, local_vars) + exec(code) except IOError: pass BLOCK_LIMIT = BLOCK_LOWER +time_regex = r'(?P\d\d)/(?P[A-Za-z]+)/(?P\d\d\d\d):(?P\d\d):(?P\d\d):(?P\d\d) [+-]\d\d\d\d' -format_pat= re.compile('(?P[(\d\.)]+) - - \[(?P