Compare commits

..

4 Commits

3 changed files with 18 additions and 8 deletions
+4
View File
@@ -9,6 +9,9 @@ RUN apk add --no-cache \
curl-dev \ curl-dev \
curl-static \ curl-static \
cjson-dev \ cjson-dev \
cjson-static \
zstd-dev \
zstd-static \
openssl-dev \ openssl-dev \
openssl-libs-static \ openssl-libs-static \
nghttp2-dev \ nghttp2-dev \
@@ -34,6 +37,7 @@ RUN make STATIC=1
FROM scratch FROM scratch
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /etc/ssl/cert.pem /etc/ssl/cert.pem
COPY --from=builder /build/build/dns-keeper /dns-keeper COPY --from=builder /build/build/dns-keeper /dns-keeper
ENTRYPOINT ["/dns-keeper"] ENTRYPOINT ["/dns-keeper"]
+1 -1
View File
@@ -11,7 +11,7 @@ Every `POLL_INTERVAL` seconds, DNS Keeper will check if the IPv4 in the domain(s
valid by seeing if `DNS_KEEPER_RECORD`.`DNS_KEEPER_DOMAIN` still points to itself. valid by seeing if `DNS_KEEPER_RECORD`.`DNS_KEEPER_DOMAIN` still points to itself.
> [!NOTE] > [!NOTE]
> On startup DNS Keeper starts a detached thread with a UDP socket on which it answers with > On startup DNS Keeper starts a detached thread with a UDP socket on which it answers
> a random set of challenge bytes. > a random set of challenge bytes.
> DNS Keeper will send an empty data-frame to its own socket using > DNS Keeper will send an empty data-frame to its own socket using
> the DNS resolved IPv4 address to see if it gets a response with the correct challenge bytes. > the DNS resolved IPv4 address to see if it gets a response with the correct challenge bytes.
+13 -7
View File
@@ -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");