diff --git a/front/devices.php b/front/devices.php index 61d91020..1655bf28 100755 --- a/front/devices.php +++ b/front/devices.php @@ -1,17 +1,3 @@ - - 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): p = re.compile(r"(?:[0-9a-fA-F]:?){12}") diff --git a/server/scan/device_heuristics.py b/server/scan/device_heuristics.py index 15f9a0ad..2fda4ff4 100755 --- a/server/scan/device_heuristics.py +++ b/server/scan/device_heuristics.py @@ -5,6 +5,7 @@ import base64 from pathlib import Path from typing import Optional, Tuple from logger import mylog +from helpers import is_random_mac # Register NetAlertX directories INSTALL_PATH = os.getenv("NETALERTX_APP", "/app") @@ -176,6 +177,12 @@ def guess_device_attributes( name = str(name).lower().strip() if name else "(unknown)" 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 # if mac == "INTERNET": # 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. 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.")