mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
BE: NEWDEV setting to disable IP match for names
Signed-off-by: jokob-sk <jokob.sk@gmail.com>
This commit is contained in:
@@ -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",
|
"function": "replace_preset_icon",
|
||||||
"type": {
|
"type": {
|
||||||
|
|||||||
@@ -40,16 +40,18 @@ class NameResolver:
|
|||||||
raw = result[0][0]
|
raw = result[0][0]
|
||||||
return ResolvedName(raw, self.clean_device_name(raw, False))
|
return ResolvedName(raw, self.clean_device_name(raw, False))
|
||||||
|
|
||||||
# Check by IP
|
# Check name by IP if enabled
|
||||||
sql.execute(f"""
|
if get_setting_value('NEWDEV_IP_MATCH_NAME'):
|
||||||
SELECT Watched_Value2 FROM Plugins_Objects
|
|
||||||
WHERE Plugin = '{plugin}' AND Object_SecondaryID = '{pIP}'
|
sql.execute(f"""
|
||||||
""")
|
SELECT Watched_Value2 FROM Plugins_Objects
|
||||||
result = sql.fetchall()
|
WHERE Plugin = '{plugin}' AND Object_SecondaryID = '{pIP}'
|
||||||
# self.db.commitDB() # Issue #1251: Optimize name resolution lookup
|
""")
|
||||||
if result:
|
result = sql.fetchall()
|
||||||
raw = result[0][0]
|
# self.db.commitDB() # Issue #1251: Optimize name resolution lookup
|
||||||
return ResolvedName(raw, self.clean_device_name(raw, True))
|
if result:
|
||||||
|
raw = result[0][0]
|
||||||
|
return ResolvedName(raw, self.clean_device_name(raw, True))
|
||||||
|
|
||||||
return nameNotFound
|
return nameNotFound
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user