mholt / caddy-dynamicdns

Caddy app that keeps your DNS records (A/AAAA) pointed at itself.
Apache License 2.0
236 stars 24 forks source link

Bug: Will not update when one domain is outdated but another is up-to-date #30

Closed Frans-Willem closed 1 year ago

Frans-Willem commented 1 year ago

If you intend to update two domains (say A.com and B.com), and A.com is correct, but B.com is outdated or incorrect, this utility will still not update B.com at startup I believe this to be caused by the fact that the lastIPs table is filled from the current DNS domains, and will at that point contain both correct and outdated IP, and then upon receiving a response from one of the IP providers it will consider it to not be renewed as it is already contained in lastIPs.

mholt commented 1 year ago

Oh, that's interesting. Plausible theory! I'm mobile so I can't check right now, but I'd happily review a PR if you're up for it. Or I'll try to take a look at and fix it in a while.

francislavoie commented 1 year ago

Reading the code, I can confirm this is an issue. There's a logic problem with the handling of records. It throws all the current IPs in a bag regardless of the domain or IP version, so there's no opportunity later for the code to determine which individual domains are out of date.

The lookupCurrentIPsFromDNS function needs to be rewritten to return the current known IP per domain, per type. A bit of a complicated nested structure, but it would be the best way to go to make sure the correct subset of modifications are performed.