From 916d683eb92fd9c12a03d6bbf595015a392fb64e Mon Sep 17 00:00:00 2001 From: surrural Date: Mon, 9 Feb 2015 14:03:15 -0500 Subject: [PATCH 1/5] Add support for DNSimple (dnsimple.com) --- etc/inc/dyndns.class | 63 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 10 deletions(-) diff --git a/etc/inc/dyndns.class b/etc/inc/dyndns.class index 2c6f944d0e..53e340c1e1 100644 --- a/etc/inc/dyndns.class +++ b/etc/inc/dyndns.class @@ -30,7 +30,8 @@ * - Eurodns (eurodns.com) * - GratisDNS (gratisdns.dk) * - City Network (citynetwork.se) - * - GleSYS (glesys.com) + * - GleSYS (glesys.com + * - DNSimple (dnsimple.com) * +----------------------------------------------------+ * Requirements: * - PHP version 4.0.2 or higher with the CURL Library and the PCRE Library @@ -67,13 +68,14 @@ * HE.net Tunnel - Last Tested: 28 June 2011 * 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 - * Eurodns - Last Tested: 27 June 2013 - * GratisDNS - Last Tested: 15 August 2012 - * OVH DynHOST - Last Tested: NEVER - * City Network - Last Tested: 13 November 2013 - * GleSYS - Last Tested: 3 February 2015 + * DNS-O-Matic - Last Tested: 9 September 2010 + * CloudFlare - Last Tested: 30 May 2013 + * Eurodns - Last Tested: 27 June 2013 + * GratisDNS - Last Tested: 15 August 2012 + * OVH DynHOST - Last Tested: NEVER + * City Network - Last Tested: 13 November 2013 + * GleSYS - Last Tested: 3 February 2015 + * DNSimple - Last Tested: 09 February 2015 * +====================================================+ * * @author E.Kristensen @@ -243,7 +245,8 @@ case 'eurodns': case 'gratisdns': case 'ovh-dynhost': - case 'citynetwork': + case 'citynetwork': + case 'dnsimple': $this->_update(); if($this->_dnsDummyUpdateDone == true) { // If a dummy update was needed, then sleep a while and do the update again to put the proper address back. @@ -670,6 +673,21 @@ $port = ":" . $this->_dnsPort; curl_setopt($ch, CURLOPT_URL, $server .$port . '?hostname=' . $this->_dnsHost . '&myip=' . $this->_dnsIP); break; + case 'dnsimple': + /* Uses DNSimple's REST API + Requires username and Account API token passed in header + Piggybacks on Route 53's ZoneID field for DNSimple record ID + Data sent as JSON */ + $needsIP = TRUE; + $server = 'https://api.dnsimple.com/v1/domains/'; + $token = $this->_dnsUser . ':' . $this->_dnsPass; + $jsondata = '{"record":{"content":"' . $this->_dnsIP . '","ttl":"' . $this->_dnsTTL . '"}}'; + curl_setopt($ch, CURLOPT_HEADER, 1); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json','Content-Type: application/json','X-DNSimple-Token: ' . $token)); + curl_setopt($ch, CURLOPT_URL, $server . $this->_dnsHost . '/records/' . $this->_dnsZoneID); + curl_setopt($ch, CURLOPT_POSTFIELDS, $jsondata); + break; default: break; } @@ -1191,8 +1209,33 @@ $this->_debug($data); } break; + case 'dnsimple': + /* Responds with HTTP 200 on success. + Responds with HTTP 4xx on error. + Returns JSON data as body */ + $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); + $header = substr($data, 0, $header_size); + $body = substr($data, $header_size); + if (preg_match("/Status: 200\s/i", $header)) { + $status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Updated Successfully!"; + $successful_update = true; + } else if (preg_match("/Status: 4\d\d\s/i", $header)) { + $arrbody = json_decode($body, true); + $message = $arrbody['message'] . "."; + if (isset($arrbody['errors']['content'])) { + foreach($arrbody['errors']['content'] as $key => $content) { + $message .= " " . $content . "."; + } + } + $status = "phpDynDNS ({$this->_dnsHost}): (Error) " . $message; + } else { + $status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)"; + log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$body}"); + $this->_debug($body); + } + break; } - + if($successful_update == true) { /* Write WAN IP to cache file */ $wan_ip = $this->_checkIP(); From e29543d68692ad669faa4646abf8580301157768 Mon Sep 17 00:00:00 2001 From: surrural Date: Mon, 9 Feb 2015 14:05:06 -0500 Subject: [PATCH 2/5] Add support for DNSimple (dnsimple.com) --- etc/inc/services.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/inc/services.inc b/etc/inc/services.inc index 42341033e6..cac21c46c6 100644 --- a/etc/inc/services.inc +++ b/etc/inc/services.inc @@ -38,8 +38,8 @@ pfSense_MODULE: utils */ -define('DYNDNS_PROVIDER_VALUES', 'citynetwork cloudflare custom custom-v6 dhs dnsexit dnsomatic dyndns dyndns-custom dyndns-static dyns easydns eurodns freedns glesys gratisdns he-net he-net-v6 he-net-tunnelbroker loopia namecheap noip noip-free ods opendns ovh-dynhost route53 selfhost zoneedit'); -define('DYNDNS_PROVIDER_DESCRIPTIONS', 'City Network,CloudFlare,Custom,Custom (v6),DHS,DNSexit,DNS-O-Matic,DynDNS (dynamic),DynDNS (custom),DynDNS (static),DyNS,easyDNS,Euro Dns,freeDNS,GleSYS,GratisDNS,HE.net,HE.net (v6),HE.net Tunnelbroker,Loopia,Namecheap,No-IP,No-IP (free),ODS.org,OpenDNS,OVH DynHOST,Route 53,SelfHost,ZoneEdit'); +define('DYNDNS_PROVIDER_VALUES', 'citynetwork cloudflare custom custom-v6 dhs dnsexit dnsimple dnsomatic dyndns dyndns-custom dyndns-static dyns easydns eurodns freedns glesys gratisdns he-net he-net-v6 he-net-tunnelbroker loopia namecheap noip noip-free ods opendns ovh-dynhost route53 selfhost zoneedit'); +define('DYNDNS_PROVIDER_DESCRIPTIONS', 'City Network,CloudFlare,Custom,Custom (v6),DHS,DNSexit,DNSimple,DNS-O-Matic,DynDNS (dynamic),DynDNS (custom),DynDNS (static),DyNS,easyDNS,Euro Dns,freeDNS,GleSYS,GratisDNS,HE.net,HE.net (v6),HE.net Tunnelbroker,Loopia,Namecheap,No-IP,No-IP (free),ODS.org,OpenDNS,OVH DynHOST,Route 53,SelfHost,ZoneEdit'); /* implement ipv6 route advertising daemon */ function services_radvd_configure($blacklist = array()) { From a39b78b50675e3809253ce6dd6937d1089ddbf0a Mon Sep 17 00:00:00 2001 From: surrural Date: Mon, 9 Feb 2015 14:09:21 -0500 Subject: [PATCH 3/5] Add support for DNSimple (dnsimple.com) --- usr/local/www/services_dyndns_edit.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/usr/local/www/services_dyndns_edit.php b/usr/local/www/services_dyndns_edit.php index 0cf95f1df2..80d1743f51 100644 --- a/usr/local/www/services_dyndns_edit.php +++ b/usr/local/www/services_dyndns_edit.php @@ -205,6 +205,7 @@ function _onTypeChange(type){ document.getElementById("r53_zoneid").style.display='none'; document.getElementById("r53_ttl").style.display='none'; break; + case "dnsimple": case "route53": document.getElementById("_resulttr").style.display = 'none'; document.getElementById("_urltr").style.display = 'none'; @@ -320,7 +321,8 @@ function _onTypeChange(type){

- +
+ @@ -373,6 +375,7 @@ function _onTypeChange(type){

+
@@ -381,6 +384,7 @@ function _onTypeChange(type){
+
From c19250a5b382546ccf9eb55e2827673a4dbba7ac Mon Sep 17 00:00:00 2001 From: surrural Date: Mon, 9 Feb 2015 14:14:00 -0500 Subject: [PATCH 4/5] Update dyndns.class --- etc/inc/dyndns.class | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/inc/dyndns.class b/etc/inc/dyndns.class index 53e340c1e1..2430d67cb5 100644 --- a/etc/inc/dyndns.class +++ b/etc/inc/dyndns.class @@ -30,7 +30,7 @@ * - Eurodns (eurodns.com) * - GratisDNS (gratisdns.dk) * - City Network (citynetwork.se) - * - GleSYS (glesys.com + * - GleSYS (glesys.com) * - DNSimple (dnsimple.com) * +----------------------------------------------------+ * Requirements: From e0a4147b3b5eda4d0d859d0c81ee127677d746a0 Mon Sep 17 00:00:00 2001 From: surrural Date: Mon, 9 Feb 2015 14:17:03 -0500 Subject: [PATCH 5/5] Add support for DNSimple (dnsimple.com) --- etc/inc/dyndns.class | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/inc/dyndns.class b/etc/inc/dyndns.class index 2430d67cb5..9f54403bc3 100644 --- a/etc/inc/dyndns.class +++ b/etc/inc/dyndns.class @@ -30,7 +30,7 @@ * - Eurodns (eurodns.com) * - GratisDNS (gratisdns.dk) * - City Network (citynetwork.se) - * - GleSYS (glesys.com) + * - GleSYS (glesys.com) * - DNSimple (dnsimple.com) * +----------------------------------------------------+ * Requirements: