From 364f89d3d41fd2b9882057851e5e289b7efdfa7f 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