From 918ffe1b5b51dcbebee11cb735957f1bd2449b71 Mon Sep 17 00:00:00 2001 From: maauso Date: Thu, 3 Nov 2022 19:34:32 +0100 Subject: [PATCH] remove the ip in host_in_db in order to avoid the dhcp false positives --- .gitignore | 8 +++++++- Makefile | 3 ++- src/compare.go | 8 ++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 5969e24..eb651ca 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,10 @@ # Ignore local data data/ watchyourlan -tmp/ \ No newline at end of file +tmp/ +/src/db.sqlite +/.idea/modules.xml +/.idea/vcs.xml +/.idea/WatchYourLAN.iml +/.idea/.gitignore +/.idea/golinter.xml diff --git a/Makefile b/Makefile index 5d352cc..1ac6d6c 100644 --- a/Makefile +++ b/Makefile @@ -39,4 +39,5 @@ clean: rm src/$(DNAME) || true docker rmi -f $(DUSER)/$(DNAME) -dev: docker-build docker-run \ No newline at end of file +dev: docker-build docker-run + diff --git a/src/compare.go b/src/compare.go index 9b1a614..d809385 100644 --- a/src/compare.go +++ b/src/compare.go @@ -7,7 +7,7 @@ import ( func host_in_db(host Host, dbHosts []Host) bool { // Check if host is already in DB for _, oneHost := range dbHosts { - if host.Ip == oneHost.Ip && host.Mac == oneHost.Mac && host.Hw == oneHost.Hw { + if host.Mac == oneHost.Mac && host.Hw == oneHost.Hw { oneHost.Date = host.Date oneHost.Now = 1 db_update(oneHost) @@ -20,11 +20,11 @@ func host_in_db(host Host, dbHosts []Host) bool { // Check if host is already in func hosts_compare(foundHosts []Host, dbHosts []Host) { for _, oneHost := range foundHosts { if !(host_in_db(oneHost, dbHosts)) { - oneHost.Now = 1 // Mark host online + oneHost.Now = 1 // Mark host online msg := fmt.Sprintf("UNKNOWN HOST IP: '%s', MAC: '%s', Hw: '%s'", oneHost.Ip, oneHost.Mac, oneHost.Hw) log.Println("WARN:", msg) - shoutr_notify(msg) // Notify through Shoutrrr + shoutr_notify(msg) // Notify through Shoutrrr db_insert(oneHost) } } -} \ No newline at end of file +}