Revert "Add option to only compare MAC for alerting"
This reverts commit 7ca8feeec9.
This commit is contained in:
parent
7ca8feeec9
commit
6ed487ea21
3 changed files with 10 additions and 25 deletions
|
|
@ -6,24 +6,12 @@ import (
|
|||
)
|
||||
|
||||
func host_in_db(host Host, dbHosts []Host) bool { // Check if host is already in DB
|
||||
|
||||
if AppConfig.OnlyCompareMac {
|
||||
for _, oneHost := range dbHosts {
|
||||
if host.Mac == oneHost.Mac {
|
||||
oneHost.Date = host.Date
|
||||
oneHost.Now = 1
|
||||
db_update(oneHost)
|
||||
return true
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for _, oneHost := range dbHosts {
|
||||
if host.Ip == oneHost.Ip && host.Mac == oneHost.Mac && host.Hw == oneHost.Hw {
|
||||
oneHost.Date = host.Date
|
||||
oneHost.Now = 1
|
||||
db_update(oneHost)
|
||||
return true
|
||||
}
|
||||
for _, oneHost := range dbHosts {
|
||||
if host.Ip == oneHost.Ip && host.Mac == oneHost.Mac && host.Hw == oneHost.Hw {
|
||||
oneHost.Date = host.Date
|
||||
oneHost.Now = 1
|
||||
db_update(oneHost)
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
|
|
@ -39,4 +27,4 @@ func hosts_compare(foundHosts []Host, dbHosts []Host) {
|
|||
db_insert(oneHost)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -14,11 +14,10 @@ func get_config() (config Conf) {
|
|||
viper.SetDefault("TIMEOUT", "60")
|
||||
viper.SetDefault("SHOUTRRR_URL", "")
|
||||
viper.SetDefault("THEME", "solar")
|
||||
viper.SetDefault("ONLY_COMPARE_MAC", false)
|
||||
|
||||
viper.SetConfigFile(configPath)
|
||||
viper.SetConfigFile(configPath)
|
||||
viper.SetConfigType("env")
|
||||
viper.ReadInConfig()
|
||||
viper.ReadInConfig()
|
||||
|
||||
viper.AutomaticEnv() // Get ENVIRONMENT variables
|
||||
|
||||
|
|
@ -29,7 +28,6 @@ func get_config() (config Conf) {
|
|||
config.Timeout = viper.GetInt("TIMEOUT")
|
||||
config.ShoutUrl = viper.Get("SHOUTRRR_URL").(string)
|
||||
config.Theme = viper.Get("THEME").(string)
|
||||
config.OnlyCompareMac = viper.GetBool("ONLY_COMPARE_MAC")
|
||||
|
||||
return config
|
||||
}
|
||||
|
|
@ -39,4 +37,4 @@ func write_config() {
|
|||
viper.SetConfigType("env")
|
||||
viper.Set("THEME", AppConfig.Theme)
|
||||
viper.WriteConfig()
|
||||
}
|
||||
}
|
||||
|
|
@ -23,7 +23,6 @@ type Conf struct {
|
|||
Timeout int
|
||||
ShoutUrl string
|
||||
Theme string
|
||||
OnlyCompareMac bool
|
||||
}
|
||||
|
||||
var AppConfig Conf
|
||||
|
|
|
|||
Loading…
Reference in a new issue