Skip to content

Commit 9232f31

Browse files
committed
Pi.Alert v3.02
#114 - Fixed: UNIQUE constraint failed with Local MAC
1 parent 9c324b1 commit 9232f31

File tree

8 files changed

+39
-21
lines changed

8 files changed

+39
-21
lines changed

back/pialert.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ def scan_network ():
374374
read_DHCP_leases ()
375375

376376
# Load current scan data
377-
print ('\nProcesising scan results...')
377+
print ('\nProcessing scan results...')
378378
print_log ('Save scanned devices')
379379
save_scanned_devices (arpscan_devices, cycle_interval)
380380

@@ -598,10 +598,12 @@ def save_scanned_devices (p_arpscan_devices, p_cycle_interval):
598598
# local_ip_cmd = ["ip route list default | awk {'print $7'}"]
599599
local_ip_cmd = ["ip -o route get 1 | sed 's/^.*src \\([^ ]*\\).*$/\\1/;q'"]
600600
local_ip = subprocess.Popen (local_ip_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0].decode().strip()
601-
602-
sql.execute ("INSERT INTO CurrentScan (cur_ScanCycle, cur_MAC, cur_IP, cur_Vendor, cur_ScanMethod) "+
603-
"VALUES ( ?, ?, ?, Null, 'local_MAC') ", (cycle, local_mac, local_ip) )
604601

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

606608
#-------------------------------------------------------------------------------
607609
def print_scan_stats ():

config/version.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
VERSION = '3.01'
1+
VERSION = '3.02'
22
VERSION_YEAR = '2021'
3-
VERSION_DATE = '2021-04-22'
3+
VERSION_DATE = '2021-04-24'

0 commit comments

Comments
 (0)