Fix: only update self domain if not in domain list
This commit is contained in:
+13
-7
@@ -108,8 +108,10 @@ int main(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int failed_updates = 0;
|
int failed_updates = 0;
|
||||||
|
int self_domain_in_list = 0;
|
||||||
for (int i = 0; i < cfg.domain_count; i++) {
|
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);
|
int gret = gandi_update_domains(cfg.domains[i], cached_ip, public_ip);
|
||||||
if (gret == -3) {
|
if (gret == -3) {
|
||||||
@@ -120,14 +122,18 @@ int main(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int sret = gandi_update_record(cfg.dns_keeper_domain, cfg.dns_keeper_record,
|
if (!self_domain_in_list) {
|
||||||
cached_ip, public_ip);
|
int sret = gandi_update_record(cfg.dns_keeper_domain, cfg.dns_keeper_record,
|
||||||
if (sret == 0) {
|
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);
|
strncpy(cached_ip, public_ip, GANDI_MAX_IP_LEN - 1);
|
||||||
cached_ip[GANDI_MAX_IP_LEN - 1] = '\0';
|
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");
|
if (failed_updates) log_error("One or more updates failed this cycle");
|
||||||
|
|||||||
Reference in New Issue
Block a user