diff --git a/cmd/domaincheckbot/main.go b/cmd/domaincheckbot/main.go index 54af159..a088bdc 100644 --- a/cmd/domaincheckbot/main.go +++ b/cmd/domaincheckbot/main.go @@ -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