Added flag in subtitle translations
Added American flag in subtitle translations
Added German flag in subtitle translations
Fixed style in subtitle translations
Added flag in subtitle translations
Added American flag in subtitle translations
Added German flag in subtitle translations
Fixed style in subtitle translations
Added <br> tag in the "Tools" tab in the "Internet info" section
Added new tool "SpeedTest" in the "Tools" tab (This tool is only shown when the mac is equal to the Internet)
Added new translation variable "DevDetail_Tab_Tools_Speedtest_Title" in the "SpeedTest" tool in the "Tools" tab
Added new translation variable "DevDetail_Tab_Tools_Speedtest_Description" in the "SpeedTest" tool in the "Tools" tab
Added new translation variable "DevDetail_Tab_Tools_Speedtest_Start" in the "SpeedTest" tool in the "Tools" tab
Fixed the "internetinfo" function in the "Tools" tab
Added h5 tag for description of the "internetinfo" function
Added translation variable "DevDetail_Tab_Tools_Internet_Info_Description"
Modified translation variable from "DevDetail_Tools_Internet_Info_Title" to "DevDetail_Tab_Tools_Internet_Info_Title"
Modified translation variable from "DevDetail_Tools_Internet_Info_Start" to "DevDetail_Tab_Tools_Internet_Info_Start"
Optimized the order of translation variables
New translation variable "Systeminfo_Network_HTTP_Referer_String"
New translation variable "Systeminfo_Network_Secure_Connection_String"
New translation variable "Systeminfo_Network_Server_Name_String"
New translation variable "Systeminfo_Network_Server_Query_String"
Optimized the order of translation variables
New translation variable "Systeminfo_Network_HTTP_Referer_String"
New translation variable "Systeminfo_Network_Secure_Connection_String"
New translation variable "Systeminfo_Network_Server_Name_String"
New translation variable "Systeminfo_Network_Server_Query_String"
Optimized the order of translation variables
New translation variable "Systeminfo_Network_HTTP_Referer_String"
New translation variable "Systeminfo_Network_Secure_Connection_String"
New translation variable "Systeminfo_Network_Server_Name_String"
New translation variable "Systeminfo_Network_Server_Query_String"
Optimized the order of translation variables
New translation variable "Systeminfo_Network_Accept_Encoding"
New translation variable "Systeminfo_Network_Accept_Language"
New translation variable "Systeminfo_Network_Connection_Port"
New translation variable "Systeminfo_Network_HTTP_Host"
New translation variable "Systeminfo_Network_HTTP_Referer"
New translation variable "Systeminfo_Network_IP"
New translation variable "Systeminfo_Network_IP_Connection"
New translation variable "Systeminfo_Network_IP_Server"
New translation variable "Systeminfo_Network_MIME"
New translation variable "Systeminfo_Network_Request_Method"
New translation variable "Systeminfo_Network_Request_URI"
New translation variable "Systeminfo_Network_Request_Time"
New translation variable "Systeminfo_Network_Secure_Connection"
New translation variable "Systeminfo_Network_Server_Name"
New translation variable "Systeminfo_Network_Server_Query"
New translation variable "Systeminfo_Network_Server_Version"
Optimized the order of translation variables
New translation variable "Systeminfo_Network_Accept_Encoding"
New translation variable "Systeminfo_Network_Accept_Language"
New translation variable "Systeminfo_Network_Connection_Port"
New translation variable "Systeminfo_Network_HTTP_Host"
New translation variable "Systeminfo_Network_HTTP_Referer"
New translation variable "Systeminfo_Network_IP"
New translation variable "Systeminfo_Network_IP_Connection"
New translation variable "Systeminfo_Network_IP_Server"
New translation variable "Systeminfo_Network_MIME"
New translation variable "Systeminfo_Network_Request_Method"
New translation variable "Systeminfo_Network_Request_URI"
New translation variable "Systeminfo_Network_Request_Time"
New translation variable "Systeminfo_Network_Secure_Connection"
New translation variable "Systeminfo_Network_Server_Name"
New translation variable "Systeminfo_Network_Server_Query"
New translation variable "Systeminfo_Network_Server_Version"
Optimized the order of translation variables
New translation variable "Systeminfo_Network_Accept_Encoding"
New translation variable "Systeminfo_Network_Accept_Language"
New translation variable "Systeminfo_Network_Connection_Port"
New translation variable "Systeminfo_Network_HTTP_Host"
New translation variable "Systeminfo_Network_HTTP_Referer"
New translation variable "Systeminfo_Network_IP"
New translation variable "Systeminfo_Network_IP_Connection"
New translation variable "Systeminfo_Network_IP_Server"
New translation variable "Systeminfo_Network_MIME"
New translation variable "Systeminfo_Network_Request_Method"
New translation variable "Systeminfo_Network_Request_URI"
New translation variable "Systeminfo_Network_Request_Time"
New translation variable "Systeminfo_Network_Secure_Connection"
New translation variable "Systeminfo_Network_Server_Name"
New translation variable "Systeminfo_Network_Server_Query"
New translation variable "Systeminfo_Network_Server_Version"
Update "Network" submenu with new translation variables
New translation variable "Systeminfo_Network_Accept_Encoding"
New translation variable "Systeminfo_Network_Accept_Language"
New translation variable "Systeminfo_Network_Connection_Port"
New translation variable "Systeminfo_Network_HTTP_Host"
New translation variable "Systeminfo_Network_HTTP_Referer"
New translation variable "Systeminfo_Network_IP"
New translation variable "Systeminfo_Network_IP_Connection"
New translation variable "Systeminfo_Network_IP_Server"
New translation variable "Systeminfo_Network_MIME"
New translation variable "Systeminfo_Network_Request_Method"
New translation variable "Systeminfo_Network_Request_URI"
New translation variable "Systeminfo_Network_Request_Time"
New translation variable "Systeminfo_Network_Secure_Connection"
New translation variable "Systeminfo_Network_Server_Name"
New translation variable "Systeminfo_Network_Server_Query"
New translation variable "Systeminfo_Network_Server_Version"
New translation variable "Systeminfo_Motherboard_BIOS"
New translation variable "Systeminfo_Motherboard_BIOS_Date"
New translation variable "Systeminfo_Motherboard_BIOS_Vendor"
New translation variable "Systeminfo_Motherboard_Manufactured"
New translation variable "Systeminfo_Motherboard_Name"
New translation variable "Systeminfo_Motherboard_Revision"
New translation variable "Systeminfo_Motherboard_BIOS"
New translation variable "Systeminfo_Motherboard_BIOS_Date"
New translation variable "Systeminfo_Motherboard_BIOS_Vendor"
New translation variable "Systeminfo_Motherboard_Manufactured"
New translation variable "Systeminfo_Motherboard_Name"
New translation variable "Systeminfo_Motherboard_Revision"
New translation variable "Systeminfo_Motherboard_BIOS"
New translation variable "Systeminfo_Motherboard_BIOS_Date"
New translation variable "Systeminfo_Motherboard_BIOS_Vendor"
New translation variable "Systeminfo_Motherboard_Manufactured"
New translation variable "Systeminfo_Motherboard_Name"
New translation variable "Systeminfo_Motherboard_Revision"
Update "Motherboard" submenu with new translation variables
New translation variable "Systeminfo_Motherboard_BIOS
New translation variable "Systeminfo_Motherboard_BIOS_Date"
New translation variable "Systeminfo_Motherboard_BIOS_Vendor"
New translation variable "Systeminfo_Motherboard_Manufactured"
New translation variable "Systeminfo_Motherboard_Name"
New translation variable "Systeminfo_Motherboard_Revision"
Optimized the order of translation variables
New translation variable "Systeminfo_System_Architecture"
New translation variable "Systeminfo_System_AVG"
New translation variable "Systeminfo_System_Kernel"
New translation variable "Systeminfo_System_OSVersion"
New translation variable "Systeminfo_System_System"
New translation variable "Systeminfo_System_Uname"
New translation variable "Systeminfo_System_Uptime"
Optimized the order of translation variables
New translation variable "Systeminfo_System_Architecture"
New translation variable "Systeminfo_System_AVG"
New translation variable "Systeminfo_System_Kernel"
New translation variable "Systeminfo_System_OSVersion"
New translation variable "Systeminfo_System_System"
New translation variable "Systeminfo_System_Uname"
New translation variable "Systeminfo_System_Uptime"
Optimized the order of translation variables
New translation variable "Systeminfo_System_Architecture"
New translation variable "Systeminfo_System_AVG"
New translation variable "Systeminfo_System_Kernel"
New translation variable "Systeminfo_System_OSVersion"
New translation variable "Systeminfo_System_System"
New translation variable "Systeminfo_System_Uname"
New translation variable "Systeminfo_System_Uptime"
Update "System" submenu with new translation variables
New translation variable "Systeminfo_System_Uptime"
New translation variable "Systeminfo_System_Kernel"
New translation variable "Systeminfo_System_System"
New translation variable "Systeminfo_System_OSVersion"
New translation variable "Systeminfo_System_Uname"
New translation variable "Systeminfo_System_Architecture"
New translation variable "Systeminfo_System_AVG"
Added name variable in tr "Systeminfo_Storage_Mount"
Added name variable in tr "Systeminfo_Storage_Device"
Added name variable in tr "Systeminfo_Storage_Size"
Added name variable in tr "Systeminfo_Storage_Type"
Added name variable in tr "Systeminfo_Storage_Usage_Mount"
Added name variable in tr "Systeminfo_Storage_Usage_Total"
Added name variable in tr "Systeminfo_Storage_Usage_Used"
Added name variable in tr "Systeminfo_Storage_Usage_Free"
Added option for "Back Button" to hide it on small screens
Added option for "Next Button" to hide it on small screens
Added option for "Reload Button" to hide it on small screens
Added option for "Full Screen Button" to hide it on small screens
Added new section "Motherboard"
Added new section "Motherboard stat"
Added new variable "motherboard_name" in the section "Motherboard stat"
Added new variable "motherboard_manufactured" in the section "Motherboard stat"
Added new variable "motherboard_revision" in the section "Motherboard stat"
Added new variable "motherboard_bios" in the section "Motherboard stat"
Added new variable "motherboard_biosdate" in the section "Motherboard stat"
Added new variable "biosvendor" in the section "Motherboard stat"
Updated the "Memory Statistics" formula variables
Updated "Memory Statistics" echo variables
Added new formula variables for "CPU Temp"
Modified section "General"
Added new section "System"
Added new section "CPU"
Added new section "Memory"
Added new code "VERSION" to report version in report file
Added new code "BUILD" to report version in report file
Updated "REPORT_DATE" comment tag
Updated "SERVER_NAME" comment tag
Modified creator banner url (repot_template.html --> report_template_new_version.html)
Modified the creators banner adding to cvc90
Removed several white spaces between banner and tag
Changed the background color in the table (bgcolor=#00c0ef --> bgcolor=#4b99d3)
Changed the color of the text to white in the table ( bgcolor=#4b99d3 --> bgcolor=#ffffff)
Changed the background color in td (bgcolor=#F5F5F5 --> bgcolor=#F1F5F5)
Changed the background color in the footer table (bgcolor=#46802e --> bgcolor=#3c8dbc)
Added in the footer table the color of the text to white (color: white)
Changed footer text
Modified creator banner url repot_template.html --> report_template.html
Modified the creators banner adding to cvc90
Removed several white spaces between banner and tag
Changed the background color in the table (bgcolor=#00c0ef --> bgcolor=#4b99d3)
Changed the color of the text to white in the table (bgcolor=#4b99d3 --> bgcolor=#ffffff)
Changed the background color in td (bgcolor=#F5F5F5 --> bgcolor=#F1F5F5)
Changed the background color in the footer table (bgcolor=#46802e --> bgcolor=#3c8dbc)
Added in the footer table the color of the text to white (color: white)
Changed footer text
Changed the content of the "System info" menu variable ("Navigation_SystemInfo" : "Información del sistema" --> "Navigation_SystemInfo" : "Info del sistema")
Modified creator banner url report_template.html --> report_template.html
Modified the creators banner adding to cvc90
Removed several white spaces between banner and <html> tag
Changed the background color in the table (bgcolor=#00c0ef --> bgcolor=#4b99d3)
Changed the color of the text to white in the table ( bgcolor=#4b99d3 --> bgcolor=#ffffff)
Changed the background color in td (bgcolor=#F5F5F5 --> bgcolor=#F1F5F5)
Changed the background color in the footer table (bgcolor=#46802e --> bgcolor=#3c8dbc)
Added in the footer table the color of the text to white (color: white)
Changed footer text
Modified creator banner url report_template.html --> report_template.html
Modified the creators banner adding to cvc90
Removed several white spaces between banner and <html> tag
Changed the background color in the table (bgcolor=#00c0ef --> bgcolor=#4b99d3)
Changed the color of the text to white in the table (bgcolor=#ffffff --> bgcolor=#4b99d3)
Changed the background color in td (bgcolor=#F5F5F5 --> bgcolor=#F1F5F5)
Changed the background color in the footer table (bgcolor=#46802e --> bgcolor=#3c8dbc)
Added in the footer table the color of the text to white (color: white)
Changed footer text
Added new translation to German, variable "Navigation_SystemInfo" : "Systeminformationen"
Added new translation to German, variable "SYSTEM_TITLE" : "Systeminformationen"
Added new translation to English, variable "Navigation_SystemInfo" : "System Information"
Added new translation to English, variable "SYSTEM_TITLE" : "System Information"
Added new translation to Spanish, variable Navigation_SystemInfo" : "Información del sistema"
Added new translation to Spanish, variable "SYSTEM_TITLE" : "Información del sistema"
description:'When submitting an issue enable debug and have a look at the docs.'
labels:['bug 🐛']
body:
- type:checkboxes
attributes:
label:Is there an existing issue for this?
description:Please search to see if an open or closed issue already exists for the bug you encountered.
options:
- label:I have searched the existing open and closed issues and I checked the docs https://github.com/jokob-sk/Pi.Alert/tree/main/docs
required:true
- type:textarea
attributes:
label:Current Behavior
description:A concise description of what you're experiencing.
validations:
required:true
- type:textarea
attributes:
label:Expected Behavior
description:A concise description of what you expected to happen.
validations:
required:true
- type:textarea
attributes:
label:Steps To Reproduce
description:Steps to reproduce the behavior.
placeholder:|
1. With these settings...
2. With this config...
3. Run '...'
4. See error...
validations:
required:false
- type:textarea
attributes:
label:pialert.conf
description:|
Paste your `pialert.conf` (remove personal info)
render:python
validations:
required:false
- type:textarea
attributes:
label:docker-compose.yml
description:|
Paste your `docker-compose.yml`
render:python
validations:
required:false
- type:dropdown
attributes:
label:What branch are you running?
options:
- Production
- Dev
validations:
required:true
- type:textarea
attributes:
label:pialert.log
description:|
Logs with debug enabled (https://github.com/jokob-sk/Pi.Alert/blob/main/docs/DEBUG_TIPS.md) ⚠
***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 /home/pi/pialert/front/log/pialert.log` in teh container if you have troubles getting to the log files.
validations:
required:false
- type:checkboxes
attributes:
label:Debug enabled
description:I confirm I enabled `debug`
options:
- label:I have read and followed the steps in the wiki link above and provided the required debug logs and the log section covers the time when the issue occurs.
Get visibility of what's going on on your WIFI/LAN network. Scan for devices, port changes and get alerts if unknown devices or changes are found. Write your own [Plugins](https://github.com/jokob-sk/Pi.Alert/tree/main/front/plugins#readme) with auto-generated UI and in-build notification system.
Scans for devices connected to your WIFI / LAN and alerts you if new and unknown devices are found.
The system continuously scans the network for, **New devices**, **New connections** (re-connections), **Disconnections**, **"Always Connected" devices down**, Devices **IP changes** and **Internet IP address changes**. Scanning methods are:
- **Method 1: arp-scan**. The arp-scan system utility is used to search
for devices on the network using arp frames.
- **Method 2: Pi-hole**. This method is optional and complementary to
method 1. If the Pi-hole DNS server is active, Pi.Alert examines its
activity looking for active devices using DNS that have not been
detected by method 1.
- **Method 3. dnsmasq**. This method is optional and complementary to the
previous methods. If the DHCP server dnsmasq is active, Pi.Alert
examines the DHCP leases (addresses assigned) to find active devices
Most of us don't know what's going on on our home network, but we want our family and data to be safe. _Command-line tools_ are great, but the output can be _hard to understand_ and action if you are not a network specialist.
PiAlert gives you peace of mind. _Visualize and immediately report 📬_ what is going on in your network - this is the first step to enhance your _network security 🔐_.
PiAlert combines several network and other scanning tools 🔍 with notifications 📧 into one user-friendly package 📦.
Setup a _kill switch ☠_ for your network via a smart plug with the available [Home Assistant](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/HOME_ASSISTANT.md) integration. Implement custom automations with the [CSV device Exports 📤](https://github.com/jokob-sk/Pi.Alert/tree/main/front/plugins/csv_backup), [Webhooks](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/WEBHOOK_N8N.md), or [API endpoints](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/API.md) features.
Extend the app if you want to create your own scanner [Plugin](https://github.com/jokob-sk/Pi.Alert/tree/main/front/plugins#readme) and handle the results and notifications in PiAlert.
Looking forward to your contributions if you decide to share your work with the community ❤.
</details>
## Scan Methods, Notifications, Integration, Extension system
| Features | Details |
|-------------|-------------|
| 🔍 | The app scans your network for, **New devices**, **New connections** (re-connections), **Disconnections**, **"Always Connected" devices down**, Devices **IP changes** and **Internet IP address changes**. Discovery & scan methods include: **arp-scan**. **Pi-hole - DB import**, **Pi-hole - DHCP leases import**, **Generic DHCP leases import**. **UNIFI controller import**, **SNMP-enabled router import**. Check the [Plugins](https://github.com/jokob-sk/Pi.Alert/tree/main/front/plugins#readme) docs for more info on individual scans. |
|📧 | Send notifications to more than 80+ services, including Telegram via [Apprise](https://hub.docker.com/r/caronc/apprise), or use [Pushsafer](https://www.pushsafer.com/), [Pushover](https://www.pushover.net/), or [NTFY](https://ntfy.sh/). |
|🧩 | Feed your data and device changes into [Home Assistant](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/HOME_ASSISTANT.md), read [API endpoints](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/API.md), or use [Webhooks](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/WEBHOOK_N8N.md) to setup custom automation flows. |
|➕ | Build your own scanners with the [Plugin system](https://github.com/jokob-sk/Pi.Alert/tree/main/front/plugins#readme) |
| 📚 | [All Documentation](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/README.md) (App Usage and Configuration) |
> Other Alternatives
>
> - Check out [leiweibau's on HW installed fork](https://github.com/leiweibau/Pi.Alert/) (maintained)
> - Check instructions for [pucherot's original code](https://github.com/pucherot/Pi.Alert/) (unmaintained)
> - [WatchYourLAN](https://github.com/aceberg/WatchYourLAN) - Lightweight network IP scanner with web GUI (Open source)
> - [Fing](https://www.fing.com/) - Network scanner app for your Internet security (Commercial, Phone App, Proprietary hardware)
# 📥 Installation
## ❤ Support me for...
- I don't get burned out and the app survives longer🔥🤯
- Regular updates to keep your data and family safe 🔄
- Better and more functionality➕
- Quicker and better support with issues 🆘
- Less grumpy me 😄
| [](https://github.com/sponsors/jokob-sk) | [](https://www.buymeacoffee.com/jokobsk) | [](https://www.patreon.com/user?u=84385063) |
⚠ This [fork (jokob-sk)](https://github.com/jokob-sk/Pi.Alert) is only tested as a [docker container](dockerfiles/README.md). Check out [leiweibau's fork](https://github.com/leiweibau/Pi.Alert/) if you want to install Pi.Alert on the server directly.
### 🌍 Translations
Instructions for [pucherot's original code can be found here](https://github.com/pucherot/Pi.Alert/)
Proudly using [Weblate](https://hosted.weblate.org/projects/pialert/).
Help out and suggest languages in the [online portal of Weblate](https://hosted.weblate.org/projects/pialert/core/).
### License
GPL 3.0
- [Read more here](LICENSE.txt)
- Source of the [animated GIF (Loading Animation)](https://commons.wikimedia.org/wiki/File:Loading_Animation.gif)
- Source of the [selfhosted Fonts](https://github.com/adobe-fonts/source-sans)
> GPL 3.0 | [Read more here](LICENSE.txt) | Source of the [animated GIF (Loading Animation)](https://commons.wikimedia.org/wiki/File:Loading_Animation.gif) | Source of the [selfhosted Fonts](https://github.com/adobe-fonts/source-sans)
### 🥇 Special thanks
### Special thanks
This code is a collaborative body of work, with special thanks to:
This code is a collaborative body of work, with special thanks to:
- 🏆 [pucherot/Pi.Alert](https://github.com/pucherot/Pi.Alert) is the original creator od PiAlert
- [leiweibau](https://github.com/leiweibau/Pi.Alert): Dark mode (and much more)
- [Macleykun](https://github.com/Macleykun): Help with Dockerfile clean-up
- [Final-Hawk](https://github.com/Final-Hawk): Help with NTFY, styling and other fixes
- [jokob-sk](https://github.com/jokob-sk/Pi.Alert): DB Maintenance tools
- Please see the [Git commit history](https://github.com/jokob-sk/Pi.Alert/commits/main) for a full list of people and their contributions to the project
> [pucherot/Pi.Alert](https://github.com/pucherot/Pi.Alert) (the original creator of PiAlert), [leiweibau](https://github.com/leiweibau/Pi.Alert): Dark mode (and much more), [Macleykun](https://github.com/Macleykun) (Help with Dockerfile clean-up) [Final-Hawk](https://github.com/Final-Hawk) (Help with NTFY, styling and other fixes), [TeroRERO](https://github.com/terorero) (Spanish translations), [Data-Monkey](https://github.com/Data-Monkey), (Split-up of the python.py file and more), [cvc90](https://github.com/cvc90) (Spanish translation and various UI work) to name a few...
>
> Please see the [Git contributors](https://github.com/jokob-sk/Pi.Alert/graphs/contributors) for a full list of people and their contributions to the project
> There is also an experimental 🧪 [bare-metal install](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/HW_INSTALL.md) method available.
## 📕 Basic Usage
- You will have to run the container on the host network, e.g:
- You will have to run the container on the `host` network, e.g:
```yaml
docker run -d --rm --network=host \
@@ -27,65 +30,89 @@ docker run -d --rm --network=host \
-e TZ=Europe/Berlin \
-e PORT=20211 \
jokobsk/pi.alert:latest
```
- The initial scan can take up-to 15min (with 50 devices and MQTT). Subsequent ones 3 and 5 minutes so wait that long for all of the scans to run.
```
-The initial scan can take upto 15min (with 50 devices and MQTT). Subsequent ones 3 and 5 minutes so wait that long for all of the scans to run.
### Docker environment variables
| Variable | Description | Default |
| :------------- |:-------------| -----:|
| `PORT` |Port of the web interface | `20211` |
| `LISTEN_ADDR` |Set the specific IP Address for the listener address for the nginx webserver (web interface). This could be useful when using multiple subnets to hide the web interface from all untrusted networks. | `0.0.0.0` |
|`TZ` |Time zone to display stats correctly. Find your time zone [here](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) | `Europe/Berlin` |
|`HOST_USER_GID` |User ID (UID) to map the user in the container to a server user with sufficient read&write permissions on the mapped files | `1000` |
|`HOST_USER_ID` |User Group ID (GID) to map the user group in the container to a server user group with sufficient read&write permissions on the mapped files | `1000` |
| ✅ | `:/home/pi/pialert/config` | Folder which will contain the `pialert.conf` file (see below for details) |
| ✅ | `:/home/pi/pialert/db` | Folder which will contain the `pialert.db` file |
| | `:/home/pi/pialert/front/log` | Logs folder useful for debugging if you have issues setting up the container |
| | `:/etc/pihole/pihole-FTL.db` | PiHole's `pihole-FTL.db` database file. Required if you want to use PiHole DB mapping. |
| | `:/etc/pihole/dhcp.leases` | PiHole's `dhcp.leases` file. Required if you want to use PiHole `dhcp.leases` file. This has to be matched with a corresponding `DHCPLSS_paths_to_check` setting entry (the path in the container must contain `pihole`)|
| | `:/home/pi/pialert/front/api` | A simple [API endpoint](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/API.md) containing static (but regularly updated) json and other files. |
| | `:/home/pi/pialert/front/plugins/<plugin>/ignore_plugin` | Map a file `ignore_plugin` to ignore a plugin. Plugins can be soft-disabled via settings. More in the [Plugin docs](https://github.com/jokob-sk/Pi.Alert/blob/main/front/plugins/README.md). |
| | `:/etc/resolv.conf` | Use a custom `resolv.conf` file for [better name resolution](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/REVERSE_DNS.md). |
### Config (`pialert.conf`)
### Modify the config (`pialert.conf`) only if UI is not available
- Modify [pialert.conf](https://github.com/jokob-sk/Pi.Alert/tree/main/config) or manage the configuration via Settings.
- ❗ Set the `SCAN_SUBNETS` variable.
*The adapter will probably be `eth0` or `eth1`. (Run `iwconfig` to find your interface name(s))
*Specify the network filter (which **significantly** speeds up the scan process). For example, the filter `192.168.1.0/24` covers IP ranges 192.168.1.0 to 192.168.1.255.
* Examples for one and two subnets (❗ Note the `['...', '...']` format):
* One subnet:`SCAN_SUBNETS = ['192.168.1.0/24 --interface=eth0']`
* Two subnets:`SCAN_SUBNETS = ['192.168.1.0/24 --interface=eth0', '192.168.1.0/24 --interface=eth1']`
- The preferred way is to manage the configuration via the Settings section in the UI.
- You can modify [pialert.conf](https://github.com/jokob-sk/Pi.Alert/tree/main/config) directly, if needed.
- If unavailable, the app generates a default `pialert.conf` and `pialert.db` file on the first run.
#### Important settings
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: 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
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).
> [!NOTE]
> It's recommended to use the same schedule interval for all plugins responsible for discovering new devices.
### 🛑 **Common issues**
#### 🧭 Community guides
Use the official installation guides at first and use community content as suplementary material. Open an issue if you'd like to add your link to the list 🙏
- 📄 [How to Install Pi.Alert on Your Synology NAS - Marius hosting (English)](https://mariushosting.com/how-to-install-pi-alert-on-your-synology-nas/) (Updated frequently)
- 📄 [Using the PiAlert Network Security Scanner on a Raspberry Pi - PiMyLifeUp (English)](https://pimylifeup.com/raspberry-pi-pialert/)
- ▶ [How to Setup Pi.Alert on Your Synology NAS - Digital Aloha (English)](https://www.youtube.com/watch?v=M4YhpuRFaUg)
- 📄 [시놀/헤놀에서 네트워크 스캐너 Pi.Alert Docker로 설치 및 사용하기 (Korean)](https://blog.dalso.org/article/%EC%8B%9C%EB%86%80-%ED%97%A4%EB%86%80%EC%97%90%EC%84%9C-%EB%84%A4%ED%8A%B8%EC%9B%8C%ED%81%AC-%EC%8A%A4%EC%BA%90%EB%84%88-pi-alert-docker%EB%A1%9C-%EC%84%A4%EC%B9%98-%EB%B0%8F-%EC%82%AC%EC%9A%A9) (July 2023)
- ▶ [Pi.Alert auf Synology & Docker by - Jürgen Barth (German)](https://www.youtube.com/watch?v=-ouvA2UNu-A) (March 2023)
- ▶ [Top Docker Container for Home Server Security - VirtualizationHowto (English)](https://www.youtube.com/watch?v=tY-w-enLF6Q) (March 2023)
- ▶ [Pi.Alert or WatchYourLAN can alert you to unknown devices appearing on your WiFi or LAN network - Danie van der Merwe (English)](https://www.youtube.com/watch?v=v6an9QG2xF0) (November 2022)
> Ordered by last update time.
### **Common issues**
💡 Before creating a new issue, please check if a similar issue was [already resolved](https://github.com/jokob-sk/Pi.Alert/issues?q=is%3Aissue+is%3Aclosed).
**Permissions**
⚠ Check also common issues and [debugging tips](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/DEBUG_TIPS.md).
*If facing issues (AJAX errors, can't write to DB, empty screen, etc,) make sure permissions are set correctly, and check the logs under `/home/pi/pialert/front/log`.
*To solve permission issues you can also try to create a DB backup and then run a DB Restore via the **Maintenance > Backup/Restore** section.
* You can try also setting the owner and group of the `pialert.db` by executing the following on the host system:`docker exec pialert chown -R www-data:www-data /home/pi/pialert/db/pialert.db`.
*Map to local User and Group IDs. Specify the enviroment variables `HOST_USER_ID` and `HOST_USER_GID` if needed.
*Map the pialert.db file (⚠ not folder) to `:/home/pi/pialert/db/pialert.db` (see Examples below for details)
> [!NOTE]
> You can bulk-update devices via the [CSV import method](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/DEVICES_BULK_EDITING.md).
**Containerrestarts / crashes**
*Check the logs for details. Often a required setting for a notification method is missing.
**unableto resolve host**
*Check that your `SCAN_SUBNETS` variable is using the correct mask and `--interface` as outlined in the instructions above.
Docker-compose examples can be found below.
## 📄 Examples
## 📄 docker-compose.yml Examples
### Example 1
@@ -94,6 +121,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 +142,29 @@ To run the container execute: `sudo docker-compose up -d`
### Example 2
Example by [SeimuS](https://github.com/SeimusS).
```yaml
pialert:
container_name:PiAlert
hostname:PiAlert
privileged:true
# use the below line if you want to test the latest dev image
To run the container execute: `sudo docker-compose --env-file /path/to/.env up`
### Example 3
### Example 4
Courtesy of [pbek](https://github.com/pbek). The volume `pialert_db` is used by the db directory. The two config files are mounted directly from a local folder to their places in the config folder. You can backup the `docker-compose.yaml` folder and the docker volumes folder.
```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"
@@ -180,16 +236,21 @@ Courtesy of [pbek](https://github.com/pbek). The volume `pialert_db` is used by
## 🏅 Recognitions
Big thanks to <ahref="https://github.com/Macleykun">@Macleykun</a> for help and tips&tricks for Dockerfile(s):
Big thanks to <ahref="https://github.com/Macleykun">@Macleykun</a> for help and tips&tricks for Dockerfile(s).
- Regular updates to keep your data and family safe 🔄
- Better and more functionality➕
- I don't get burned out and the app survives longer🔥🤯
- Quicker and better support with issues 🆘
- Less grumpy me 😄
Disclaimer: Please only donate if you don't have any debt yourself. Support yourself first, then others.
| [](https://github.com/sponsors/jokob-sk) | [](https://www.buymeacoffee.com/jokobsk) | [](https://www.patreon.com/user?u=84385063) |
| --- | --- | --- |
<ahref="https://github.com/sponsors/jokob-sk"target="_blank"><imgsrc="https://i.imgur.com/X6p5ACK.png"alt="Sponsor Me on GitHub"style="height: 30px !important;width: 117px !important;"width="150px"></a>
<ahref="https://www.buymeacoffee.com/jokobsk"target="_blank"><imgsrc="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png"alt="Buy Me A Coffee"style="height: 30px !important;width: 117px !important;"width="117px"height="30px"></a>
<ahref="https://www.patreon.com/user?u=84385063"target="_blank"><imgsrc="https://upload.wikimedia.org/wikipedia/commons/thumb/8/82/Patreon_logo_with_wordmark.svg/512px-Patreon_logo_with_wordmark.svg.png"alt="Support me on patreon"style="height: 30px !important;width: 117px !important;"width="117px"></a>
- El escaneo inicial puede tardar hasta 15 minutos (con 50 dispositivos y MQTT). Los siguientes pueden durar entre 3 y 5 minutos, así que espere a que se ejecuten todos los escaneos.
### Variables de entorno Docker
| Variable | Descripción | Predeterminado |
| :------------- |:-------------| -----:|
| `PORT` |Puerto de la interfaz web | `20211` |
|`TZ` |Zona horaria para mostrar correctamente las estadísticas. Encuentre su zona horaria [aquí](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) | `Europe/Berlin` |
|`HOST_USER_GID` |ID de usuario (UID) para asignar el usuario del contenedor a un usuario del servidor con suficientes permisos de lectura y escritura en los archivos asignados | `1000` |
|`HOST_USER_ID` |ID de grupo de usuarios (GID) para asignar el grupo de usuarios del contenedor a un grupo de usuarios del servidor con suficientes permisos de lectura y escritura en los archivos asignados | `1000` |
| **Obligatorio** | `:/home/pi/pialert/config` | Carpeta que contendrá el archivo `pialert.conf` (para más detalles, véase más abajo) |
| **Obligatorio** | `:/home/pi/pialert/db` | Carpeta que contendrá el archivo `pialert.db` |
|Opcional| `:/home/pi/pialert/front/log` | Carpeta de registros útil para depurar si tiene problemas al configurar el contenedor |
|Opcional| `:/etc/pihole/pihole-FTL.db` | Archivo de base de datos `pihole-FTL.db` de PiHole. Necesario si desea utilizar PiHole |
|Opcional| `:/etc/pihole/dhcp.leases` | Archivo `dhcp.leases` de PiHole. Obligatorio si desea utilizar el archivo `dhcp.leases` de PiHole. Tiene que coincidir con la correspondiente entrada de configuración `DHCPLSS_paths_to_check`. (La ruta en el contenedor debe contener `pihole`)|
|Opcional| `:/home/pi/pialert/front/api` | Una simple [API endpoint](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/API.md) que contiene archivos json estáticos (pero actualizados regularmente) y otros archivos. |
### Configurar (`pialert.conf`)
- Si no está disponible, la aplicación genera un archivo `pialert.conf` y `pialert.db` por defecto en la primera ejecución.
- La forma preferida es gestionar la configuración a través de la sección "Configuración" de la interfaz de usuario.
- Puede modificar [pialert.conf](https://github.com/jokob-sk/Pi.Alert/tree/main/config) directamente, si es necesario.
#### Ajustes importantes
Estos son los ajustes más importantes para obtener al menos alguna salida en la pantalla de tus Dispositivos. Por lo general, sólo se utiliza un enfoque, pero usted debe ser capaz de combinar estos enfoques.
##### Para arp-scan: ARPSCAN_RUN, SCAN_SUBNETS
- ❗ Para usar el método arp-scan, necesitas configurar la variable `SCAN_SUBNETS`. Consulte la documentación sobre cómo [configurar SUBNETS, VLANs y limitaciones](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/SUBNETS.md)
##### Para pihole: PIHOLE_RUN, DHCPLSS_RUN
Hay dos maneras de importar dispositivos PiHole. A través del plugin de importación PiHole (PIHOLE) o del plugin DHCP leases (DHCPLSS).
**PiHole(Sincronización de dispositivos)**
* `PIHOLE_RUN`:Necesitas mapear `:/etc/pihole/pihole-FTL.db` en el fichero `docker-compose.yml` si activas esta opción.
**DHCPLeases (Importación de dispositivos)**
* `DHCPLSS_RUN`:Es necesario mapear `:/etc/pihole/dhcp.leases` en el fichero `docker-compose.yml` si se activa esta opción.
*La configuración anterior tiene que coincidir con una entrada de configuración correspondiente `DHCPLSS_paths_to_check` (la ruta en el contenedor debe contener `pihole` ya que PiHole utiliza un formato diferente del archivo `dhcp.leases`).
> Se recomienda utilizar el mismo intervalo de programación para todos los plugins responsables de descubrir nuevos dispositivos.
### **Problemas comunes**
💡 Antes de crear una nueva incidencia, comprueba si ya se ha resuelto una [incidencia similar](https://github.com/jokob-sk/Pi.Alert/issues?q=is%3Aissue+is%3Aclosed).
⚠ Compruebe también los problemas comunes y los [consejos de depuración](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/DEBUG_TIPS.md).
## 📄 Ejemplos
### Ejemplo 1
```yaml
version:"3"
services:
pialert:
container_name:pialert
# Utilice la siguiente línea si desea probar la última imagen de desarrollo
# (optional) useful for debugging if you have issues setting up the container
- ${LOGS_LOCATION}:/home/pi/pialert/front/log
environment:
- TZ=${TZ}
- HOST_USER_ID=${HOST_USER_ID}
- HOST_USER_GID=${HOST_USER_GID}
- PORT=${PORT}
```
`.env` file
```yaml
#VARIABLES DE RUTA GLOBAL
APP_DATA_LOCATION=/path/to/docker_appdata
APP_CONFIG_LOCATION=/path/to/docker_config
LOGS_LOCATION=/path/to/docker_logs
#VARIABLES DE ENTORNO
TZ=Europe/Paris
HOST_USER_ID=1000
HOST_USER_GID=1000
PORT=20211
#VARIABLES DE DESARROLLO
DEV_LOCATION=/path/to/local/source/code
```
Para ejecutar el contenedor ejecute: `sudo docker-compose --env-file /path/to/.env up`
### Example 4
Por cortesía de [pbek](https://github.com/pbek). El volumen `pialert_db` es utilizado por el directorio db. Los dos archivos de configuración se montan directamente desde una carpeta local a sus lugares en la carpeta config. Puedes hacer una copia de seguridad de la carpeta `docker-compose.yaml` y de la carpeta docker volumes.
```yaml
pialert:
# Utilice la siguiente línea si desea probar la última imagen de desarrollo
<ahref="https://github.com/sponsors/jokob-sk"target="_blank"><imgsrc="https://i.imgur.com/X6p5ACK.png"alt="Sponsor Me on GitHub"style="height: 30px !important;width: 117px !important;"width="150px"></a>
<ahref="https://www.buymeacoffee.com/jokobsk"target="_blank"><imgsrc="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png"alt="Buy Me A Coffee"style="height: 30px !important;width: 117px !important;"width="117px"height="30px"></a>
<ahref="https://www.patreon.com/user?u=84385063"target="_blank"><imgsrc="https://upload.wikimedia.org/wikipedia/commons/thumb/8/82/Patreon_logo_with_wordmark.svg/512px-Patreon_logo_with_wordmark.svg.png"alt="Support me on patreon"style="height: 30px !important;width: 117px !important;"width="117px"></a>
@@ -5,12 +5,7 @@ PiAlert comes with a simple API. These API endpoints are static files, that are
### When are the endpoints updated
Once you enable the API (`ENABLE_API` setting), the endpoints are updated during these events:
1) Always during a notification event.
2) (optional) If `API_RUN` is set to `schedule` on a specified cron-like schedule specified by the `API_RUN_SCHD` setting.
3) (optional) If `API_RUN` is set to `interval` every N seconds specified by the `API_RUN_INTERVAL` setting (minimum 5).
The endpoints are updated when objects in the API endpoints are changed.
### Location of the endpoints
@@ -25,11 +20,15 @@ You can access the following files:
| `notification_text.txt` | The plain text version of the last notification. |
| `notification_text.html` | The full HTML of the last email notification. |
| `notification_json_final.json` | The json version of the last notification (e.g. used for webhooks - [sample JSON](https://github.com/jokob-sk/Pi.Alert/blob/main/back/webhook_json_sample.json)). |
| `table_devices.json` | The current (at the time of the last update as mentioned above on this page) state of all of the available Devices detected by the app. |
| `table_nmap_scan.json` | The current state of the discovered ports by the regular NMAP scans. |
| `table_devices.json` | The current (at the time of the last update as mentioned above on this page) state of all of the available Devices detected by the app. |
| `table_pholus_scan.json` | The latest state of the [pholus](https://github.com/jokob-sk/Pi.Alert/tree/main/pholus) (A multicast DNS and DNS Service Discovery Security Assessment Tool) scan results. |
| `table_events_pending_alert.json` | The list of the unprocessed (pending) notification events. |
| `table_plugins_events.json` | The list of the unprocessed (pending) notification events (plugins_events DB table). |
| `table_plugins_history.json` | The list of notification events history. |
| `table_plugins_objects.json` | The content of the plugins_objects table. Find more info on the [Plugin system here](https://github.com/jokob-sk/Pi.Alert/tree/main/front/plugins)|
| `language_strings.json` | The content of the language_strings table, which in turn is loaded from the plugins `config.json` definitions. |
| `table_custom_endpoint.json` | A custom endpoint generated by the SQL query specified by the `API_CUSTOM_SQL` setting. |
| `table_settings.json` | The content of the settings table. |
| `app_state.json` | Contains the current application state. |
Current/latest state of the aforementioned files depends on your settings.
# A high-level description of the datbase structure
⚠ Disclaimer: As I'm not the original author, some of the information might be inaccurate. Feel free to submit a PR to correct anything within this page or documentation in general.
The MAC address is used as a foreign key in most cases.
| CurrentScan | Result of the current scan | ![Screen1][screen1] |
| Devices | The main devices database that also contains the Network tree mappings. If `ScanCycle` is set to `0` device is not scanned. | ![Screen2][screen2] |
| Events | Used to collect connection/disconnection events. | ![Screen4][screen4] |
| Online_History | Used to display the `Device presence` chart | ![Screen6][screen6] |
| Parameters | Used to pass values between the frontend and backend. | ![Screen7][screen7] |
| Pholus_Scan | Scan results of the Pholus python network penetration script. | ![Screen8][screen8] |
| Plugins_Events | For capturing events exposed by a plugin via the `last_result.log` file. If unique then saved into the `Plugins_Objects` table. Entries are deleted once processed and stored in the `Plugins_History` and/or `Plugins_Objects` tables. | ![Screen10][screen10] |
| Plugins_History | History of all entries from the `Plugins_Events` table | ![Screen11][screen11] |
| Plugins_Language_Strings | Language strings colelcted from the plugin `config.json` files used for string resolution in the frontend. | ![Screen12][screen12] |
| Sessions | Used to display sessions in the charts | ![Screen15][screen15] |
| Settings | Database representation of the sum of all settings from `pialert.conf` and plugins coming from `config.json` files. | ![Screen16][screen16] |
Check the the HTTP response of the failing backend call by following these steps:
- Open developer console in your browser (usually, e. g. for Chrome, key F12 on the keyboard).
- Follow the steps in this screenshot:
![F12DeveloperConsole][F12DeveloperConsole]
- Copy the URL causing the error and enter it in the address bar of your browser directly and hit enter. The copied URLs could look something like this (notice the query strings at the end):
- Post the error response in the existing issue thread on GitHub or create a new issue and include the redacted response of the failing query.
For reference, the above queries should return results in the following format:
## First URL:
- Should yield a valid JSON file
## Second URL:
![array][array]
## Third URL:
![json][json]
You can copy and paste any JSON result (result of the First and Third query) into an online JSON checker, such as [this one](https://jsonchecker.com/) to check if it's valid.
If a Plugin supplies data to the main app it's doine either vie a SQL query or via a script that updates the `last_result.log` file in the plugin folder (`front/plugins/<plugin>`).
For a more in-depth overview on how plugins work check the [Plugins development docs](https://github.com/jokob-sk/Pi.Alert/blob/main/front/plugins/README.md).
### Prerequisites
- Make sure you read and followed the specific plugin setup instructions.
- Ensure you have [debug enabled (see More Logging)](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/DEBUG_TIPS.md#1-more-logging-)
### Potential issues
- Bugs
- Unexpected input (e.g. special characters in names)
- Dependencies changed how data is output
#### Incorrect input data
Input data from the plugin might cause mapping issues in specific edge cases. Look for a corresponding section in the `pialert.log` file, for example notice the first line of the execution run of the `PIHOLE` plugin below:
```
17:31:05 [Scheduler] - Scheduler run for PIHOLE: YES
17:31:05 [Plugins] CMD: SELECT n.hwaddr AS Object_PrimaryID, {s-quote}null{s-quote} AS Object_SecondaryID, datetime() AS DateTime, na.ip AS Watched_Value1, n.lastQuery AS Watched_Value2, na.name AS Watched_Value3, n.macVendor AS Watched_Value4, {s-quote}null{s-quote} AS Extra, n.hwaddr AS ForeignKey FROM EXTERNAL_PIHOLE.Network AS n LEFT JOIN EXTERNAL_PIHOLE.Network_Addresses AS na ON na.network_id = n.id WHERE n.hwaddr NOT LIKE {s-quote}ip-%{s-quote} AND n.hwaddr is not {s-quote}00:00:00:00:00:00{s-quote} AND na.ip is not null
17:31:05 [Plugins] setTyp: subnets
17:31:05 [Plugin utils] Flattening the below array
17:31:05 [Plugins] Executing: SELECT n.hwaddr AS Object_PrimaryID, 'null' AS Object_SecondaryID, datetime() AS DateTime, na.ip AS Watched_Value1, n.lastQuery AS Watched_Value2, na.name AS Watched_Value3, n.macVendor AS Watched_Value4, 'null' AS Extra, n.hwaddr AS ForeignKey FROM EXTERNAL_PIHOLE.Network AS n LEFT JOIN EXTERNAL_PIHOLE.Network_Addresses AS na ON na.network_id = n.id WHERE n.hwaddr NOT LIKE 'ip-%' AND n.hwaddr is not '00:00:00:00:00:00' AND na.ip is not null
> ⚠ Please note, don't use the `-d` parameter so you see the error when the container crashes. Use this error in your issue description.
## 3. Check the _dev image and open issues ❓
If possible, check if your issue got fixed in the `_dev` image before opening a new issue. The container is:
`jokobsk/pi.alert_dev:latest`
> ⚠ Please backup your DB and config beforehand!
Please also search [open issues](https://github.com/jokob-sk/Pi.Alert/issues).
## 4. Disable restart behavior 🛑
To prevent a Docker container from automatically restarting in a Docker Compose file, specify the restart policy as `no`:
```yaml
version:'3'
services:
your-service:
image:your-image:tag
restart:no
# Other service configurations...
```
## 📃Common issues
### Permissions
* If facing issues (AJAX errors, can't write to DB, empty screen, etc,) make sure permissions are set correctly, and check the logs under `/home/pi/pialert/front/log`.
* To solve permission issues you can try setting the owner and group of the `pialert.db` by executing the following on the host system: `docker exec pialert chown -R www-data:www-data /home/pi/pialert/db/pialert.db`.
* Map to local User and Group IDs. Specify the enviroment variables `HOST_USER_ID` and `HOST_USER_GID` if needed.
* If still facing issues, try to map the pialert.db file (⚠ not folder) to `:/home/pi/pialert/db/pialert.db` (see [docker-compose Examples](https://github.com/jokob-sk/Pi.Alert/blob/main/dockerfiles/README.md#-docker-composeyml-examples) for details)
### Container restarts / crashes
* Check the logs for details. Often a required setting for a notification method is missing.
### unable to resolve host
* Check that your `SCAN_SUBNETS` variable is using the correct mask and `--interface` as outlined in the instructions above.
### Invalid JSON
Check the [Invalid JSON errors debug help](/docs/DEBUG_INVALID_JSON.md) docs on how to proceed.
### sudo execution failing (e.g.: on arpscan) on a Raspberry Pi 4
> sudo: unexpected child termination condition: 0
Resolution based on [this issue](https://github.com/linuxserver/docker-papermerge/issues/4#issuecomment-1003657581)
The link above will probably break in time too. Go to https://packages.debian.org/sid/armhf/libseccomp2/download to find the new version number and put that in the url.
> The file containing a list of Devices including the Network relationships between Network Nodes and connected devices. You can also trigger this by acessing this URL: `<your pialert url>/php/server/devices.php?action=ExportCSV` or via the `CSV Backup` plugin. (💡 You can schedule this)
> [Bulk-edit devices](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/DEVICES_BULK_EDITING.md) by using the `CSV Export` functionality in the `Maintenance` section.
![Device Details][screen1]
@@ -18,7 +23,7 @@ To edit device information:
- **Owner**: Device owner (The list is self-populated with existing owners)
- **Type**: Select a device type from the dropdown list (Smartphone, Table,
Laptop, TV, router, ....) or type a new device type
- **Vendor**: Automatically updated by Pi.Alert
- **Vendor**: Automatically updated by Pi.Alert when empty or unknown
- **Favorite**: Mark the device as favorite and then it will appears at the
begining of the device list
- **Group**: Select a grouper ('Always on', 'Personal', Friends') or type
@@ -41,8 +46,7 @@ To edit device information:
- **Alert All Events**: Send a notification in each event (connection,
disconnection, IP Changed, ...)
- **Alert Down**: Send a notification when the device is down
- *(Userful with "always connected" devices: Router, AP, Camera, Alexa,
...)*
- *(Userful with "always connected" devices: Camera, Alexa,...)*
- **Skip repeated notifications during**: Do not send more than one
notification to this device for X hours
- *(Useful to avoid notification saturation on devices that frequently
@@ -81,9 +85,17 @@ decides to change the MAC).
GPL 3.0
[Read more here](../LICENSE.txt)
### Contact
pi.alert.application@gmail.com
### Contact
Always use the Issue tracker for the correct fork, for example:
[jokob-sk/Pi.Alert](https://github.com/jokob-sk/Pi.Alert/issues). Please also follow the guidelines on:
This page contains tips for frontend development when extending PiAlert. Guiding principles are:
1. Maintainability
2. Extendability
3. Reusability
4. Placing more functionality into Plugins and enhancing core Plugins functionality
That means that, when writing code, focus on reusing what's available instead of writing quick fixes. Or creating reusable functions, instead of bespoke functionaility.
## 🔍 Examples
Some examples how to apply the above:
> Example 1
>
> I want to implement a scan fucntion. Options would be:
>
> 1. To add a manual scan functionality to the `deviceDetails.php` page.
> 2. To create a separate page that handles the execution of the scan.
> 3. To create a configurable Plugin.
>
> From the above, number 3 would be the most appropriate solution. Then followed by number 2. Number 1 would be approved only in special circumstances.
> Example 2
>
> I want to change the behavior of the application. Options to implement this could be:
>
> 1. Hard-code the changes in the code.
> 2. Implement the changes and add settings to influence the behavior in the `initialize.py` file so the user can adjust these.
> 3. Implement the changes and add settings via a setting-only plugin.
> 4. Implement the changes in a way so the behavior can be toggled on each plugin so the core capabilities of Plugins get extended.
>
> From the above, number 4 would be the most appropriate solution. Then followed by number 3. Number 1 or 2 would be approved only in special circumstances.
## 💡 Frontend tips
Some useful frontend JavaScript functions:
-`getDeviceDataByMacAddress(macAddress, devicesColumn)` - method to retrieve any device data (database column) based on MAC address in the frontend
-`getString(string stringKey)` - method to retrieve translated strings in the frontend
-`getSetting(string stringKey)` - method to retrieve settings in the frontend
Check the [pialert_common.js](https://github.com/jokob-sk/Pi.Alert/blob/main-2023-06-10/front/js/pialert_common.js) file for more frontend functions.
PiAlert comes with MQTT support, allowing you to show all detected devices as devices in Home Assistant. It also supplies a collection of stats, such as number of online devices.
## ⚠ Note
- Please note that discovery takes about ~10s per device.
- Deleting of devices is not handled automatically. Please use [MQTT Explorer](https://mqtt-explorer.com/) to delete devices in the broker (Home Assistant), if needed.
## 🧭 Guide
> 💡 This guide was tested only with the Mosquitto MQTT broker
1. Enable Mosquitto MQTT in Home Assistant by following the [documentation](https://www.home-assistant.io/integrations/mqtt/)
2. Configure a user name and password on your broker.
3. Note down the following details that you will need to configure PiAlert:
- MQTT host url (usually your Home Assistant IP)
- MQTT broker port
- User
- Password
4. Ope the `PiAlert` > `Settings` > `MQTT` settings group
These commands will download the `install.sh` script from the GitHub repository, make it executable with `chmod`, and then run it using `./install.sh`.
Make sure you have the necessary permissions to execute the script.
Icons are used to visually distinguish devices in the app in most of the device listing tables and the [network tree](/docs/NETWORK_TREE.md). Currently only free [Font Awesome](https://fontawesome.com/search?o=r&m=free) icons (up-to v 6.4.0) are supported.

## ⚙ How to use custom device Icons
You can assign icons individually on each device in the Details tab.

- You can click into the `Icon` field or click the Pencil (2) icon in the above screenshot to enter any text. Only [free Font Awesome](https://fontawesome.com/search?o=r&m=free) icons in the following format will work:
1. For any value that is only prefixed with `fa-`, you can enter the value directly, such as `server`, `tv`, `ethernet`.
2. If you want to add another classname, e.g. `fa-brands`, you can enter `brands fa-[fontawesome-icon-name]`, so for `apple` that is using the syntax`fa-brands fa-apple`, you would enter `brands fa-apple`.
- If you want to mass-apply an icon to all devices of the same device type (Field marked (4) in the above screenshot), you can click the copy button (Marked (1) in the above screenshot). A confirmation prompt is displayed. If you proceed, icons of all devices set to the same device type as the current device, will be overwritten with the current device's icon.
- The dropdown (3) contains all icons already used in the app for device icons. You need to navigate away or refresh the page once you add a new icon.
## 🌟 Pro Font Awesome icons
If you own the premium package of Font Awesome icons you can mount it in your Docker container the following way:
Make sure you have a root device with the MAC `Internet` (No other MAC addresses are currently support as root)
Make sure you have a root device with the MAC `Internet` (No other MAC addresses are currently supported as the root node) set to a network device type (e.g.: **Type**:`Router`).
To setup a device named `rapberrypi` as a `Switch` in our network.
> 💡 Tip: You can add dummy devices via the [Undiscoverables plugin](https://github.com/jokob-sk/Pi.Alert/blob/main/front/plugins/undiscoverables/README.md)
### 1) Device details page
> 💡 Tip: Export your configuration of the Network and Devices once in a while via the Export CSV feature under **Maintenance** -> **Backup/Restore** -> **CSV Export**.
## ⚡Quick setup:
* Go to a Device you want to use as network device (network nodes, such as a Switch).
* Set the **Type** of such a device to one of the following: AP, Firewall, Gateway, PLC, Powerline, Router, Switch, USB LAN Adapter, USB WIFI Adapter and WLAN (you can create a custom network type device with in Settings -> General -> `NETWORK_DEVICE_TYPES`).
* Save and go to Network where the devices you've marked as network devices (by selecting the Type as mentioned above) will show up as tabs.
* You can now assign the Unassigend devices to the network node.
* If port is empty or 0 a wifi icon is rendered, otherwise a ethernet port icon.
> [!NOTE]
>
> [Bulk-edit devices](/docs/DEVICES_BULK_EDITING.md) by using the `CSV Export` functionality in the `Maintenance` section. You can use this to fix `Internet` node assignment issues.
## 🔍Detailed example:
In this example you will setup a device named `rapberrypi` as a `Switch` in our network.
### 1. Device details page
- Go to the `Devices` (1) page:
@@ -13,23 +32,23 @@ To setup a device named `rapberrypi` as a `Switch` in our network.
- In the (2) `Details` tab navigate to the the `Type` (3) dropdown and select the type `Switch` (4).
> Note: Only the following device types will show up as selectable Network nodes ( = devices you can connect other devices to):
> AP, Firewall, Gateway, PLC, Powerline, Router, Switch, USB LAN Adapter, USB WIFI Adapter and WLAN.
> AP, Firewall, Gateway, Hypervisor, PLC, Powerline, Router, Switch, USB LAN Adapter, USB WIFI Adapter and WLAN. Custom types can be added via the `NETWORK_DEVICE_TYPES` setting.
- Assign a device to your root device from the `Node` (5) dropdown whitch has the MAC `Internet` (6) (Your name may differ, but the MAC needs to be set to `Internet` - this is done by default).
- Assign a device to your root device from the `Node` (5) dropdown which has the MAC `Internet` (6) (Your name may differ, but the MAC needs to be set to `Internet` - this is done by default).
- Notice the newly added `raspberrypi` (2) tab which now represents a network node, also showing up in the tree (3).
- As we asssigned the `raspberrypi` in the previous 1) Device details page section to the `Internet` parent network node in step (6), the link is also showing up in the tree diagram (4)
- As we asssigned the `raspberrypi` in the previous (1) Device details page section to the `Internet` parent network node in step (6), the link is also showing up in the tree diagram (4)
- We can now assign the device `(AppleTV)` (5) to this `raspberrypi` node, representing a network Switch in this example
### 1) Network page with 2 levels
### 3. Network page with 2 levels
- After clicking the `Assign` button in the previous section, the `(AppleTV)` (1) device is now connected to our `raspberrypi` (2).
@@ -41,3 +60,4 @@ To setup a device named `rapberrypi` as a `Switch` in our network.
@@ -16,6 +16,8 @@ WIFI's**, in this way, Pi.Alert will be able to identify the device, and it
will not identify it as a new device every so often (every time IOS or Android
decides to change the MAC).
**Random MACs** are recognized by the characters "2", "6", "A", or "E" as the 2nd character in the Mac address. You can disable specific prefixes to be detected as random MAC addresses by specifying the `UI_NOT_RANDOM_MAC` setting.
## IOS
![ios][ios]
@@ -33,7 +35,14 @@ decides to change the MAC).
[Read more here](../LICENSE.txt)
### Contact
pi.alert.application@gmail.com
Always use the Issue tracker for the correct fork, for example:
[jokob-sk/Pi.Alert](https://github.com/jokob-sk/Pi.Alert/issues). Please also follow the guidelines on:
<summary>:information_source: In the app hover over settings or fields/labels or click blue in-app ❔ (question-mark) icons to get to relevant documentation pages.</summary>

</details>
There is also an in-app Help / FAQ section that should be answering frequently asked questions.
### 📥 Installation
#### 🐳 Docker (Fully supported)
- The main installation method is as a [docker container - follow these instructions here](https://github.com/jokob-sk/Pi.Alert/blob/main/dockerfiles/README.md).
Design philosophy: Focus on core functionality and leverage existing apps and tools to make PiAlert integrate into other workflows.
Examples:
1. Supporting apprise makes more sense than implementing multiple individual notification gateways
2. Implementing regular expression support across settings for validation makes more sense than validating one setting with a specific expression.
UI-specific requests are a low priority as the framework picked by the original developer is not very extensible (and afaik doesn't support components) and has limited mobile support. Also, I argue the value proposition is smaller than working on something else.
Feel free to submit PRs if interested. try to **keep the PRs small/on-topic** so they are easier to review and approve.
That being said, I'd reconsider if more people and or recurring sponsors file a request 😉.
## 🙏 Feature requests
Please be as detailed as possible with **workarounds** you considered and why a native feature is the better way. This gives me better context and will make it more likely to be implemented. Ideally, a feature request should be in the format "I want to be able to do XYZ so that ZYX. I considered these approaches XYZ".
## ➕ Pull requests (PRs)
If you submit a PR please:
1. Check that your changes are backward compatible with existing installations and with a blank setup.
2. Existing features should always be preserved.
3. Keep the PR small, on-topic and don't change code that is not necessary for the PR to work
4. New features code should ideally be re-usable for different purposes, not be for a very narrow use-case.
5. New functionality should ideally be implemented via the Plugins system, if possible.
Suggested test cases:
- Blank setup with no DB or config
- Existing DB / config
- Sending a notification (e. g. Delete a device and wait for a scan to run) and testing all notification gateways, especially:
- Email, Apprise (e.g. via Telegram), webhook (e.g. via Discord), MQTT (e.g. via Home Assistant)
- Saving settings
- Test a couple of plugins
- Check the Error log for anything unusual
Some additional context:
* Permanent settings/config is stored in the `pialert.conf` file
* Currently temporary (session?) settings are stored in the `Parameters` DB table as key-value pairs. This table is wiped during a container rebuild/restart and its values are re-initialized from cookies/session data from the browser.
## 🐛 Submitting an issue or bug
Before submitting a new issue please spend a couple of minutes on research:
* Check [🛑 Common issues](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/DEBUG_TIPS.md#common-issues)
* Check [💡 Closed issues](https://github.com/jokob-sk/Pi.Alert/issues?q=is%3Aissue+is%3Aclosed) if a similar issue was solved in the past.
* When submitting an issue ❗[enable debug](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/DEBUG_TIPS.md)❗
⚠ Please follow the pre-defined issue template to resolve your issue faster.
## Setting up better name discovery with Reverse DNS
If you are running a DNS server, such as **AdGuard**, set up **Private reverse DNS servers** for a better name resolution on your network. Enabling this setting will enable PiAlert to execute dig and nslookup commands to automatically resolve device names based on their IP addresses.
> Example 1: Reverse DNS `disabled`
>
> ```
> jokob@Synology-NAS:/$ nslookup 192.168.1.58
> ** server can't find 58.1.168.192.in-addr.arpa: NXDOMAIN
>
> ```
> Example 2: Reverse DNS `enabled`
>
> ```
> jokob@Synology-NAS:/$ nslookup 192.168.1.58
> 45.1.168.192.in-addr.arpa name = jokob-NUC.localdomain.
> ```
### Enabling reverse DNS in AdGuard
1. Navigate to **Settings** -> **DNS Settings**
2. Locate **Private reverse DNS servers**
3. Enter your router IP address, such as `192.168.1.1`
4. Make sure you have **Use private reverse DNS resolvers** ticked.
5. Click **Apply** to save your settings.
### Using a custom resolv.conf file
You can configure a custom **/etc/resolv.conf** file in **docker-compose.yml** and set the nameserver to your LAN DNS server (e.g.: Pi-Hole). See the relevant [resolv.conf man](https://www.man7.org/linux/man-pages/man5/resolv.conf.5.html) entry for details.
> Submitted by [Isegrimm](https://github.com/Isegrimm) 🙏 (based on this [discussion](https://github.com/jokob-sk/Pi.Alert/discussions/449#discussioncomment-7281442))
Asuming the user already has a working Traefik setup, this is what's needed to make Pi.Alert work at a URL like www.domain.com/pialert/.
Note: Everything in these configs assumes '**www.domain.com**' as your domainname and '**section31**' as an arbitrary name for your certificate setup. You will have to substitute these with your own.
Also, I use the prefix '**pialert**'. If you want to use another prefix, change it in these files: dynamic.toml and default.
Content of my yaml-file (this is the generic Traefik config, which defines which ports to listen on, redirect http to https and sets up the certificate process).
It also contains Authelia, which I use for authentication.
To make Pi.Alert work with this setup I modified the default file at `/etc/nginx/sites-available/default` in the docker container by copying it to my local filesystem, adding the changes as specified by [cvc90](https://github.com/cvc90) and mounting the new file into the docker container, overwriting the original one. By mapping the file instead of changing the file in-place, the changes persist if an updated dockerimage is pulled. This is also a downside when the default file is updated, so I only use this as a temporary solution, until the dockerimage is updated with this change.
This is an explanation how settings are handled intended for anyone thinking about writing their own plugin or contributing to the project.
If you are a user of the app, settings should be described in the `Settings` section of the app. Open an issue if you'd like to clarify any of the settings.
### 🛢 Data storage
The source of truth for user-defined values is the `pialert.conf` file. Editing the file makes the App overwrite values in the `Settings` database table and in the `table_settings.json` file.
#### Settings database table
The `Settings` database table contains settings for App run purposes. The table is recreated every time the App restarts. The settings are loaded from the source-of-truth, that is the `pialert.conf` file. A high-level overview on the database structure can be found in the [database documentation](/docs/DATABASE.md).
#### table_settings.json
This is the [API endpoint](/docs/API.md) that reflects the state of the `Settings` database table. Settings can be accessed with the:
*`getSetting(key)` JavaScript method
The json file is also cached on the client-side local storage of the browser.
#### pialert.conf
> [!NOTE]
> This is the source of truth for settings. User-defined values in this files always override default values specified in the Plugin definition.
The App generates two `pialert.conf` entries for every setting (Since version 23.8+). One entry is the setting value, the second is the `__metadata` associated with the setting. This `__metadata` entry contains the full setting definition in JSON format. Currently unused, but intended to be used in future to extend the Settings system.
#### Plugin settings
> [!NOTE]
> This is the preferred way adding settings going forward. I'll be likely migrating all app settings into plugin-based settings.
Plugin settings are loaded dynamically from the `config.json` of individual plugins. If a setting isn't defined in the `pialert.conf` file, it is initialized via the `default_value` property of a setting from the `config.json` file. Check the [Plugins documentation](https://github.com/jokob-sk/Pi.Alert/blob/main/front/plugins/README.md#-setting-object-structure), section `⚙ Setting object structure` for details on the structure of the setting.
![Screen 1][screen1]
### Settings Process flow
The process flow is mostly managed by the [initialise.py](/pialert/initialise.py) file.
The script is responsible for reading user-defined values from a configuration file (`pialert.conf`), initializing settings, and importing them into a database. It also handles plugins and their configurations.
Here's a high-level description of the code:
1. Function Definitions:
-`ccd`: This function is used to handle user-defined settings and configurations. It takes several parameters related to the setting's name, default value, input type, options, group, and more. It saves the settings and their metadata in different lists (`conf.mySettingsSQLsafe` and `conf.mySettings`).
-`importConfigs`: This function is the main entry point of the script. It imports user settings from a configuration file, processes them, and saves them to the database.
-`read_config_file`: This function reads the configuration file (`pialert.conf`) and returns a dictionary containing the key-value pairs from the file.
2. Importing Configuration and Initializing Settings:
- The `importConfigs` function starts by checking the modification time of the configuration file to determine if it needs to be re-imported. If the file has not been modified since the last import, the function skips the import process.
- The function reads the configuration file using the `read_config_file` function, which returns a dictionary of settings.
- The script then initializes various user-defined settings using the `ccd` function, based on the values read from the configuration file. These settings are categorized into groups such as "General," "Email," "Webhooks," "Apprise," and more.
3. Plugin Handling:
- The script loads and handles plugins dynamically. It retrieves plugin configurations and iterates through each plugin.
- For each plugin, it extracts the prefix and settings related to that plugin and processes them similarly to other user-defined settings.
- It also handles scheduling for plugins with specific `RUN_SCHD` settings.
4. Saving Settings to the Database:
- The script clears the existing settings in the database and inserts the updated settings into the database using SQL queries.
5. Updating the API and Performing Cleanup:
- After importing the configurations, the script updates the API to reflect the changes in the settings.
- It saves the current timestamp to determine the next import time.
- Finally, it logs the successful import of the new configuration.
You need to specify the network interface and the network mask. You can also configure multiple subnets and specify VLANS (see exceptions below).
## Examples
> [!NOTE]
> Please use the UI to configure settings as that ensures that the config file is in the correct format. Edit `pialert.conf` directly only when really necessary.
* Examples for one and two subnets (❗ Note the `['...', '...']` format):
* One subnet: `SCAN_SUBNETS = ['192.168.1.0/24 --interface=eth0']`
* Two subnets: `SCAN_SUBNETS = ['192.168.1.0/24 --interface=eth0', '192.168.1.0/24 --interface=eth1 -vlan=107']`
## Explanation
### Network mask
**Example value: `192.168.1.0/24`**
The arp-scan time itself depends on the number of IP addresses to check.
> The number of IPs to check depends on the [network mask](https://www.calculator.net/ip-subnet-calculator.html) you set on the `SCAN_SUBNETS` setting.
> For example, a `/24` mask results in 256 IPs to check, whereas a `/16` mask checks around 65,536. Every IP takes a couple of seconds. This means that with an incorrect configuration, the arp-scan will take hours to complete instead of seconds.
Specify the network filter (which **significantly** speeds up the scan process). For example, the filter `192.168.1.0/24` covers IP ranges 192.168.1.0 to 192.168.1.255.
### Network interface (adapter)
**Example value: `--interface=eth0`**
The adapter will probably be `eth0` or `eth1`. (Check `System info` > `Network Hardware` or run `iwconfig` in the container to find your interface name(s))
> Run `ip -o link show | awk -F': ' '!/lo|vir|docker/ {print $2}'` in your container to find your interface name(s) (e.g.: `eth0`, `eth1`).
### VLANs
**Example value: `-vlan=107`**
- Append e.g.: ` -vlan=107` to the interface field (e.g.: `eth0 -vlan=107`) for multiple vlans. More details in this [comment in this issue](https://github.com/jokob-sk/Pi.Alert/issues/170#issuecomment-1419902988)
#### VLANs on a Hyper-V setup
> Community sourced content by [mscreations](https://github.com/mscreations) from this [discussion](https://github.com/jokob-sk/Pi.Alert/discussions/404).
> [!NOTE]
> The setup this was tested on: Bare Metal -> Hyper-V on Win Server 2019 -> Ubuntu 22.04 VM -> Docker -> PiAlert.
**Approach 1 (may cause issues):**
Configure multiple network adapters in Hyper-V with distinct VLANs connected to each one using Hyper-V's network setup. However, this action can potentially lead to the Docker host's inability to handle network traffic correctly. The issue may stem from the creation of routes for network time servers or domain controllers on every interface, thereby preventing proper synchronization of the underlying Ubuntu VM. This interference can affect the performance of other applications such as Authentik.
**Approach 2 (working example)**
Network connections to switches are configured as trunk and allow all VLANs access to the server.
By default Hyper-V only allows untagged packets through to the VM interface and no VLAN tagged packets get through. In order to fix this follow these steps:
1) Run the following command in Powershell on the Hyper-V machine:
```shell
Set-VMNetworkAdapterVlan -VMName <Docker VM Name> -Trunk -NativeVlanId 0 -AllowedVlanIdList "<comma separated list of vlans>"
```
(There might be other ways how adjust this.)
2) Within the VM, set up sub-interfaces for each of the VLANs so they can be scanned. On Ubuntu 22.04 Netplan can be used.
In /etc/netplan/00-installer-config.yaml, add vlan definitions:
```
network:
ethernets:
eth0:
dhcp4: yes
vlans:
eth0.2:
id: 2
link: eth0
addresses: [ "192.168.2.2/24" ]
routes:
- to: 192.168.2.0/24
via: 192.168.1.1
```
3) Run `sudo netplan apply` and the interfaces are then available to scan in PiAlert.
4) In this case, use `192.168.2.0/24 --interface=eth0.2` in PiAlert
Please note the accessibility of the macvlans when they are configured on the same computer. My understanding this is a general networking behavior, but feel free to clarify via a PR/issue.
- Pi.Alert does not detect the macvlan container when it is running on the same computer.
- Pi.Alert recognizes the macvlan container when it is running on a different computer.
Since version 23.01.14 PiAlert uses a simple timestamp-based version check to verify if a new version is available. You can check the [current and past releases here](https://github.com/jokob-sk/Pi.Alert/releases), or have a look at what I'm [currently working on](https://github.com/jokob-sk/Pi.Alert/issues/138).
If you are not on the latest version, the app will notify you, that a new released version is avialable the following way:
### 📧 Via email on a notification event
If any notification occurs and an email is sent, the email will contain a note that a new version is available. See the sample email below:

### 🆕 In the UI
In the UI via a notification Icon and via a custom message in the Maintenance section.

For a comparison, this is how the UI looks like if you are on the latest stable image:

## Implementation details
During build a [/home/pi/pialert/front/buildtimestamp.txt](https://github.com/jokob-sk/Pi.Alert/blob/092797e75ccfa8359444ad149e727358ac4da05f/Dockerfile#L44) file is created. The app then periodically checks if a new release is available with a newer timestamp in GitHub's rest-based JSON endpoint (check the `def isNewVersion():` method in `pialert.py` for details).
Pi.Alert will use the configured secret to create a hash signature of the request body. This SHA256-HMAC signature will appear in the `X-Webhook-Signature` header of each request to the webhook target URL. You can use the value of this header to validate the request was sent by Pi.Alert.
## Activating webhook signatures
All you need to do in order to add a signature to the request headers is to set the `WEBHOOK_SECRET` config value to a non-empty string.
## Validating webhook deliveries
There are a few things to keep in mind when validating the webhook delivery:
- Pi.Alert uses an HMAC hex digest to compute the hash
- The signature in the `X-Webhook-Signature` header always starts with `sha256=`
- The hash signature is generated using the configured `WEBHOOK_SECRET` and the request body.
- Never use a plain `==` operator. Instead, consider using a method like [`secure_compare`](https://www.rubydoc.info/gems/rack/Rack%2FUtils:secure_compare) or [`crypto.timingSafeEqual`](https://nodejs.org/api/crypto.html#cryptotimingsafeequala-b), which performs a "constant time" string comparison to help mitigate certain timing attacks against regular equality operators, or regular loops in JIT-optimized languages.
## Testing the webhook payload validation
You can use the following secret and payload to verify that your implementation is working correctly.
`secret`: 'this is my secret'
`payload`: '{"test":"this is a test body"}'
If your implementation is correct, the signature you generated should match the following:
If you want to learn more about webhook security, take a look at [GitHub's webhook documentation](https://docs.github.com/en/webhooks/about-webhooks).
You can find examples for validating a webhook delivery [here](https://docs.github.com/en/webhooks/using-webhooks/validating-webhook-deliveries#examples).
Some files were not shown because too many files have changed in this diff
Show More
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.