From b6567ab5fc37beca030b4eec38f9b4dfe654b56f Mon Sep 17 00:00:00 2001 From: jokob-sk Date: Thu, 13 Nov 2025 20:22:34 +1100 Subject: [PATCH] BE: NEWDEV setting to disable IP match for names Signed-off-by: jokob-sk --- front/plugins/newdev_template/config.json | 35 +++++++++++++++++++++++ server/scan/name_resolution.py | 22 +++++++------- 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/front/plugins/newdev_template/config.json b/front/plugins/newdev_template/config.json index fbb6f547..3ac8a9bb 100755 --- a/front/plugins/newdev_template/config.json +++ b/front/plugins/newdev_template/config.json @@ -419,6 +419,41 @@ } ] }, + { + "function": "IP_MATCH_NAME", + "type": { + "dataType": "boolean", + "elements": [ + { + "elementType": "input", + "elementOptions": [ + { + "type": "checkbox" + } + ], + "transformers": [] + } + ] + }, + "default_value": true, + "options": [], + "localized": [ + "name", + "description" + ], + "name": [ + { + "language_code": "en_us", + "string": "Name IP match" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "If checked, the application will guess the name also by IPs, not only MACs. This approach works if your IPs are mostly static." + } + ] + }, { "function": "replace_preset_icon", "type": { diff --git a/server/scan/name_resolution.py b/server/scan/name_resolution.py index 8984b4c0..e331b786 100755 --- a/server/scan/name_resolution.py +++ b/server/scan/name_resolution.py @@ -40,16 +40,18 @@ class NameResolver: raw = result[0][0] return ResolvedName(raw, self.clean_device_name(raw, False)) - # Check by IP - sql.execute(f""" - SELECT Watched_Value2 FROM Plugins_Objects - WHERE Plugin = '{plugin}' AND Object_SecondaryID = '{pIP}' - """) - result = sql.fetchall() - # self.db.commitDB() # Issue #1251: Optimize name resolution lookup - if result: - raw = result[0][0] - return ResolvedName(raw, self.clean_device_name(raw, True)) + # Check name by IP if enabled + if get_setting_value('NEWDEV_IP_MATCH_NAME'): + + sql.execute(f""" + SELECT Watched_Value2 FROM Plugins_Objects + WHERE Plugin = '{plugin}' AND Object_SecondaryID = '{pIP}' + """) + result = sql.fetchall() + # self.db.commitDB() # Issue #1251: Optimize name resolution lookup + if result: + raw = result[0][0] + return ResolvedName(raw, self.clean_device_name(raw, True)) return nameNotFound