diff --git a/back/pialert.py b/back/pialert.py index e7552aee..2c850226 100644 --- a/back/pialert.py +++ b/back/pialert.py @@ -489,14 +489,19 @@ def query_ScanCycle_Data (pOpenCloseDB = False): #------------------------------------------------------------------------------- def execute_arpscan (): - # #101 - arp-scan subnet configuration - # Prepare command arguments - subnets = SCAN_SUBNETS.strip().split() - # Retry is 6 to avoid false offline devices - arpscan_args = ['sudo', 'arp-scan', '--ignoredups', '--retry=6'] + subnets - - # Execute command - arpscan_output = subprocess.check_output (arpscan_args, universal_newlines=True) + + # output of possible multiple interfaces + arpscan_output = "" + + # multiple interfaces + if type(SCAN_SUBNETS) is list: + print(" arp-scan: Multiple interfaces") + for interface in SCAN_SUBNETS : + arpscan_output += execute_arpscan_on_interface (interface) + # one interface only + else: + print(" arp-scan: One interface") + arpscan_output += execute_arpscan_on_interface (SCAN_SUBNETS) # Search IP + MAC + Vendor as regular expresion re_ip = r'(?P((2[0-5]|1[0-9]|[0-9])?[0-9]\.){3}((2[0-5]|1[0-9]|[0-9])?[0-9]))' @@ -528,6 +533,17 @@ def execute_arpscan (): # return list return unique_devices +#------------------------------------------------------------------------------- +def execute_arpscan_on_interface (SCAN_SUBNETS): + # #101 - arp-scan subnet configuration + # Prepare command arguments + subnets = SCAN_SUBNETS.strip().split() + # Retry is 6 to avoid false offline devices + arpscan_args = ['sudo', 'arp-scan', '--ignoredups', '--retry=6'] + subnets + + # Execute command + return subprocess.check_output (arpscan_args, universal_newlines=True) + #------------------------------------------------------------------------------- def copy_pihole_network (): # check if Pi-hole is active diff --git a/config/pialert.conf b/config/pialert.conf index 8146b353..db9b22eb 100644 --- a/config/pialert.conf +++ b/config/pialert.conf @@ -80,6 +80,9 @@ DHCP_LEASES = '/etc/pihole/dhcp.leases' # # Scan using interface eth0 # SCAN_SUBNETS = '--localnet --interface=eth0' +# +# Scan multiple interfaces (eth1 and eth0): +# SCAN_SUBNETS = [ '192.168.1.0/24 --interface=eth1', '192.168.1.0/24 --interface=eth0' ] SCAN_SUBNETS = '--localnet' diff --git a/docker-compose.yml b/docker-compose.yml index b1ec288d..3f878e97 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,7 @@ services: volumes: - ${APP_DATA_LOCATION}/pialert/config:/home/pi/pialert/config - ${APP_DATA_LOCATION}/pialert/db/pialert.db:/home/pi/pialert/db/pialert.db - - ${LOGS_LOCATION}/tmp:/home/pi/pialert/log + - ${LOGS_LOCATION}:/home/pi/pialert/log environment: - TZ=${TZ} - PORT=${PORT} diff --git a/dockerfiles/start.sh b/dockerfiles/start.sh index 67099939..56551321 100755 --- a/dockerfiles/start.sh +++ b/dockerfiles/start.sh @@ -12,6 +12,9 @@ if [ -n "${PORT}" ]; then sed -ie 's/listen 20211/listen '${PORT}'/g' /etc/nginx/sites-available/default fi +# I hope this will fix DB permission issues going forward +chown -R www-data:www-data /home/pi/pialert/db/pialert.db + /etc/init.d/php7.4-fpm start /etc/init.d/nginx start cron -f diff --git a/install/default b/install/default index 1e235e9c..983f9d5c 100644 --- a/install/default +++ b/install/default @@ -2,6 +2,7 @@ server { listen 80 default_server; root /var/www/html; index index.php; + rewrite /pialert/(.*) / permanent; location ~* \.php$ { fastcgi_pass unix:/run/php/php7.4-fpm.sock;