BE+FE: new fields handling in views and skipping device heuristics for random macs

Signed-off-by: jokob-sk <jokob.sk@gmail.com>
This commit is contained in:
jokob-sk
2026-01-30 09:09:39 +11:00
parent 6244daebcf
commit 2d6e357fe5
3 changed files with 8 additions and 35 deletions

View File

@@ -1,17 +1,3 @@
<!--
#---------------------------------------------------------------------------------#
# NetAlertX #
# Open Source Network Guard / WIFI & LAN intrusion detector #
# #
# devices.php - Front module. Devices list page #
#---------------------------------------------------------------------------------#
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3 #
# jokob-sk 2022 jokob.sk@gmail.com GNU GPLv3 #
# leiweibau 2022 https://github.com/leiweibau GNU GPLv3 #
# cvc90 2023 https://github.com/cvc90 GNU GPLv3 #
#---------------------------------------------------------------------------------#
-->
<?php <?php
require 'php/templates/header.php'; require 'php/templates/header.php';

View File

@@ -590,26 +590,6 @@ def normalize_string(text):
# MAC and IP helper methods # MAC and IP helper methods
# ------------------------------------------------------------------------------- # -------------------------------------------------------------------------------
# # -------------------------------------------------------------------------------------------
# def is_random_mac(mac: str) -> bool:
# """Determine if a MAC address is random, respecting user-defined prefixes not to mark as random."""
# is_random = mac[1].upper() in ["2", "6", "A", "E"]
# # Get prefixes from settings
# prefixes = get_setting_value("UI_NOT_RANDOM_MAC")
# # If detected as random, make sure it doesn't start with a prefix the user wants to exclude
# if is_random:
# for prefix in prefixes:
# if mac.upper().startswith(prefix.upper()):
# is_random = False
# break
# return is_random
# ------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------
def generate_mac_links(html, deviceUrl): def generate_mac_links(html, deviceUrl):
p = re.compile(r"(?:[0-9a-fA-F]:?){12}") p = re.compile(r"(?:[0-9a-fA-F]:?){12}")

View File

@@ -5,6 +5,7 @@ import base64
from pathlib import Path from pathlib import Path
from typing import Optional, Tuple from typing import Optional, Tuple
from logger import mylog from logger import mylog
from helpers import is_random_mac
# Register NetAlertX directories # Register NetAlertX directories
INSTALL_PATH = os.getenv("NETALERTX_APP", "/app") INSTALL_PATH = os.getenv("NETALERTX_APP", "/app")
@@ -176,6 +177,12 @@ def guess_device_attributes(
name = str(name).lower().strip() if name else "(unknown)" name = str(name).lower().strip() if name else "(unknown)"
mac_clean = mac.replace(":", "").replace("-", "").upper() mac_clean = mac.replace(":", "").replace("-", "").upper()
# --- Check for Random MAC ---
# If the MAC is randomized (private), skip vendor/heuristics assignment
if is_random_mac(mac):
mylog("debug", f"[guess_device_attributes] Random MAC detected ({mac}); returning defaults to avoid incorrect assignment.")
return default_icon, default_type
# # Internet shortcut # # Internet shortcut
# if mac == "INTERNET": # if mac == "INTERNET":
# return ICONS.get("globe", default_icon), DEVICE_TYPES.get("Internet", default_type) # return ICONS.get("globe", default_icon), DEVICE_TYPES.get("Internet", default_type)
@@ -261,4 +268,4 @@ def guess_type(
# Handler for when this is run as a program instead of called as a module. # Handler for when this is run as a program instead of called as a module.
if __name__ == "__main__": if __name__ == "__main__":
mylog("error", "This module is not intended to be run directly.") mylog("none", "This module is not intended to be run directly.")