mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 01:26:11 -08:00
NMAP + docs work
This commit is contained in:
@@ -23,7 +23,7 @@ The system continuously scans the network for, **New devices**, **New connection
|
|||||||
- **Pi-hole - DHCP leases**. Import of devices from the PiHole dhcp.leases file
|
- **Pi-hole - DHCP leases**. Import of devices from the PiHole dhcp.leases file
|
||||||
- **Generic DHCP leases**. Import of devices from the generic dhcp.leases file
|
- **Generic DHCP leases**. Import of devices from the generic dhcp.leases file
|
||||||
- **UNIFI import**. Import of devices from the UNIFI controller
|
- **UNIFI import**. Import of devices from the UNIFI controller
|
||||||
- **SNMP-enabled router import**. Import of devices from an SNMP enabled router
|
- **SNMP-enabled router import**. Import of devices from an SNMP-enabled router
|
||||||
|
|
||||||
## 🧩 Integrations
|
## 🧩 Integrations
|
||||||
- [Apprise](https://hub.docker.com/r/caronc/apprise), [Pushsafer](https://www.pushsafer.com/), [NTFY](https://ntfy.sh/)
|
- [Apprise](https://hub.docker.com/r/caronc/apprise), [Pushsafer](https://www.pushsafer.com/), [NTFY](https://ntfy.sh/)
|
||||||
|
|||||||
@@ -440,6 +440,7 @@
|
|||||||
"Plugins_History" : "Events History",
|
"Plugins_History" : "Events History",
|
||||||
"Plugins_Filters_Mac" : "Mac Filter",
|
"Plugins_Filters_Mac" : "Mac Filter",
|
||||||
"Plugins_Out_of" : "out of",
|
"Plugins_Out_of" : "out of",
|
||||||
|
"Plugins_no_control" : "No form control was found to render this value.",
|
||||||
"Settings_Metadata_Toggle" : "Show/hide metadata for the given setting.",
|
"Settings_Metadata_Toggle" : "Show/hide metadata for the given setting.",
|
||||||
"settings_missing" : "Not all settings loaded, refresh the page! This is probably caused by a high load on the database.",
|
"settings_missing" : "Not all settings loaded, refresh the page! This is probably caused by a high load on the database.",
|
||||||
"settings_missing_block" : "You can not save your settings without specifying all setting keys. Refresh the page. This is probably caused by a high load on the database.",
|
"settings_missing_block" : "You can not save your settings without specifying all setting keys. Refresh the page. This is probably caused by a high load on the database.",
|
||||||
|
|||||||
@@ -371,7 +371,7 @@ This approach is used to implement the `DHCPLSS` plugin. The script parses all s
|
|||||||
3) That's it. PiAlert takes care of the rest. It loops thru the objects discovered by the plugin, takes the results line, by line and inserts them into the database table specified in `"mapped_to_table"`. The columns are translated from the generic plugin columns to the target table via the `"mapped_to_column"` property in the column definitions.
|
3) That's it. PiAlert takes care of the rest. It loops thru the objects discovered by the plugin, takes the results line, by line and inserts them into the database table specified in `"mapped_to_table"`. The columns are translated from the generic plugin columns to the target table via the `"mapped_to_column"` property in the column definitions.
|
||||||
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
> You can create a column mapping with a default value via the `mapped_to_column_data` property.
|
> You can create a column mapping with a default value via the `mapped_to_column_data` property. This means that the value of the given column will always be this value. Taht also menas that the `"column": "NameDoesntMatter"` is not important as there is no databse source column.
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
@@ -590,7 +590,7 @@ You can have any `"function": "my_custom_name"` custom name, however, the ones l
|
|||||||
|
|
||||||
##### UI settings in database_column_definitions
|
##### UI settings in database_column_definitions
|
||||||
|
|
||||||
The UI will adjust how columns are displayed in the UI based on the definition of the `database_column_definitions` object. These are the supported form controls and related functionality:
|
The UI will adjust how columns are displayed in the UI based on the resolvers definition of the `database_column_definitions` object. These are the supported form controls and related functionality:
|
||||||
|
|
||||||
- Only columns with `"show": true` and also with at least an English translation will be shown in the UI.
|
- Only columns with `"show": true` and also with at least an English translation will be shown in the UI.
|
||||||
|
|
||||||
@@ -599,9 +599,10 @@ The UI will adjust how columns are displayed in the UI based on the definition o
|
|||||||
| `label` | Displays a column only. |
|
| `label` | Displays a column only. |
|
||||||
| `text` | Makes a column editable, and a save icon is displayed next to it. See below for information on `threshold`, `replace`. |
|
| `text` | Makes a column editable, and a save icon is displayed next to it. See below for information on `threshold`, `replace`. |
|
||||||
| | |
|
| | |
|
||||||
| `options` Property | Used in conjunction with types like `threshold`, `replace`. |
|
| `options` Property | Used in conjunction with types like `threshold`, `replace`, `regex`. |
|
||||||
| `threshold` | The `options` array contains objects ordered from the lowest `maximum` to the highest. The corresponding `hexColor` is used for the value background color if it's less than the specified `maximum` but more than the previous one in the `options` array. |
|
| `threshold` | The `options` array contains objects ordered from the lowest `maximum` to the highest. The corresponding `hexColor` is used for the value background color if it's less than the specified `maximum` but more than the previous one in the `options` array. |
|
||||||
| `replace` | The `options` array contains objects with an `equals` property, which is compared to the "value." If the values are the same, the string in `replacement` is displayed in the UI instead of the actual "value". |
|
| `replace` | The `options` array contains objects with an `equals` property, which is compared to the "value." If the values are the same, the string in `replacement` is displayed in the UI instead of the actual "value". |
|
||||||
|
| `regex` | Applies a regex to the value. The `options` array contains objects with an `type` (must be set to `regex`) and `param` (must contain the regex itself) property. |
|
||||||
| | |
|
| | |
|
||||||
| Type Definitions | |
|
| Type Definitions | |
|
||||||
| `device_mac` | The value is considered to be a MAC address, and a link pointing to the device with the given MAC address is generated. |
|
| `device_mac` | The value is considered to be a MAC address, and a link pointing to the device with the given MAC address is generated. |
|
||||||
@@ -609,6 +610,11 @@ The UI will adjust how columns are displayed in the UI based on the definition o
|
|||||||
| `device_name_mac` | The value is considered to be a MAC address, and a link pointing to the device with the given IP is generated. The link label is resolved as the target device name. |
|
| `device_name_mac` | The value is considered to be a MAC address, and a link pointing to the device with the given IP is generated. The link label is resolved as the target device name. |
|
||||||
| `url` | The value is considered to be a URL, so a link is generated. |
|
| `url` | The value is considered to be a URL, so a link is generated. |
|
||||||
| `textbox_save` | Generates an editable and saveable text box that saves values in the database. Primarily intended for the `UserData` database column in the `Plugins_Objects` table. |
|
| `textbox_save` | Generates an editable and saveable text box that saves values in the database. Primarily intended for the `UserData` database column in the `Plugins_Objects` table. |
|
||||||
|
| `url_http_https` | Generates towo links with the `https` and `http` prefix as lock icons. |
|
||||||
|
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> Supports chaining. You can chain multiple resolvers with `.`. For example `regex.url_http_https`. This will apply the `regex` resolver and then the `url_http_https` resolver
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -671,6 +677,28 @@ The UI will adjust how columns are displayed in the UI based on the definition o
|
|||||||
"language_code":"en_us",
|
"language_code":"en_us",
|
||||||
"string" : "Status"
|
"string" : "Status"
|
||||||
}]
|
}]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"column": "Watched_Value3",
|
||||||
|
"css_classes": "col-sm-1",
|
||||||
|
"show": true,
|
||||||
|
"type": "regex.url_http_https",
|
||||||
|
"default_value":"",
|
||||||
|
"options": [
|
||||||
|
{
|
||||||
|
"type": "regex",
|
||||||
|
"param": "([\\d.:]+)"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"localized": ["name"],
|
||||||
|
"name":[{
|
||||||
|
"language_code":"en_us",
|
||||||
|
"string" : "HTTP/s links"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"language_code":"es_es",
|
||||||
|
"string" : "N/A"
|
||||||
|
}]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,7 @@
|
|||||||
"column": "Object_SecondaryID",
|
"column": "Object_SecondaryID",
|
||||||
"css_classes": "col-sm-2",
|
"css_classes": "col-sm-2",
|
||||||
"show": true,
|
"show": true,
|
||||||
"type": "url",
|
"type": "label",
|
||||||
"default_value":"",
|
"default_value":"",
|
||||||
"options": [],
|
"options": [],
|
||||||
"localized": ["name"],
|
"localized": ["name"],
|
||||||
@@ -193,15 +193,20 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"column": "Watched_Value3",
|
"column": "Watched_Value3",
|
||||||
"css_classes": "col-sm-2",
|
"css_classes": "col-sm-1",
|
||||||
"show": false,
|
"show": true,
|
||||||
"type": "label",
|
"type": "regex.url_http_https",
|
||||||
"default_value":"",
|
"default_value":"",
|
||||||
"options": [],
|
"options": [
|
||||||
|
{
|
||||||
|
"type": "regex",
|
||||||
|
"param": "([\\d.:]+)"
|
||||||
|
}
|
||||||
|
],
|
||||||
"localized": ["name"],
|
"localized": ["name"],
|
||||||
"name":[{
|
"name":[{
|
||||||
"language_code":"en_us",
|
"language_code":"en_us",
|
||||||
"string" : "N/A"
|
"string" : "HTTP/s links"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"language_code":"es_es",
|
"language_code":"es_es",
|
||||||
|
|||||||
@@ -60,10 +60,34 @@ function getFormControl(dbColumnDef, value, index) {
|
|||||||
|
|
||||||
result = ''
|
result = ''
|
||||||
|
|
||||||
switch(dbColumnDef.type)
|
// Check if mapped_to_column_data exists and has a value to override the supplied value which is most likely `undefined`
|
||||||
|
if (dbColumnDef.mapped_to_column_data && dbColumnDef.mapped_to_column_data.value) {
|
||||||
|
value = dbColumnDef.mapped_to_column_data.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
result = processColumnValue(dbColumnDef, value, index, dbColumnDef.type)
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Process column value
|
||||||
|
function processColumnValue(dbColumnDef, value, index, type) {
|
||||||
|
if (type.includes('.')) {
|
||||||
|
const typeParts = type.split('.');
|
||||||
|
|
||||||
|
// recursion
|
||||||
|
for (const typePart of typeParts) {
|
||||||
|
value = processColumnValue(dbColumnDef, value, index, typePart)
|
||||||
|
}
|
||||||
|
|
||||||
|
} else{
|
||||||
|
// pick form control based on the supplied type
|
||||||
|
switch(type)
|
||||||
{
|
{
|
||||||
case 'label':
|
case 'label':
|
||||||
result = `<span>${value}<span>`;
|
value = `<span>${value}<span>`;
|
||||||
break;
|
break;
|
||||||
case 'textbox_save':
|
case 'textbox_save':
|
||||||
|
|
||||||
@@ -71,7 +95,7 @@ function getFormControl(dbColumnDef, value, index) {
|
|||||||
|
|
||||||
id = `${dbColumnDef.column}_${index}`
|
id = `${dbColumnDef.column}_${index}`
|
||||||
|
|
||||||
result = `<span class="form-group">
|
value = `<span class="form-group">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input class="form-control" type="text" value="${value}" id="${id}" data-my-column="${dbColumnDef.column}" data-my-index="${index}" name="${dbColumnDef.column}">
|
<input class="form-control" type="text" value="${value}" id="${id}" data-my-column="${dbColumnDef.column}" data-my-index="${index}" name="${dbColumnDef.column}">
|
||||||
<span class="input-group-addon"><i class="fa fa-save pointer" onclick="saveData('${id}');"></i></span>
|
<span class="input-group-addon"><i class="fa fa-save pointer" onclick="saveData('${id}');"></i></span>
|
||||||
@@ -79,22 +103,33 @@ function getFormControl(dbColumnDef, value, index) {
|
|||||||
<span>`;
|
<span>`;
|
||||||
break;
|
break;
|
||||||
case 'url':
|
case 'url':
|
||||||
result = `<span><a href="${value}" target="_blank">${value}</a><span>`;
|
value = `<span><a href="${value}" target="_blank">${value}</a><span>`;
|
||||||
|
break;
|
||||||
|
case 'url_http_https':
|
||||||
|
value = `<span>
|
||||||
|
<a href="http://${value}" target="_blank">
|
||||||
|
<i class="fa fa-lock-open "></i>
|
||||||
|
</a>
|
||||||
|
/
|
||||||
|
<a href="https://${value}" target="_blank">
|
||||||
|
<i class="fa fa-lock "></i>
|
||||||
|
</a>
|
||||||
|
<span>`;
|
||||||
break;
|
break;
|
||||||
case 'device_name_mac':
|
case 'device_name_mac':
|
||||||
result = `<span class="anonymizeMac"><a href="/deviceDetails.php?mac=${value}" target="_blank">${getNameByMacAddress(value)}</a><span>`;
|
value = `<span class="anonymizeMac"><a href="/deviceDetails.php?mac=${value}" target="_blank">${getNameByMacAddress(value)}</a><span>`;
|
||||||
break;
|
break;
|
||||||
case 'device_mac':
|
case 'device_mac':
|
||||||
result = `<span class="anonymizeMac"><a href="/deviceDetails.php?mac=${value}" target="_blank">${value}</a><span>`;
|
value = `<span class="anonymizeMac"><a href="/deviceDetails.php?mac=${value}" target="_blank">${value}</a><span>`;
|
||||||
break;
|
break;
|
||||||
case 'device_ip':
|
case 'device_ip':
|
||||||
result = `<span class="anonymizeIp"><a href="#" onclick="navigateToDeviceWithIp('${value}')" >${value}</a><span>`;
|
value = `<span class="anonymizeIp"><a href="#" onclick="navigateToDeviceWithIp('${value}')" >${value}</a><span>`;
|
||||||
break;
|
break;
|
||||||
case 'threshold':
|
case 'threshold':
|
||||||
$.each(dbColumnDef.options, function(index, obj) {
|
$.each(dbColumnDef.options, function(index, obj) {
|
||||||
if(Number(value) < obj.maximum && result == '')
|
if(Number(value) < obj.maximum && value == '')
|
||||||
{
|
{
|
||||||
result = `<div style="background-color:${obj.hexColor}">${value}</div>`
|
value = `<div style="background-color:${obj.hexColor}">${value}</div>`
|
||||||
// return;
|
// return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -103,17 +138,35 @@ function getFormControl(dbColumnDef, value, index) {
|
|||||||
$.each(dbColumnDef.options, function(index, obj) {
|
$.each(dbColumnDef.options, function(index, obj) {
|
||||||
if(value == obj.equals)
|
if(value == obj.equals)
|
||||||
{
|
{
|
||||||
result = `<span title="${value}">${obj.replacement}</span>`
|
value = `<span title="${value}">${obj.replacement}</span>`
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
case 'regex':
|
||||||
|
for (const option of dbColumnDef.options) {
|
||||||
|
if (option.type === type) {
|
||||||
|
|
||||||
|
const regexPattern = new RegExp(option.param);
|
||||||
|
const match = value.match(regexPattern);
|
||||||
|
if (match) {
|
||||||
|
// Return the first match
|
||||||
|
value = match[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
result = value;
|
value = value + `<div style='text-align:center' title="${getString("Plugins_no_control")}"><i class='fa-solid fa-circle-question'></i></div>` ;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
// Default behavior if no match is found
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Update the corresponding DB column and entry
|
// Update the corresponding DB column and entry
|
||||||
function saveData (id) {
|
function saveData (id) {
|
||||||
@@ -274,7 +327,7 @@ function generateTabs()
|
|||||||
|
|
||||||
for(var j=0;j<colDefinitions.length;j++)
|
for(var j=0;j<colDefinitions.length;j++)
|
||||||
{
|
{
|
||||||
clm += '<td>'+ getFormControl(colDefinitions[j], pluginObjects[i][colDefinitions[j].column], pluginObjects[i]["Index"]) +'</td>'
|
clm += '<td>'+ getFormControl(colDefinitions[j], pluginObjects[i][colDefinitions[j].column], pluginObjects[i]["Index"], colDefinitions, pluginObjects[i]) +'</td>'
|
||||||
}
|
}
|
||||||
obRows += `<tr data-my-index="${pluginObjects[i]["Index"]}" >${clm}</tr>`
|
obRows += `<tr data-my-index="${pluginObjects[i]["Index"]}" >${clm}</tr>`
|
||||||
obCount++;
|
obCount++;
|
||||||
|
|||||||
Reference in New Issue
Block a user