From 50fb09104ea0b2714e8893cee0b3005b32e8bec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Wed, 17 Dec 2014 21:06:48 +0100 Subject: [PATCH] Filter by domain name --- iwla.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/iwla.py b/iwla.py index befe36d..7a43ceb 100755 --- a/iwla.py +++ b/iwla.py @@ -124,6 +124,7 @@ class IWLA(object): self.http_request_extracted = re.compile(r'(?P\S+) (?P\S+) (?P\S+)') self.log_re = re.compile(self.log_format_extracted) self.uri_re = re.compile(r'(?P[^\?]+)(\?(?P.+))?') + self.domain_name_re = re.compile(r'.*%s' % conf.domain_name) self.plugins = [(conf.PRE_HOOK_DIRECTORY , conf.pre_analysis_hooks), (conf.POST_HOOK_DIRECTORY , conf.post_analysis_hooks), (conf.DISPLAY_HOOK_DIRECTORY , conf.display_hooks)] @@ -582,6 +583,9 @@ class IWLA(object): self.current_analysis['days_stats'][cur_time.tm_mday] = stats def _newHit(self, hit): + if not self.domain_name_re.match(hit['server_name']): + return False + t = self._decodeTime(hit) cur_time = self.meta_infos['last_time'] @@ -609,7 +613,7 @@ class IWLA(object): for k in hit.keys(): if hit[k] == '-' or hit[k] == '*': hit[k] = '' - + self._appendHit(hit) return True @@ -637,8 +641,7 @@ class IWLA(object): groups = self.log_re.match(l) if groups: - if not self._newHit(groups.groupdict()): - continue + self._newHit(groups.groupdict()) else: self.logger.warning("No match for %s" % (l)) #break