Skip to content

Commit

Permalink
Pi.Alert v3.02
Browse files Browse the repository at this point in the history
#114 - Fixed: UNIQUE constraint failed with Local MAC
  • Loading branch information
pucherot committed Apr 24, 2021
1 parent 9c324b1 commit 9232f31
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 21 deletions.
10 changes: 6 additions & 4 deletions back/pialert.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ def scan_network ():
read_DHCP_leases ()

# Load current scan data
print ('\nProcesising scan results...')
print ('\nProcessing scan results...')
print_log ('Save scanned devices')
save_scanned_devices (arpscan_devices, cycle_interval)

Expand Down Expand Up @@ -598,10 +598,12 @@ def save_scanned_devices (p_arpscan_devices, p_cycle_interval):
# local_ip_cmd = ["ip route list default | awk {'print $7'}"]
local_ip_cmd = ["ip -o route get 1 | sed 's/^.*src \\([^ ]*\\).*$/\\1/;q'"]
local_ip = subprocess.Popen (local_ip_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0].decode().strip()

sql.execute ("INSERT INTO CurrentScan (cur_ScanCycle, cur_MAC, cur_IP, cur_Vendor, cur_ScanMethod) "+
"VALUES ( ?, ?, ?, Null, 'local_MAC') ", (cycle, local_mac, local_ip) )

# Check if local mac has been detected with other methods
sql.execute ("SELECT COUNT(*) FROM CurrentScan WHERE cur_ScanCycle = ? AND cur_MAC = ? ", (cycle, local_mac) )
if sql.fetchone()[0] == 0 :
sql.execute ("INSERT INTO CurrentScan (cur_ScanCycle, cur_MAC, cur_IP, cur_Vendor, cur_ScanMethod) "+
"VALUES ( ?, ?, ?, Null, 'local_MAC') ", (cycle, local_mac, local_ip) )

#-------------------------------------------------------------------------------
def print_scan_stats ():
Expand Down
4 changes: 2 additions & 2 deletions config/version.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
VERSION = '3.01'
VERSION = '3.02'
VERSION_YEAR = '2021'
VERSION_DATE = '2021-04-22'
VERSION_DATE = '2021-04-24'
Loading

0 comments on commit 9232f31

Please sign in to comment.