mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-06 17:15:38 -08:00
added support of multiple arp-scan interfaces & attempt at solving DB permission issues
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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'
|
||||
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user