Revert "Add option to only compare MAC for alerting"

This reverts commit 7ca8feeec9.
This commit is contained in:
bugbounce 2022-10-22 00:29:01 +05:30
parent 7ca8feeec9
commit 6ed487ea21
3 changed files with 10 additions and 25 deletions

View file

@ -6,24 +6,12 @@ import (
) )
func host_in_db(host Host, dbHosts []Host) bool { // Check if host is already in DB func host_in_db(host Host, dbHosts []Host) bool { // Check if host is already in DB
for _, oneHost := range dbHosts {
if AppConfig.OnlyCompareMac { if host.Ip == oneHost.Ip && host.Mac == oneHost.Mac && host.Hw == oneHost.Hw {
for _, oneHost := range dbHosts { oneHost.Date = host.Date
if host.Mac == oneHost.Mac { oneHost.Now = 1
oneHost.Date = host.Date db_update(oneHost)
oneHost.Now = 1 return true
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
}
} }
} }
return false return false

View file

@ -14,11 +14,10 @@ func get_config() (config Conf) {
viper.SetDefault("TIMEOUT", "60") viper.SetDefault("TIMEOUT", "60")
viper.SetDefault("SHOUTRRR_URL", "") viper.SetDefault("SHOUTRRR_URL", "")
viper.SetDefault("THEME", "solar") viper.SetDefault("THEME", "solar")
viper.SetDefault("ONLY_COMPARE_MAC", false)
viper.SetConfigFile(configPath) viper.SetConfigFile(configPath)
viper.SetConfigType("env") viper.SetConfigType("env")
viper.ReadInConfig() viper.ReadInConfig()
viper.AutomaticEnv() // Get ENVIRONMENT variables viper.AutomaticEnv() // Get ENVIRONMENT variables
@ -29,7 +28,6 @@ func get_config() (config Conf) {
config.Timeout = viper.GetInt("TIMEOUT") config.Timeout = viper.GetInt("TIMEOUT")
config.ShoutUrl = viper.Get("SHOUTRRR_URL").(string) config.ShoutUrl = viper.Get("SHOUTRRR_URL").(string)
config.Theme = viper.Get("THEME").(string) config.Theme = viper.Get("THEME").(string)
config.OnlyCompareMac = viper.GetBool("ONLY_COMPARE_MAC")
return config return config
} }

View file

@ -23,7 +23,6 @@ type Conf struct {
Timeout int Timeout int
ShoutUrl string ShoutUrl string
Theme string Theme string
OnlyCompareMac bool
} }
var AppConfig Conf var AppConfig Conf