❌ NEWDEV_LESS_NAME_CLEANUP + Internet ParentNode fix + 📚Docs
This commit is contained in:
@@ -341,7 +341,7 @@ if ($ENABLED_DARKMODE === True) {
|
|||||||
</a>
|
</a>
|
||||||
<ul class="treeview-menu" style="display: <?php if (in_array (basename($_SERVER['SCRIPT_NAME']), array('settings.php') ) ){ echo 'block'; } else {echo 'none';} ?>;">
|
<ul class="treeview-menu" style="display: <?php if (in_array (basename($_SERVER['SCRIPT_NAME']), array('settings.php') ) ){ echo 'block'; } else {echo 'none';} ?>;">
|
||||||
<li>
|
<li>
|
||||||
<a href="settings.php#pageTitle"> <?= lang("settings_enabled");?> </a>
|
<a href="settings.php#settingsOverview"> <?= lang("settings_enabled");?> </a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="settings.php#core_content_header"> <?= lang("settings_core_label");?> </a>
|
<a href="settings.php#core_content_header"> <?= lang("settings_core_label");?> </a>
|
||||||
@@ -350,13 +350,13 @@ if ($ENABLED_DARKMODE === True) {
|
|||||||
<a href="settings.php#system_content_header"> <?= lang("settings_system_label");?> </a>
|
<a href="settings.php#system_content_header"> <?= lang("settings_system_label");?> </a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="settings.php#device_scanner_content_header"> <?= lang("settings_device_scanners_label");?> </a>
|
<a href="settings.php#device_scanners_content_header"> <?= lang("settings_device_scanners_label");?> </a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="settings.php#other_content_header"> <?= lang("settings_other_scanners_label");?> </a>
|
<a href="settings.php#other_scanners_content_header"> <?= lang("settings_other_scanners_label");?> </a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="settings.php#publisher_content_header"> <?= lang("settings_publishers_label");?> </a>
|
<a href="settings.php#publishers_content_header"> <?= lang("settings_publishers_label");?> </a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -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/) |
|
| `INTRSPD` | ♻ | Internet speed test | | Script | [internet_speedtest](/front/plugins/internet_speedtest/) |
|
||||||
| `MAINT` | ⚙ | Maintenance of logs, etc. | | Script | [maintenance](/front/plugins/maintenance/) |
|
| `MAINT` | ⚙ | Maintenance of logs, etc. | | Script | [maintenance](/front/plugins/maintenance/) |
|
||||||
| `MQTT` | ▶️ | MQTT for synching to Home Assistant | | Script | [_publisher_mqtt](/front/plugins/_publisher_mqtt/) |
|
| `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/) |
|
| `NEWDEV` | ⚙ | New device template | Yes | Template | [newdev_template](/front/plugins/newdev_template/) |
|
||||||
| `NMAP` | ♻ | Nmap port scanning & discovery | | Script | [nmap_scan](/front/plugins/nmap_scan/) |
|
| `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/) |
|
| `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.
|
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. Save the changes and review the Settings of the newly loaded plugins.
|
||||||
1. Change the `<prefix>_RUN` Setting to the recommended or custom value as per the documentation of the given setting
|
1. Change the `<prefix>_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
|
- If using `schedule` on a `🔍 dev scanner` plugin, make sure the schedules are the same across all `🔍 dev scanner` plugins
|
||||||
|
|||||||
@@ -60,11 +60,11 @@ def main():
|
|||||||
print(subnets)
|
print(subnets)
|
||||||
|
|
||||||
for rgx in regexes:
|
for rgx in regexes:
|
||||||
mylog('debug', ["[cleanDeviceName] applying regex : " + rgx])
|
mylog('trace', ["[cleanDeviceName] applying regex : " + rgx])
|
||||||
mylog('debug', ["[cleanDeviceName] name before regex : " + str])
|
mylog('trace', ["[cleanDeviceName] name before regex : " + str])
|
||||||
|
|
||||||
str = re.sub(rgx, "", 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])
|
mylog('debug', ["[cleanDeviceName] output: " + str])
|
||||||
|
|
||||||
|
|||||||
@@ -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",
|
"function": "NAME_CLEANUP_REGEX",
|
||||||
"type": {
|
"type": {
|
||||||
|
|||||||
@@ -114,21 +114,21 @@ $settingsJSON_DB = json_encode($settings, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX
|
|||||||
<div class =" col-sm-12" id="system_content"></div>
|
<div class =" col-sm-12" id="system_content"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class ="bg-grey-dark color-palette panel panel-default col-sm-12 box-default box-info" id="device_scanner_content_header" >
|
<div class ="bg-grey-dark color-palette panel panel-default col-sm-12 box-default box-info" id="device_scanners_content_header" >
|
||||||
<div class ="settings-group col-sm-12">
|
<div class ="settings-group col-sm-12">
|
||||||
<i class="<?= lang("settings_device_scanners_icon");?>"></i> <?= lang("settings_device_scanners_label");?>
|
<i class="<?= lang("settings_device_scanners_icon");?>"></i> <?= lang("settings_device_scanners_label");?>
|
||||||
</div>
|
</div>
|
||||||
<div class =" col-sm-12" id="device_scanner_content"> <?= lang("settings_device_scanners_info");?> </div>
|
<div class =" col-sm-12" id="device_scanner_content"> <?= lang("settings_device_scanners_info");?> </div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class ="bg-grey-dark color-palette panel panel-default col-sm-12 box-default box-info" id="other_content_header">
|
<div class ="bg-grey-dark color-palette panel panel-default col-sm-12 box-default box-info" id="other_scanners_content_header">
|
||||||
<div class ="settings-group col-sm-12">
|
<div class ="settings-group col-sm-12">
|
||||||
<i class="<?= lang("settings_other_scanners_icon");?>"></i> <?= lang("settings_other_scanners_label");?>
|
<i class="<?= lang("settings_other_scanners_icon");?>"></i> <?= lang("settings_other_scanners_label");?>
|
||||||
</div>
|
</div>
|
||||||
<div class =" col-sm-12" id="other_content"></div>
|
<div class =" col-sm-12" id="other_content"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class ="bg-grey-dark color-palette panel panel-default col-sm-12 box-default box-info" id="publisher_content_header" >
|
<div class ="bg-grey-dark color-palette panel panel-default col-sm-12 box-default box-info" id="publishers_content_header" >
|
||||||
<div class ="settings-group col-sm-12">
|
<div class ="settings-group col-sm-12">
|
||||||
<i class="<?= lang("settings_publishers_icon");?>"></i> <?= lang("settings_publishers_label");?>
|
<i class="<?= lang("settings_publishers_icon");?>"></i> <?= lang("settings_publishers_label");?>
|
||||||
</div>
|
</div>
|
||||||
@@ -285,12 +285,14 @@ $settingsJSON_DB = json_encode($settings, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX
|
|||||||
|
|
||||||
overviewSections_html += `<div class="overview-section col-sm-12" id="${section}">
|
overviewSections_html += `<div class="overview-section col-sm-12" id="${section}">
|
||||||
<div class="col-sm-12 " title="${getString("settings_"+section)}">
|
<div class="col-sm-12 " title="${getString("settings_"+section)}">
|
||||||
<div class="overview-group col-sm-12 col-xs-12">
|
<a href="#${section}_content_header">
|
||||||
|
<div class="overview-group col-sm-12 col-xs-12">
|
||||||
<i title="${section}" class="${getString("settings_"+section+"_icon")}"></i>
|
|
||||||
|
<i title="${section}" class="${getString("settings_"+section+"_icon")}"></i>
|
||||||
${getString("settings_"+section+"_label")}
|
|
||||||
</div>
|
${getString("settings_"+section+"_label")}
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
${overviewSectionsHtml[index]}
|
${overviewSectionsHtml[index]}
|
||||||
|
|||||||
@@ -223,18 +223,32 @@ def create_new_devices (db):
|
|||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
cur_MAC,
|
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_Vendor,
|
||||||
cur_IP,
|
cur_IP,
|
||||||
?,
|
?,
|
||||||
?,
|
?,
|
||||||
cur_SyncHubNodeName,
|
cur_SyncHubNodeName,
|
||||||
{sql_generateGuid},
|
{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_PORT,
|
||||||
cur_NetworkSite,
|
cur_NetworkSite,
|
||||||
cur_SSID,
|
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}
|
{newDevDefaults}
|
||||||
FROM CurrentScan
|
FROM CurrentScan
|
||||||
WHERE 1=1
|
WHERE 1=1
|
||||||
|
|||||||
@@ -727,38 +727,6 @@ def cleanDeviceName(str, match_IP):
|
|||||||
# add matching info
|
# add matching info
|
||||||
if match_IP:
|
if match_IP:
|
||||||
str = str + " (IP match)"
|
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
|
# Applying cleanup REGEXEs
|
||||||
mylog('debug', ["[Name cleanup] Using old cleanDeviceName(" + str + ")"])
|
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')
|
regexes = get_setting_value('NEWDEV_NAME_CLEANUP_REGEX')
|
||||||
|
|
||||||
for rgx in regexes:
|
for rgx in regexes:
|
||||||
mylog('debug', ["[cleanDeviceName] applying regex : " + rgx])
|
mylog('trace', ["[cleanDeviceName] applying regex : " + rgx])
|
||||||
mylog('debug', ["[cleanDeviceName] name before regex : " + str])
|
mylog('trace', ["[cleanDeviceName] name before regex : " + str])
|
||||||
str = re.sub(rgx, "", 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'\.\b', '', str) # trailing dot after words
|
||||||
str = re.sub(r'\.$', '', str) # trailing dot at the end of the string
|
str = re.sub(r'\.$', '', str) # trailing dot at the end of the string
|
||||||
|
|||||||
Reference in New Issue
Block a user