diff --git a/src/main.c b/src/main.c index ee03956..68df7d5 100644 --- a/src/main.c +++ b/src/main.c @@ -108,8 +108,10 @@ int main(void) { } int failed_updates = 0; + int self_domain_in_list = 0; for (int i = 0; i < cfg.domain_count; i++) { - if (strcmp(cfg.domains[i], cfg.dns_keeper_domain) == 0) continue; + if (strcmp(cfg.domains[i], cfg.dns_keeper_domain) == 0) + self_domain_in_list = 1; int gret = gandi_update_domains(cfg.domains[i], cached_ip, public_ip); if (gret == -3) { @@ -120,14 +122,18 @@ int main(void) { } } - int sret = gandi_update_record(cfg.dns_keeper_domain, cfg.dns_keeper_record, - cached_ip, public_ip); - if (sret == 0) { + if (!self_domain_in_list) { + int sret = gandi_update_record(cfg.dns_keeper_domain, cfg.dns_keeper_record, + cached_ip, public_ip); + if (sret != 0) { + log_error("Failed to update self record, cached IP not advanced"); + failed_updates = 1; + } + } + + if (!failed_updates) { strncpy(cached_ip, public_ip, GANDI_MAX_IP_LEN - 1); cached_ip[GANDI_MAX_IP_LEN - 1] = '\0'; - } else { - log_error("Failed to update self record, cached IP not advanced"); - failed_updates = 1; } if (failed_updates) log_error("One or more updates failed this cycle");