mrikirill / SynologyDDNSCloudflareMultidomain

Synology DDNS Cloudflare service provider with multidomains and subdomains
https://mrikirill.github.io/SynologyDDNSCloudflareMultidomain/
MIT License
465 stars 65 forks source link

IPv6 Support #12

Closed giacomitti closed 3 years ago

giacomitti commented 3 years ago

What about implement IPv6 support in script?

Regards.

mrikirill commented 3 years ago

By following this article A zones support ipv4 only. AAAA zones for ipv6. As an idea script probably can detect ipv4 and use A zone upd (current case) and ipv6 use AAAA zone

smoetje commented 3 years ago

Synology doesn't give ipv6 address as an input parameter by default, so it'll have to be via by retrieving ipv6 with file_get_contents('https://api64.ipify.org'). I tried some simulations in the existing code with some quick coding and works fine.

However after checking the script itself will need some recoding, in particular now how jsons are being parsed when getting responses from the Cloudflare api and how it's recorded in the hostList array. E.g. now jsons are parsed on array element number 0. But after checking I noticed element 0 sometimes contains A and sometimes AAAA (or both in element 0 and 1 or opposite). not reliable.

I am working on it now and'll post it when done.

mrikirill commented 3 years ago

Added getting a zone type by ip type: IPv4 = zone A IPv6 = zone AAAA as @smoetje has mentioned I've added getting ip from https://api64.ipify.org instead of if Synology input param

smoetje commented 3 years ago

There are some serious issues after these modifications. When you have IPV6 it basically only updates the IPV6 and no longer IPV4. It's due how the hostlist array is built and parsed afterwards based on recordsId. Basically every DNS record has a separate RecordId for A and another RecordId for AAAA . I fixed the script where now IPV4 and IPV6 are both recognized. If there's no IPV6, then only IPV4 will be updated.

I completely fixed it and over here it works now for both IPV4 and IPV6. Personally I would've done some things completely different (e.g. the way how the hostslist array is constructed, the api calls, etc) and extend it with the supported error messages accepted by DSM. But the one I have will do just fine now, these changes will be for another occasion...

smoetje commented 3 years ago

Personally I would've done some things completely different (e.g. the way how the hostslist array is constructed, the api calls, etc) and extend it with the supported error messages accepted by DSM. But the one I have will do just fine now, these changes will be for another occasion...

I have been further thinking on this: A new target-array which contains RecordId keys instead of fullname can simply things. Because fullname can contain 1 or 2 values, a RecordId is always unique after further figuring-out the Cloudflare api.

I made a pull request of with my (properly working) changes. Further improvement is in the progress, I'll get back to it...