From 1f622d19f171e859ed878704beeb2dd3bdad1e26 Mon Sep 17 00:00:00 2001 From: Jean-Romain Garnier Date: Fri, 24 Apr 2020 23:02:55 +0200 Subject: [PATCH] Auto format MAC addresses inmachine history search --- logs/models.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/logs/models.py b/logs/models.py index 942a76a4..2641ed24 100644 --- a/logs/models.py +++ b/logs/models.py @@ -26,6 +26,7 @@ from django.utils.translation import ugettext_lazy as _ from django.contrib.auth.models import Group from django.db.models import Q from django.apps import apps +from netaddr import EUI from machines.models import IpList from machines.models import Interface @@ -149,9 +150,16 @@ class MachineHistorySearch: self.events = [] if search_type == "ip": - return self._get_by_ip(search)[::-1] + try: + return self._get_by_ip(search)[::-1] + except: + pass elif search_type == "mac": - return self._get_by_mac(search)[::-1] + try: + search = EUI(search) + return self._get_by_mac(search)[::-1] + except: + pass return None