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: