mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 01:26:11 -08:00
skip invalid dhcp.leases entries #516🩹
This commit is contained in:
@@ -11,7 +11,7 @@ import chardet
|
||||
sys.path.append("/home/pi/pialert/front/plugins")
|
||||
sys.path.append('/home/pi/pialert/pialert')
|
||||
|
||||
from plugin_helper import Plugin_Object, Plugin_Objects, handleEmpty
|
||||
from plugin_helper import Plugin_Object, Plugin_Objects, handleEmpty, is_mac
|
||||
from logger import mylog
|
||||
from dhcp_leases import DhcpLeases
|
||||
|
||||
@@ -76,6 +76,10 @@ def get_entries(path, plugin_objects):
|
||||
leases = DhcpLeases(path)
|
||||
leasesList = leases.get()
|
||||
for lease in leasesList:
|
||||
|
||||
# filter out irrelevant entries (e.g. from OPNsense dhcp.leases files)
|
||||
if is_mac(lease.ethernet):
|
||||
|
||||
plugin_objects.add_object(
|
||||
primaryId = handleEmpty(lease.ethernet),
|
||||
secondaryId = handleEmpty(lease.ip),
|
||||
|
||||
@@ -45,6 +45,11 @@ def handleEmpty(input):
|
||||
input = re.sub(r'[^\x00-\x7F]+', ' ', input)
|
||||
return input
|
||||
|
||||
# -------------------------------------------------------------------
|
||||
# Check if a valid MAC address
|
||||
def is_mac(input):
|
||||
return re.match("[0-9a-f]{2}([-:]?)[0-9a-f]{2}(\\1[0-9a-f]{2}){4}$", input.lower())
|
||||
|
||||
# -------------------------------------------------------------------
|
||||
def decodeBase64(inputParamBase64):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user