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. 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) - ❗ 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 ##### 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. There are 2 approaches how to get PiHole devices imported. Via the PiHole import (PIHOLE) plugin or DHCP leases (DHCPLSS) plugin.
* `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`).
**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. > It's recommended to use the same schedule interval for all plugins scanning your network.
@@ -87,6 +95,8 @@ version: "3"
services: services:
pialert: pialert:
container_name: 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" image: "jokobsk/pi.alert:latest"
network_mode: "host" network_mode: "host"
restart: unless-stopped restart: unless-stopped
@@ -113,6 +123,8 @@ Example by [SeimuS](https://github.com/SeimusS).
container_name: PiAlert container_name: PiAlert
hostname: PiAlert hostname: PiAlert
privileged: true 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 image: jokobsk/pi.alert:latest
environment: environment:
- TZ=Europe/Bratislava - TZ=Europe/Bratislava
@@ -134,6 +146,8 @@ version: "3"
services: services:
pialert: pialert:
container_name: 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" image: "jokobsk/pi.alert:latest"
network_mode: "host" network_mode: "host"
restart: unless-stopped restart: unless-stopped
@@ -178,6 +192,8 @@ Courtesy of [pbek](https://github.com/pbek). The volume `pialert_db` is used by
```yaml ```yaml
pialert: pialert:
# use the below line if you want to test the latest dev image
# image: "jokobsk/pi.alert_dev:latest"
image: jokobsk/pi.alert image: jokobsk/pi.alert
ports: ports:
- "80:20211/tcp" - "80:20211/tcp"

View File

@@ -454,11 +454,8 @@
"Setting_Override" : "Override value", "Setting_Override" : "Override value",
"Setting_Override_Description" : "Enabling this option will override an App supplied default value with the value specified above.", "Setting_Override_Description" : "Enabling this option will override an App supplied default value with the value specified above.",
"General_display_name" : "General", "General_display_name" : "General",
"General_icon" : "<i class=\"fa fa-gears\"></i>", "General_icon" : "<i class=\"fa fa-gears\"></i>",
"ENABLE_ARPSCAN_name" : "Enable ARP scan", "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.",
"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.",
"LOG_LEVEL_name" : "Print additional logging", "LOG_LEVEL_name" : "Print additional logging",
"LOG_LEVEL_description" : "This setting will enable more verbose logging. Useful for debugging events writing into the database.", "LOG_LEVEL_description" : "This setting will enable more verbose logging. Useful for debugging events writing into the database.",
"TIMEZONE_name" : "Time zone", "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.", "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_display_name" : "General",
"General_icon" : "<i class=\"fa fa-gears\"></i>", "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_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_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.", "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", "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 - `"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). - `"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) `"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 ##### Supported settings `function` values

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -96,8 +96,7 @@ def importConfigs (db):
conf.HRS_TO_KEEP_NEWDEV = ccd('HRS_TO_KEEP_NEWDEV', 0 , c_d, 'Keep new devices for', 'integer', "0", 'General') conf.HRS_TO_KEEP_NEWDEV = ccd('HRS_TO_KEEP_NEWDEV', 0 , c_d, 'Keep new devices for', 'integer', "0", 'General')
conf.API_CUSTOM_SQL = ccd('API_CUSTOM_SQL', 'SELECT * FROM Devices WHERE dev_PresentLastScan = 0' , c_d, 'Custom endpoint', 'text', '', 'General') 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) # 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') 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 # Email

View File

@@ -25,6 +25,7 @@ import const
from const import pialertPath, logPath, apiPath 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 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 logger import logResult, mylog, print_log
from plugin import execute_plugin
from publishers.email import (check_config as email_check_config, from publishers.email import (check_config as email_check_config,
send as send_email ) send as send_email )
@@ -512,12 +513,11 @@ def check_and_run_event(db):
def handle_run(runType, db): def handle_run(runType, db):
mylog('minimal', ['[', timeNowTZ(), '] START Run: ', runType]) mylog('minimal', ['[', timeNowTZ(), '] START Run: ', runType])
if runType == 'ENABLE_ARPSCAN': # run the plugin to run
# run the plugin to run for plugin in conf.plugins:
for plugin in conf.plugins: if plugin["unique_prefix"] == runType:
if plugin["unique_prefix"] == 'ARPSCAN': execute_plugin(db, plugin)
execute_plugin(db, plugin)
mylog('minimal', ['[', timeNowTZ(), '] END Run: ', runType]) mylog('minimal', ['[', timeNowTZ(), '] END Run: ', runType])