Settings cleanup, docs and strings, Removal of ENABLE_ARPSCAN

This commit is contained in:
Jokob-sk
2023-08-16 08:01:56 +10:00
parent c8bae60060
commit a3359dbec4
11 changed files with 40 additions and 28 deletions

View File

@@ -61,14 +61,22 @@ docker run -d --rm --network=host \
These are the most important settings to get at least some output in your Devices screen. Usually, only one approach is used, but you should be able to combine these approaches.
##### For arp-scan: ENABLE_ARPSCAN, SCAN_SUBNETS
##### For arp-scan: ARPSCAN_RUN, SCAN_SUBNETS
- ❗ To use the arp-scan method, you need to set the `SCAN_SUBNETS` variable. See the documentation on how [to setup SUBNETS, VLANs & limitations](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/SUBNETS.md)
##### For pihole: PIHOLE_RUN, DHCPLSS_RUN
* `PIHOLE_RUN`: You need to map `:/etc/pihole/pihole-FTL.db in the docker-compose.yml` file if you enable this setting.
* `DHCPLSS_RUN`: You need to map `:/etc/pihole/dhcp.leases in the docker-compose.yml` file if you enable this setting. This has to be matched with a corresponding `DHCPLSS_paths_to_check` setting entry (the path in the container must contain `pihole`).
There are 2 approaches how to get PiHole devices imported. Via the PiHole import (PIHOLE) plugin or DHCP leases (DHCPLSS) plugin.
**PiHole (Device sync)**
* `PIHOLE_RUN`: You need to map `:/etc/pihole/pihole-FTL.db` in the `docker-compose.yml` file if you enable this setting.
**DHCP Leases (Device import)**
* `DHCPLSS_RUN`: You need to map `:/etc/pihole/dhcp.leases` in the `docker-compose.yml` file if you enable this setting.
* The above setting has to be matched with a corresponding `DHCPLSS_paths_to_check` setting entry (the path in the container must contain `pihole` as PiHole uses a different format of the `dhcp.leases` file).
> It's recommended to use the same schedule interval for all plugins scanning your network.
@@ -87,6 +95,8 @@ version: "3"
services:
pialert:
container_name: pialert
# use the below line if you want to test the latest dev image
# image: "jokobsk/pi.alert_dev:latest"
image: "jokobsk/pi.alert:latest"
network_mode: "host"
restart: unless-stopped
@@ -113,6 +123,8 @@ Example by [SeimuS](https://github.com/SeimusS).
container_name: PiAlert
hostname: PiAlert
privileged: true
# use the below line if you want to test the latest dev image
# image: "jokobsk/pi.alert_dev:latest"
image: jokobsk/pi.alert:latest
environment:
- TZ=Europe/Bratislava
@@ -134,6 +146,8 @@ version: "3"
services:
pialert:
container_name: pialert
# use the below line if you want to test the latest dev image
# image: "jokobsk/pi.alert_dev:latest"
image: "jokobsk/pi.alert:latest"
network_mode: "host"
restart: unless-stopped
@@ -178,6 +192,8 @@ Courtesy of [pbek](https://github.com/pbek). The volume `pialert_db` is used by
```yaml
pialert:
# use the below line if you want to test the latest dev image
# image: "jokobsk/pi.alert_dev:latest"
image: jokobsk/pi.alert
ports:
- "80:20211/tcp"

View File

@@ -455,10 +455,7 @@
"Setting_Override_Description" : "Enabling this option will override an App supplied default value with the value specified above.",
"General_display_name" : "General",
"General_icon" : "<i class=\"fa fa-gears\"></i>",
"ENABLE_ARPSCAN_name" : "Enable ARP scan",
"ENABLE_ARPSCAN_description" : "Arp-scan is a command-line tool that uses the ARP protocol to discover and fingerprint IP hosts on the local network. An alternative to ARP scan is to enable the <a onclick=\"toggleAllSettings()\" href=\"#PIHOLE_RUN\"><code>PIHOLE_RUN</code>PiHole integration settings</a>.",
"SCAN_SUBNETS_name" : "Subnets to scan",
"SCAN_SUBNETS_description" : "The arp-scan time itself depends on the number of IP addresses to check so set this up carefully with the appropriate network mask and interface. Check the <a href=\"https://github.com/jokob-sk/Pi.Alert/blob/main/docs/SUBNETS.md\" target=\"_blank\">subnets documentation</a> for help on setting up VLANs, what VLANs are supported, or how to figure out the network mask and your interface.",
"SCAN_SUBNETS_description" : "Arp-scan is a command-line tool that uses the ARP protocol to discover and fingerprint IP hosts on the local network. An alternative to ARP scan is to enable the <a onclick=\"toggleAllSettings()\" href=\"#PIHOLE_RUN\"><code>PIHOLE_RUN</code>PiHole integration settings</a>. The arp-scan time itself depends on the number of IP addresses to check so set this up carefully with the appropriate network mask and interface. Check the <a href=\"https://github.com/jokob-sk/Pi.Alert/blob/main/docs/SUBNETS.md\" target=\"_blank\">subnets documentation</a> for help on setting up VLANs, what VLANs are supported, or how to figure out the network mask and your interface.",
"LOG_LEVEL_name" : "Print additional logging",
"LOG_LEVEL_description" : "This setting will enable more verbose logging. Useful for debugging events writing into the database.",
"TIMEZONE_name" : "Time zone",

View File

@@ -448,10 +448,8 @@
"Setting_Override_Description": "Habilitar esta opción anulará un valor predeterminado proporcionado por la aplicación con el valor especificado anteriormente.",
"General_display_name" : "General",
"General_icon" : "<i class=\"fa fa-gears\"></i>",
"ENABLE_ARPSCAN_name" : "Activar escaneo ARP",
"ENABLE_ARPSCAN_description" : "El escaneo Arp es una herramienta de la línea de comandos que usa el protocolo ARP para encontrar e identificar la ip de los dispositivos. Una alternativa a este escaneo sería activar los ajustes de la <a onclick=\"toggleAllSettings()\" href=\"#PIHOLE_RUN\"><code>PIHOLE_RUN</code>integración con PiHole</a>.",
"SCAN_SUBNETS_name" : "Subredes para escanear",
"SCAN_SUBNETS_description" : "El tiempo del escaneo ARP depende del número de ips a comprobar, así que es importante establecer correctamente la máscara y la interfaz de red. Comprueba la <a href=\"https://github.com/jokob-sk/Pi.Alert/blob/main/docs/SUBNETS.md\" target=\"_blank\">documentación sobre sudredes</a> para obtener ayuda para establecer VLANs, cuáles son soportadas o como averiguar la máscara y la interfaz de red.",
"SCAN_SUBNETS_description" : "El escaneo Arp es una herramienta de la línea de comandos que usa el protocolo ARP para encontrar e identificar la ip de los dispositivos. Una alternativa a este escaneo sería activar los ajustes de la <a onclick=\"toggleAllSettings()\" href=\"#PIHOLE_RUN\"><code>PIHOLE_RUN</code>integración con PiHole</a>. El tiempo del escaneo ARP depende del número de ips a comprobar, así que es importante establecer correctamente la máscara y la interfaz de red. Comprueba la <a href=\"https://github.com/jokob-sk/Pi.Alert/blob/main/docs/SUBNETS.md\" target=\"_blank\">documentación sobre sudredes</a> para obtener ayuda para establecer VLANs, cuáles son soportadas o como averiguar la máscara y la interfaz de red.",
"LOG_LEVEL_name" : "Imprimir registros adicionales",
"LOG_LEVEL_description" : "Esto hará que el registro tenga más información. Util para depurar que eventos se van guardando en la base de datos.",
"TIMEZONE_name" : "Zona horaria",

View File

@@ -463,7 +463,8 @@ Required attributes are:
- `"localized"` - a list of properties on the current JSON level which need to be localized
- `"name"` and `"description"` - Displayed on the Settings page. An array of localized strings. (see Localized strings below).
- (optional) `"events"` - `<test|run>` - to generate an execution button next to the input field of the setting (not fully tested)
- (optional) `"override_value"` - used to determine a user-defined override for the setting. Useful for template-based plugins, where you can choose to leave the current value or override it with the value defined in the setting. (wip)
- (optional) `"override_value"` - used to determine a user-defined override for the setting. Useful for template-based plugins, where you can choose to leave the current value or override it with the value defined in the setting. (work in progress)
- (optional) `"events": ["run", "test"]` - used to trigger the plugin. Usually used on the `RUN` setting. Not fully tested in all scenarios. Will show a play button next to the setting and then after clicking an event is generated for the backend in the `Parameters` database table to process the front-end event on the next run.
##### Supported settings `function` values

View File

@@ -19,11 +19,11 @@
"display_name": [
{
"language_code": "en_us",
"string": "Network scan (Arp-Scan)"
"string": "Arp-Scan (Network scan)"
},
{
"language_code": "es_es",
"string": "Escaneo de red (Arp-Scan)"
"string": "Arp-Scan (Escaneo de red)"
}
],
"icon": [
@@ -60,6 +60,7 @@
"default_value":"schedule",
"options": ["disabled", "once", "schedule", "always_after_scan", "on_new_device"],
"localized": ["name", "description"],
"events": ["run"],
"name" :[
{
"language_code":"en_us",

View File

@@ -17,7 +17,7 @@
"mapped_to_table": "DHCP_Leases",
"display_name" : [{
"language_code":"en_us",
"string" : "DHCP Leases"
"string" : "DHCP Leases (Device import)"
}],
"icon":[{
"language_code":"en_us",

View File

@@ -19,7 +19,7 @@
"display_name": [
{
"language_code": "en_us",
"string": "Network scan (PiHole)"
"string": "PiHole (Device sync)"
}
],
"icon": [
@@ -31,7 +31,7 @@
"description": [
{
"language_code": "en_us",
"string": "This plugin is to import devices from PiHole"
"string": "This plugin syncs devices from the PiHole database"
}
],
"params" : [

View File

@@ -356,6 +356,7 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
eventsList.forEach(event => {
eventsHtml += `<span class="input-group-addon pointer"
data-myparam="${codeName}"
data-myparam-plugin="${group}"
data-myevent="${event}"
onclick="handleEvent(this)"
>
@@ -680,8 +681,8 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
function handleEvent (element){
// value has to be in format event|param. e.g. run|ENABLE_ARPSCAN
value = $(element).attr('data-myevent') + '|'+ $(element).attr('data-myparam')
// value has to be in format event|param. e.g. run|ARPSCAN
value = $(element).attr('data-myevent') + '|'+ $(element).attr('data-myparam-plugin')
setParameter ('Front_Event', value)

View File

@@ -39,7 +39,6 @@ changedPorts_json_struc = None
# ACTUAL CONFIGRATION ITEMS set to defaults
# General
ENABLE_ARPSCAN = True
SCAN_SUBNETS = ['192.168.1.0/24 --interface=eth1', '192.168.1.0/24 --interface=eth0']
LOG_LEVEL = 'verbose'
TIMEZONE = 'Europe/Berlin'

View File

@@ -97,7 +97,6 @@ def importConfigs (db):
conf.API_CUSTOM_SQL = ccd('API_CUSTOM_SQL', 'SELECT * FROM Devices WHERE dev_PresentLastScan = 0' , c_d, 'Custom endpoint', 'text', '', 'General')
# ARPSCAN (+ other settings provided by the ARPSCAN plugin)
conf.ENABLE_ARPSCAN = ccd('ENABLE_ARPSCAN', True , c_d, 'Enable arpscan', 'boolean', '', 'ARPSCAN', ['run'])
conf.SCAN_SUBNETS = ccd('SCAN_SUBNETS', ['192.168.1.0/24 --interface=eth1', '192.168.1.0/24 --interface=eth0'] , c_d, 'Subnets to scan', 'subnets', '', 'ARPSCAN')
# Email

View File

@@ -25,6 +25,7 @@ import const
from const import pialertPath, logPath, apiPath
from helper import noti_struc, generate_mac_links, removeDuplicateNewLines, timeNowTZ, hide_email, updateState, get_file_content, write_file
from logger import logResult, mylog, print_log
from plugin import execute_plugin
from publishers.email import (check_config as email_check_config,
send as send_email )
@@ -513,11 +514,10 @@ def handle_run(runType, db):
mylog('minimal', ['[', timeNowTZ(), '] START Run: ', runType])
if runType == 'ENABLE_ARPSCAN':
# run the plugin to run
for plugin in conf.plugins:
if plugin["unique_prefix"] == 'ARPSCAN':
execute_plugin(db, plugin)
# run the plugin to run
for plugin in conf.plugins:
if plugin["unique_prefix"] == runType:
execute_plugin(db, plugin)
mylog('minimal', ['[', timeNowTZ(), '] END Run: ', runType])