diff options
author | Phil Davis <phil.davis@inf.org> | 2016-07-20 16:41:11 +0930 |
---|---|---|
committer | Phil Davis <phil.davis@inf.org> | 2016-07-20 16:41:11 +0930 |
commit | b18e885cbcc719bf1d80f41e4afbc92de684ead5 (patch) | |
tree | c33a1e8870ba51223f7880f5cc551508da04f7cc /src/etc/inc/dyndns.class | |
parent | c9d6b915daced9767ff596ee9485ec2d9a573a41 (diff) | |
download | pfsense-b18e885cbcc719bf1d80f41e4afbc92de684ead5.zip pfsense-b18e885cbcc719bf1d80f41e4afbc92de684ead5.tar.gz |
Backport IPv6 support for CloudFlare
Original code for master in pull request #3061
Diffstat (limited to 'src/etc/inc/dyndns.class')
-rw-r--r-- | src/etc/inc/dyndns.class | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/etc/inc/dyndns.class b/src/etc/inc/dyndns.class index bd8fa05..41f3cc4 100644 --- a/src/etc/inc/dyndns.class +++ b/src/etc/inc/dyndns.class @@ -79,6 +79,7 @@ * - Custom DDNS (any URL) * - Custom DDNS IPv6 (any URL) * - CloudFlare (www.cloudflare.com) + * - CloudFlare IPv6 (www.cloudflare.com) * - Eurodns (eurodns.com) * - GratisDNS (gratisdns.dk) * - City Network (citynetwork.se) @@ -126,7 +127,8 @@ * SelfHost - Last Tested: 26 December 2011 * Amazon Route 53 - Last tested: 01 April 2012 * DNS-O-Matic - Last Tested: 9 September 2010 - * CloudFlare - Last Tested: 30 May 2013 + * CloudFlare - Last Tested: 17 July 2016 + * CloudFlare IPv6 - Last Tested: 17 July 2016 * Eurodns - Last Tested: 27 June 2013 * GratisDNS - Last Tested: 15 August 2012 * OVH DynHOST - Last Tested: NEVER @@ -249,6 +251,7 @@ case 'custom-v6': case 'spdyn-v6': case 'freedns-v6': + case 'cloudflare-v6': $this->_useIPv6 = true; break; default: @@ -319,6 +322,7 @@ case 'he-net-tunnelbroker': case 'route53': case 'cloudflare': + case 'cloudflare-v6': case 'eurodns': case 'gratisdns': case 'ovh-dynhost': @@ -724,7 +728,10 @@ } curl_setopt($ch, CURLOPT_URL, $server); break; + case 'cloudflare-v6': case 'cloudflare': + $isv6 = ($this->_dnsService === 'cloudflare-v6'); + $recordType = $isv6 ? "AAAA" : "A"; $needsIP = TRUE; $dnsServer ='api.cloudflare.com'; $dnsHost = str_replace(' ', '', $this->_dnsHost); @@ -744,14 +751,14 @@ $output = json_decode(curl_exec($ch)); $zone = $output->result[0]->id; if ($zone) { // If zone ID was found get host ID - $getHostId = "https://{$dnsServer}/client/v4/zones/{$zone}/dns_records?name={$this->_dnsHost}"; + $getHostId = "https://{$dnsServer}/client/v4/zones/{$zone}/dns_records?name={$this->_dnsHost}&type={$recordType}"; curl_setopt($ch, CURLOPT_URL, $getHostId); $output = json_decode(curl_exec($ch)); $host = $output->result[0]->id; if ($host) { // If host ID was found update host $hostData = array( "content" => "{$this->_dnsIP}", - "type" => "A", + "type" => "{$recordType}", "name" => "{$this->_dnsHost}" ); $data_json = json_encode($hostData); @@ -1320,6 +1327,7 @@ $status = $status_intro . $error_str . gettext("Result did not match.") . " [" . $data . "]"; } break; + case 'cloudflare-v6': case 'cloudflare': $output = json_decode($data); if ($output->result->content === $this->_dnsIP) { |