From f468903b0057c414adf18912f8bc52571e0e1015 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 15 Jul 2024 11:53:43 +0000 Subject: [PATCH 1/4] =?UTF-8?q?[=F0=9F=A4=96Automation]=20Update=20README?= =?UTF-8?q?=20with=20sponsors=20information?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From b45e82b2a0dd22ab4190b739b6466546359042f7 Mon Sep 17 00:00:00 2001 From: jokob-sk Date: Tue, 16 Jul 2024 20:27:15 +1000 Subject: [PATCH 2/4] =?UTF-8?q?=E2=9D=8C=20NEWDEV=5FLESS=5FNAME=5FCLEANUP?= =?UTF-8?q?=20+=20Internet=20ParentNode=20fix=20+=20=F0=9F=93=9ADocs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/php/templates/header.php | 8 ++--- front/plugins/README.md | 4 +-- front/plugins/__test/test.py | 6 ++-- front/plugins/newdev_template/config.json | 28 ----------------- front/settings.php | 20 ++++++------ server/device.py | 20 ++++++++++-- server/helper.py | 38 ++--------------------- 7 files changed, 40 insertions(+), 84 deletions(-) diff --git a/front/php/templates/header.php b/front/php/templates/header.php index c1b8647b..4c0e682d 100755 --- a/front/php/templates/header.php +++ b/front/php/templates/header.php @@ -341,7 +341,7 @@ if ($ENABLED_DARKMODE === True) { diff --git a/front/plugins/README.md b/front/plugins/README.md index 1d7064e7..17a0f58b 100755 --- a/front/plugins/README.md +++ b/front/plugins/README.md @@ -37,7 +37,7 @@ Device-detecting plugins insert values into the `CurrentScan` database table. T | `INTRSPD` | ♻ | Internet speed test | | Script | [internet_speedtest](/front/plugins/internet_speedtest/) | | `MAINT` | ⚙ | Maintenance of logs, etc. | | Script | [maintenance](/front/plugins/maintenance/) | | `MQTT` | ▶️ | MQTT for synching to Home Assistant | | Script | [_publisher_mqtt](/front/plugins/_publisher_mqtt/) | -| `NBTSCAN` | ♻ | NSLookup (NetBIOS-based) name resolution | | Script | [nbtscan_scan](/front/plugins/nbtscan_scan/) | +| `NBTSCAN` | ♻ | Nbtscan (NetBIOS-based) name resolution | | Script | [nbtscan_scan](/front/plugins/nbtscan_scan/) | | `NEWDEV` | ⚙ | New device template | Yes | Template | [newdev_template](/front/plugins/newdev_template/) | | `NMAP` | ♻ | Nmap port scanning & discovery | | Script | [nmap_scan](/front/plugins/nmap_scan/) | | `NMAPDEV` | 🔍 | Nmap dev scan on current network | | Script | [nmap_dev_scan](/front/plugins/nmap_dev_scan/) | @@ -80,7 +80,7 @@ Device-detecting plugins insert values into the `CurrentScan` database table. T Plugins can be enabled via Settings, and can be disabled as needed. -1. Research which plugin you'd like to use below and then load the required plugins in Settings via the `LOADED_PLUGINS` setting. +1. Research which plugin you'd like to use and load the required plugins in Settings via the `LOADED_PLUGINS` setting. 1. Save the changes and review the Settings of the newly loaded plugins. 1. Change the `_RUN` Setting to the recommended or custom value as per the documentation of the given setting - If using `schedule` on a `🔍 dev scanner` plugin, make sure the schedules are the same across all `🔍 dev scanner` plugins diff --git a/front/plugins/__test/test.py b/front/plugins/__test/test.py index fb2cc51a..69b2f9ca 100755 --- a/front/plugins/__test/test.py +++ b/front/plugins/__test/test.py @@ -60,11 +60,11 @@ def main(): print(subnets) for rgx in regexes: - mylog('debug', ["[cleanDeviceName] applying regex : " + rgx]) - mylog('debug', ["[cleanDeviceName] name before regex : " + str]) + mylog('trace', ["[cleanDeviceName] applying regex : " + rgx]) + mylog('trace', ["[cleanDeviceName] name before regex : " + str]) str = re.sub(rgx, "", str) - mylog('debug', ["[cleanDeviceName] name after regex : " + str]) + mylog('trace', ["[cleanDeviceName] name after regex : " + str]) mylog('debug', ["[cleanDeviceName] output: " + str]) diff --git a/front/plugins/newdev_template/config.json b/front/plugins/newdev_template/config.json index b29f78c4..1d2b0357 100755 --- a/front/plugins/newdev_template/config.json +++ b/front/plugins/newdev_template/config.json @@ -176,34 +176,6 @@ } ] }, - { - "function": "LESS_NAME_CLEANUP", - "type": { - "dataType": "boolean", - "elements": [ - { - "elementType": "input", - "elementOptions": [{ "type": "checkbox" }], - "transformers": [] - } - ] - }, - "default_value": 0, - "options": [], - "localized": ["name", "description"], - "name": [ - { - "language_code": "en_us", - "string": "Less Name Cleanup" - } - ], - "description": [ - { - "language_code": "en_us", - "string": "Check to start using the new code for cleaning device names. Removes all labels starting with underscore and removes network domain and search list." - } - ] - }, { "function": "NAME_CLEANUP_REGEX", "type": { diff --git a/front/settings.php b/front/settings.php index e1c2d920..7fbae9e4 100755 --- a/front/settings.php +++ b/front/settings.php @@ -114,21 +114,21 @@ $settingsJSON_DB = json_encode($settings, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX
-
+
">
-
+
">
-
+
">
@@ -285,12 +285,14 @@ $settingsJSON_DB = json_encode($settings, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX overviewSections_html += `
-
- - - - ${getString("settings_"+section+"_label")} -
+ +
+ + + + ${getString("settings_"+section+"_label")} +
+
${overviewSectionsHtml[index]} diff --git a/server/device.py b/server/device.py index cff15651..3445920e 100755 --- a/server/device.py +++ b/server/device.py @@ -223,18 +223,32 @@ def create_new_devices (db): ) SELECT cur_MAC, - CASE WHEN LENGTH(TRIM(cur_Name)) > 0 THEN cur_Name ELSE '(unknown)' END, + CASE + WHEN LENGTH(TRIM(cur_Name)) > 0 THEN cur_Name ELSE '(unknown)' + END, cur_Vendor, cur_IP, ?, ?, cur_SyncHubNodeName, {sql_generateGuid}, - CASE WHEN LENGTH(TRIM(cur_NetworkNodeMAC)) > 0 THEN cur_NetworkNodeMAC ELSE '{get_setting_value('NEWDEV_dev_Network_Node_MAC_ADDR')}' END, + CASE + WHEN LENGTH(TRIM(cur_NetworkNodeMAC)) > 0 + AND cur_MAC != 'Internet' + THEN cur_NetworkNodeMAC + ELSE + CASE + WHEN cur_MAC = 'Internet' + THEN 'null' + ELSE '{get_setting_value('NEWDEV_dev_Network_Node_MAC_ADDR')}' + END + END, cur_PORT, cur_NetworkSite, cur_SSID, - CASE WHEN LENGTH(TRIM(cur_Type)) > 0 THEN cur_Type ELSE '{get_setting_value('NEWDEV_dev_DeviceType')}' END, + CASE + WHEN LENGTH(TRIM(cur_Type)) > 0 THEN cur_Type ELSE '{get_setting_value('NEWDEV_dev_DeviceType')}' + END, {newDevDefaults} FROM CurrentScan WHERE 1=1 diff --git a/server/helper.py b/server/helper.py index 2866e599..53412ad0 100755 --- a/server/helper.py +++ b/server/helper.py @@ -727,38 +727,6 @@ def cleanDeviceName(str, match_IP): # add matching info if match_IP: str = str + " (IP match)" - - - if get_setting_value('NEWDEV_LESS_NAME_CLEANUP'): - mylog('debug', ["[Name cleanup] Using new cleanDeviceName(" + str + ")"]) - - # replace all labels starting with underscore - str = re.sub(r'^_[^\.]*\.', '', str) # leading label - str = re.sub(r'\._[^\.]*\.', '.', str) # nested label - - # get a stub resolver for access to resolv.conf configuration - resolv = dns.resolver.Resolver() - - # replace the local domain name - str = re.sub(r'\.' + resolv.domain.to_text() + r'$', '', str) - - # replace dns search list - for name in resolv.search: - str = re.sub(r'\.' + name.to_text() + r'$', '', str) - - # removing last part of e.g. Nest-Audio-ff77ff77ff77ff77ff77ff77ff77ff77 - str = re.sub(r'-[a-fA-F0-9]{32}', '', str) - - # Remove everything after '#' including the '#' - str = re.sub(r'#.*', '', str) - - # remove trailing dot - if str.endswith('.'): - str = str[:-1] - - # done - mylog('debug', ["[Name cleanup] cleanDeviceName = " + str]) - return str # Applying cleanup REGEXEs mylog('debug', ["[Name cleanup] Using old cleanDeviceName(" + str + ")"]) @@ -766,10 +734,10 @@ def cleanDeviceName(str, match_IP): regexes = get_setting_value('NEWDEV_NAME_CLEANUP_REGEX') for rgx in regexes: - mylog('debug', ["[cleanDeviceName] applying regex : " + rgx]) - mylog('debug', ["[cleanDeviceName] name before regex : " + str]) + mylog('trace', ["[cleanDeviceName] applying regex : " + rgx]) + mylog('trace', ["[cleanDeviceName] name before regex : " + str]) str = re.sub(rgx, "", str) - mylog('debug', ["[cleanDeviceName] name after regex : " + str]) + mylog('trace', ["[cleanDeviceName] name after regex : " + str]) str = re.sub(r'\.\b', '', str) # trailing dot after words str = re.sub(r'\.$', '', str) # trailing dot at the end of the string From fa00fa30045f4dfac74e95d0b0536b81fab0000e Mon Sep 17 00:00:00 2001 From: jokob-sk <96159884+jokob-sk@users.noreply.github.com> Date: Tue, 16 Jul 2024 20:31:48 +1000 Subject: [PATCH 3/4] Update i-have-an-issue.yml --- .github/ISSUE_TEMPLATE/i-have-an-issue.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/i-have-an-issue.yml b/.github/ISSUE_TEMPLATE/i-have-an-issue.yml index b50ae9b3..3e06e85a 100755 --- a/.github/ISSUE_TEMPLATE/i-have-an-issue.yml +++ b/.github/ISSUE_TEMPLATE/i-have-an-issue.yml @@ -1,5 +1,5 @@ name: Bug Report -description: 'When submitting an issue enable debug and have a look at the docs.' +description: 'When submitting an issue enable LOG_LEVEL="trace" and have a look at the docs.' labels: ['bug 🐛'] body: - type: checkboxes @@ -64,7 +64,7 @@ body: ***Generally speaking, all bug reports should have logs provided.*** Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in. Additionally, any additional info? Screenshots? References? Anything that will give us more context about the issue you are encountering! - You can use `tail -100 /app/front/log/app.log` in the container if you have troubles getting to the log files. + You can use `tail -100 /app/front/log/app.log` in the container if you have trouble getting to the log files. validations: required: false - type: checkboxes From fb8a7432cdbd7c50baec56fd9ced6d8b9b2f9fd3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 16 Jul 2024 11:53:35 +0000 Subject: [PATCH 4/4] =?UTF-8?q?[=F0=9F=A4=96Automation]=20Update=20README?= =?UTF-8?q?=20with=20sponsors=20information?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit