From 745d37797c62761bcbd08ad607bd9c19cc0e3a64 Mon Sep 17 00:00:00 2001 From: Wagner Sartori Junior Date: Mon, 28 Aug 2017 12:30:42 +0200 Subject: [PATCH] dyndns: Adding support for ClouDNS (https://www.cloudns.net) --- src/etc/inc/dyndns.class | 48 ++++++++++++++++++++++ src/etc/inc/globals.inc | 2 +- src/etc/inc/services.inc | 4 +- src/usr/local/share/locale/pot/pfSense.pot | 4 +- src/usr/local/www/services_dyndns_edit.php | 16 +++++++- 5 files changed, 68 insertions(+), 6 deletions(-) diff --git a/src/etc/inc/dyndns.class b/src/etc/inc/dyndns.class index 07b34bbdaf..5241173ad5 100644 --- a/src/etc/inc/dyndns.class +++ b/src/etc/inc/dyndns.class @@ -62,6 +62,7 @@ * - DuiaDNS IPv6 (www.duiadns.net) * - Hover (www.hover.com) * - DreamHost DNS (www.dreamhost.com) + * - ClouDNS (www.cloudns.net) * +----------------------------------------------------+ * Requirements: * - PHP version 4.0.2 or higher with the CURL Library and the PCRE Library @@ -118,6 +119,7 @@ * Hover - Last Tested: 15 February 2017 * DreamHost - Last Tested: 30 April 2017 * DreamHost IPv6 - Not Yet Tested + * ClouDNS - Last Tested: 22 August 2017 * +====================================================+ * * @author E.Kristensen @@ -226,6 +228,13 @@ if (!$dnsZoneID) $this->_error(8); if (!$dnsTTL) $this->_error(9); break; + case 'cloudns': + if (!$dnsUser) $this->_error(3); + if (!$dnsPass) $this->_error(4); + if (!$dnsHost) $this->_error(5); + if (!$dnsDomain) $this->_error(5); + if (!$dnsTTL) $this->_error(9); + break; case 'custom': if (!$dnsUpdateURL) $this->_error(7); break; @@ -327,6 +336,7 @@ case 'spdyn': case 'spdyn-v6': case 'all-inkl': + case 'cloudns': case 'hover': $this->_update(); if ($this->_dnsDummyUpdateDone == true) { @@ -909,6 +919,36 @@ curl_setopt($ch, CURLOPT_URL, $server . $port); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); break; + case 'cloudns': + /* Uses ClouDNS REST API + Requires auth-id or sub-auth-id or sub-auth-user */ + // Step 1: Find the Record ID + $url = 'https://api.cloudns.net/dns/records.json'; + $post_data['auth-id'] = $this->_dnsUser; + $post_data['auth-password'] = $this->_dnsPass; + $post_data['domain-name'] = $this->_dnsDomain; + $post_data['host'] = $this->_dnsHost; + $post_data['type'] = 'a'; + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); + $output = json_decode(curl_exec($ch)); + $recordID = key(get_object_vars($output)); + + // Step 2: Set the record + $needsIP = TRUE; + $url = 'https://api.cloudns.net/dns/mod-record.json'; + $post_data = array(); + $post_data['auth-id'] = $this->_dnsUser; + $post_data['auth-password'] = $this->_dnsPass; + $post_data['domain-name'] = $this->_dnsDomain; + $post_data['record-id'] = $recordID; + $post_data['host'] = $this->_dnsHost; + $post_data['record'] = $this->_dnsIP; + $post_data['ttl'] = $this->_dnsTTL; + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); + break; + default: break; } @@ -1768,6 +1808,14 @@ $this->_debug($data); } break; + case 'cloudns': + $result = json_decode($data, true); + if ($result['status'] == 'Success') { + $successful_update = true; + } else { + log_error($result['status'] . "(" . $result['statusDescription'] . ")"); + } + break; case 'dreamhost': case 'dreamhost-v6': $result = json_decode($data,true); diff --git a/src/etc/inc/globals.inc b/src/etc/inc/globals.inc index 1e2cbdf6b6..59b3e83cd9 100644 --- a/src/etc/inc/globals.inc +++ b/src/etc/inc/globals.inc @@ -205,5 +205,5 @@ $factory_default_checkipservice = array( "descr" => 'Default Check IP Service' ); -$dyndns_split_domain_types = array("namecheap", "cloudflare", "cloudflare-v6", "gratisdns"); +$dyndns_split_domain_types = array("namecheap", "cloudflare", "cloudflare-v6", "gratisdns", "cloudns"); ?> diff --git a/src/etc/inc/services.inc b/src/etc/inc/services.inc index 79a12db4d7..07d6cac9e3 100644 --- a/src/etc/inc/services.inc +++ b/src/etc/inc/services.inc @@ -23,8 +23,8 @@ * limitations under the License. */ -define('DYNDNS_PROVIDER_VALUES', 'all-inkl citynetwork cloudflare cloudflare-v6 custom custom-v6 dnsexit dnsimple dnsmadeeasy dnsomatic dreamhost dreamhost-v6 duiadns duiadns-v6 dyndns dyndns-custom dyndns-static dyns easydns eurodns freedns freedns-v6 glesys googledomains gratisdns he-net he-net-v6 he-net-tunnelbroker hover loopia namecheap noip noip-free ods opendns ovh-dynhost route53 selfhost spdyn spdyn-v6 zoneedit'); -define('DYNDNS_PROVIDER_DESCRIPTIONS', 'All-Inkl.com,City Network,CloudFlare,CloudFlare (v6),Custom,Custom (v6),DNSexit,DNSimple,DNS Made Easy,DNS-O-Matic,DreamHost,Dreamhost (v6),DuiaDns.net,DuiaDns.net (v6),DynDNS (dynamic),DynDNS (custom),DynDNS (static),DyNS,easyDNS,Euro Dns,freeDNS,freeDNS (v6),GleSYS,Google Domains,GratisDNS,HE.net,HE.net (v6),HE.net Tunnelbroker,Hover,Loopia,Namecheap,No-IP,No-IP (free),ODS.org,OpenDNS,OVH DynHOST,Route 53,SelfHost,SPDYN,SPDYN (v6),ZoneEdit'); +define('DYNDNS_PROVIDER_VALUES', 'all-inkl citynetwork cloudflare cloudflare-v6 cloudns custom custom-v6 dnsexit dnsimple dnsmadeeasy dnsomatic dreamhost dreamhost-v6 duiadns duiadns-v6 dyndns dyndns-custom dyndns-static dyns easydns eurodns freedns freedns-v6 glesys googledomains gratisdns he-net he-net-v6 he-net-tunnelbroker hover loopia namecheap noip noip-free ods opendns ovh-dynhost route53 selfhost spdyn spdyn-v6 zoneedit'); +define('DYNDNS_PROVIDER_DESCRIPTIONS', 'All-Inkl.com,City Network,CloudFlare,CloudFlare (v6),ClouDNS,Custom,Custom (v6),DNSexit,DNSimple,DNS Made Easy,DNS-O-Matic,DreamHost,Dreamhost (v6),DuiaDns.net,DuiaDns.net (v6),DynDNS (dynamic),DynDNS (custom),DynDNS (static),DyNS,easyDNS,Euro Dns,freeDNS,freeDNS (v6),GleSYS,Google Domains,GratisDNS,HE.net,HE.net (v6),HE.net Tunnelbroker,Hover,Loopia,Namecheap,No-IP,No-IP (free),ODS.org,OpenDNS,OVH DynHOST,Route 53,SelfHost,SPDYN,SPDYN (v6),ZoneEdit'); /* implement ipv6 route advertising daemon */ function services_radvd_configure($blacklist = array()) { diff --git a/src/usr/local/share/locale/pot/pfSense.pot b/src/usr/local/share/locale/pot/pfSense.pot index f0c10aaa4c..5a7c72bff1 100644 --- a/src/usr/local/share/locale/pot/pfSense.pot +++ b/src/usr/local/share/locale/pot/pfSense.pot @@ -22273,8 +22273,8 @@ msgid "" "Enter the complete fully qualified domain name. Example: myhost.dyndns.org" "%1$sDNS Made Easy: Dynamic DNS ID (NOT hostname)%1$she.net tunnelbroker: " "Enter the tunnel ID.%1$sGleSYS: Enter the record ID.%1$sDNSimple: Enter only " -"the domain name.%1$sNamecheap, Cloudflare, GratisDNS, Hover: Enter the " -"hostname and the domain separately, with the domain being the domain or " +"the domain name.%1$sNamecheap, Cloudflare, GratisDNS, Hover, ClouDNS: Enter " +"the hostname and the domain separately, with the domain being the domain or " "subdomain zone being handled by the provider." msgstr "" diff --git a/src/usr/local/www/services_dyndns_edit.php b/src/usr/local/www/services_dyndns_edit.php index afe274cdb6..2d26176f8d 100644 --- a/src/usr/local/www/services_dyndns_edit.php +++ b/src/usr/local/www/services_dyndns_edit.php @@ -299,7 +299,7 @@ $group->setHelp('Enter the complete fully qualified domain name. Example: myhost 'he.net tunnelbroker: Enter the tunnel ID.%1$s' . 'GleSYS: Enter the record ID.%1$s' . 'DNSimple: Enter only the domain name.%1$s' . - 'Namecheap, Cloudflare, GratisDNS, Hover: Enter the hostname and the domain separately, with the domain being the domain or subdomain zone being handled by the provider.', '
'); + 'Namecheap, Cloudflare, GratisDNS, Hover, ClouDNS: Enter the hostname and the domain separately, with the domain being the domain or subdomain zone being handled by the provider.', '
'); $section->add($group); @@ -487,6 +487,20 @@ events.push(function() { hideInput('zoneid', true); hideInput('ttl', true); break; + case "cloudns": + hideGroupInput('domainname', false); + hideInput('resultmatch', true); + hideInput('updateurl', true); + hideInput('requestif', true); + hideCheckbox('curl_ipresolve_v4', true); + hideCheckbox('curl_ssl_verifypeer', true); + hideInput('host', false); + hideInput('mx', false); + hideCheckbox('wildcard', false); + hideCheckbox('proxied', true); + hideInput('zoneid', true); + hideInput('ttl', false); + break; case 'dreamhost': case 'dreamhost-v6': hideGroupInput('domainname', true);