iwla/plugins/post_analysis/anonymize_ip.py
2022-11-10 20:06:00 +01:00

60 lines
1.3 KiB
Python

# -*- coding: utf-8 -*-
#
# Copyright Grégory Soutadé 2022
# This file is part of iwla
# iwla is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# iwla is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with iwla. If not, see <http://www.gnu.org/licenses/>.
#
import hashlib
from iwla import IWLA
from iplugin import IPlugin
"""
Post analysis hook
Replace remote_addr by a SHA1
Plugin requirements :
None
Conf values needed :
None
Output files :
None
Statistics creation :
None
Statistics update :
valid_visitors:
remote_addr
Statistics deletion :
None
"""
class IWLAPostAnalysisReverseDNS(IPlugin):
def hook(self):
hits = self.iwla.getCurrentVisits()
for (k, hit) in hits.items():
m = hashlib.sha1()
m.update(k.encode('utf-8'))
hit['remote_addr'] = m.hexdigest()[:16]