From 7ec7e0d64449d0dd410deb37a771c4c92dd90dbd Mon Sep 17 00:00:00 2001 From: Gregory Soutade Date: Fri, 4 Nov 2022 20:03:52 +0100 Subject: [PATCH] Add Geo IP location in filter users --- plugins/post_analysis/filter_users.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/plugins/post_analysis/filter_users.py b/plugins/post_analysis/filter_users.py index 682ce8f..3b16407 100644 --- a/plugins/post_analysis/filter_users.py +++ b/plugins/post_analysis/filter_users.py @@ -23,6 +23,7 @@ import re from iwla import IWLA from iplugin import IPlugin from display import * +from misc.geoiplookup import geoiplookup """ Post analysis hook @@ -67,6 +68,7 @@ Statistics creation : visits : remote_addr => filtered + geo_location Statistics update : visits : @@ -167,10 +169,19 @@ class IWLAPostAnalysisFilterUsers(IPlugin): hits = self.iwla.getValidVisitors() - if len(self.filters) or len(self.ip_filters): - for (key,value) in hits.items(): - if self._do_filter(key, hits): - print('Keep for {}'.format(key)) - value['filtered'] = True - value['keep_requests'] = True + for (key,value) in hits.items(): + # Already filtered + if value.get('filtered', False): + continue + + if self._do_filter(key, hits): + value['filtered'] = True + value['keep_requests'] = True + try: + if not value.get('geo_location', None): + value['geo_location'] = geoiplookup(value['remote_ip']) + except Exception as e: + print(e) + +