Bug #6566
closedCloudflare DnyDNS Update with subdomains
0%
Description
If a host such as ip.example.co.uk is used for the cloudflare dynamic dns update the zone_id will fail to be returned.
I believe this is due to the following code from src/etc/inc/dyndns.class:
$dnsHost = str_replace(' ', '', $this->_dnsHost);
$host_names = explode(".", $dnsHost);
$bottom_host_name = $host_names[count($host_names)-2] . "." . $host_names[count($host_names)-1];
as $bottom_host_name
would end up as "co.uk".
Something like this:
$dnsHost = str_replace(' ', '', $this->_dnsHost);
$host_names = explode(".", $dnsHost);
if (count($host_names) > 3) {
$bottom_host_name = $host_names[count($host_names)-3] . "." . $host_names[count($host_names)-2] . "." . $host_names[count($host_names)-1];
} else {
$bottom_host_name = $host_names[count($host_names)-2] . "." . $host_names[count($host_names)-1];
}
would check if the hostname contains more than three parts and would correctly retrieve the zone_id from cloudflare - I've tested it with ip.example.co.uk but my php isn't great so someone might want to improve it.
Updated by Euan Kerr about 9 years ago
Looking at this again - I don't think this would work for a subdomain such as ip.test.example.com.
It might be possible to use something like https://publicsuffix.org/list/ to get a list of subdomains for TLDs and do a lookup and if it's a TLD with a public subdomain then use the >3 code.
Updated by Jim Pingle about 6 years ago
- Status changed from New to Duplicate
Duplicate of #6778 which was fixed years ago in 2446fffa5932e8debcaf165bfaf5492cea429c60