mholt / caddy-dynamicdns

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

Increased debug logging, refactor IP sources #34

Closed francislavoie closed 1 year ago

francislavoie commented 1 year ago

As per https://caddy.community/t/dynamic-dns-ipv6/19053/8, there's a distinct lack of debug logging to be able to understand what's going wrong.

Also, I rewrote the HTTP source because it had duplicated code branches and I think it would give up on trying IPv6 if a particular endpoint returned a good IPv4 but not IPv6, because of the if len(ips) > 0 condition. Looping over the endpoints twice makes the IP versions not dependent on eachother at all, so it should be more reliable that way.

Also fixed a bug with lookupCurrentIPsFromDNS which was only keeping one of either A or AAAA for a domain instead of both, which meant the initial load was often incorrect for servers with both IPv4 and IPv6.

mholt commented 1 year ago

Does this fix #30, or is it just semi-related? :)

francislavoie commented 1 year ago

It doesn't fix that yet, no. All I did was stop A and AAAA from stepping on eachother in that function. But it still needs to be changed to return data per domain per type, and then the update procedure will need to diff them.