From ca5b70cd24aa5fd9ef856847e547b2ae4b7ca569 Mon Sep 17 00:00:00 2001 From: Cyril Jaquier Date: Sun, 20 Aug 2006 22:32:44 +0000 Subject: [PATCH] - Fixed a bug with static class members git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@283 a942ae1a-1317-0410-a47c-b1dcaea8d605 --- client/jailreader.py | 4 +++- server/filter.py | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/client/jailreader.py b/client/jailreader.py index af66b1a4..6bd712a2 100644 --- a/client/jailreader.py +++ b/client/jailreader.py @@ -34,6 +34,8 @@ logSys = logging.getLogger("fail2ban.client.config") class JailReader(ConfigReader): + actionCRE = re.compile("^((?:\w|-|_|\.)+)(?:\[(.*)\])?$") + def __init__(self, name): ConfigReader.__init__(self) self.name = name @@ -92,7 +94,7 @@ class JailReader(ConfigReader): @staticmethod def splitAction(action): - m = re.match("^((?:\w|-|_|\.)+)(?:\[(.*)\])?$", action) + m = JailReader.actionCRE.match(action) d = dict() if m.group(2) <> None: for param in m.group(2).split(','): diff --git a/server/filter.py b/server/filter.py index 3d51d3ed..081a83e7 100644 --- a/server/filter.py +++ b/server/filter.py @@ -468,8 +468,8 @@ import socket, struct class DNSUtils: - dnsRe = re.compile("(?:(?:\w|-)+\.){2,}\w+") - ipRe = re.compile("(?:\d{1,3}\.){3}\d{1,3}") + dnsCRE = re.compile("(?:(?:\w|-)+\.){2,}\w+") + ipCRE = re.compile("(?:\d{1,3}\.){3}\d{1,3}") @staticmethod def dnsToIp(dns): @@ -486,7 +486,7 @@ class DNSUtils: """ Search for possible DNS in an arbitrary text. Thanks to Tom Pike. """ - match = dnsRe.find(text) + match = DNSUtils.dnsCRE.match(text) if match: return match else: @@ -497,7 +497,8 @@ class DNSUtils: """ Search if an IP address if directly available and return it. """ - match = ipRe.find(text) + print DNSUtils.ipCRE + match = DNSUtils.ipCRE.match(text) if match: return match else: