Compare commits

...

6 Commits

5 changed files with 25 additions and 12 deletions
+3
View File
@@ -52,3 +52,6 @@ Module.symvers
Mkfile.old
dkms.conf
# Build output
build/
+4
View File
@@ -9,6 +9,9 @@ RUN apk add --no-cache \
curl-dev \
curl-static \
cjson-dev \
cjson-static \
zstd-dev \
zstd-static \
openssl-dev \
openssl-libs-static \
nghttp2-dev \
@@ -34,6 +37,7 @@ RUN make STATIC=1
FROM scratch
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
ENTRYPOINT ["/dns-keeper"]
+4 -4
View File
@@ -22,13 +22,13 @@ OBJS := $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o, $(SRCS))
all: $(BUILD_DIR)/$(TARGET)
$(BUILD_DIR)/$(TARGET): $(OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c | $(BUILD_DIR)
$(CC) $(CFLAGS) -c $< -o $@
$(CC) $(CFLAGS) -c $< -o $@
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
mkdir -p $(BUILD_DIR)
clean:
rm -rf $(BUILD_DIR)
rm -rf $(BUILD_DIR)
+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.
> [!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.
> 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.
+13 -7
View File
@@ -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");