added support of multiple arp-scan interfaces & attempt at solving DB permission issues

This commit is contained in:
jokob.sk
2022-08-16 14:15:02 +10:00
parent adf11de4ec
commit 929ea98fce
5 changed files with 32 additions and 9 deletions

View File

@@ -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<ip>((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

View File

@@ -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'

View File

@@ -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}

View File

@@ -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

View File

@@ -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;