check a second time if there was a change

This commit is contained in:
Seraphim Strub 2023-04-16 11:56:25 +02:00
parent 09b2073e1e
commit aa20d59a0f

View file

@ -48,15 +48,7 @@ func main() {
select {
case <-ticker.C:
for _, d := range config.Domains {
domain := dns.CheckDomain(d)
retrievedDomain, _ := repo.GetValue(d)
if reflect.DeepEqual(domain, retrievedDomain) {
log.Debugf(" %v: did not change", d)
} else {
log.Infof("!%v: changed", d)
go sendWebhook(client, domain, retrievedDomain)
repo.SetValue(domain)
}
go checkDomain(0, d, repo, client)
}
case <-tickerGC.C:
@ -81,6 +73,24 @@ func main() {
<-s
}
func checkDomain(counter int, d string, repo *repository.DomainRepository, client webhook.Client) {
domain := dns.CheckDomain(d)
retrievedDomain, _ := repo.GetValue(d)
if reflect.DeepEqual(domain, retrievedDomain) {
log.Debugf(" %v: did not change", d)
return
}
log.Infof("!%v: changed", d)
counter += 1
if counter >= 2 {
go sendWebhook(client, domain, retrievedDomain)
repo.SetValue(domain)
return
}
time.Sleep(1 * time.Minute)
checkDomain(counter, d, repo, client)
}
func sendWebhook(client webhook.Client, domain repository.Domain, oldDomain repository.Domain) {
var status string