Merge pull request #1479 from surrural/master

This commit is contained in:
Renato Botelho 2015-02-24 08:55:59 -03:00
commit b8b3784f24
3 changed files with 60 additions and 13 deletions

View File

@ -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();

View File

@ -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()) {

View File

@ -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){
</span>
<?=gettext("Enter the complete host/domain name. example: myhost.dyndns.org");?><br />
<?=gettext("he.net tunnelbroker: Enter your tunnel ID");?><br />
<?=gettext("GleSYS: Enter your record ID");?>
<?=gettext("GleSYS: Enter your record ID");?><br />
<?= gettext("DNSimple: Enter only the domain name.");?>
</span>
</td>
</tr>
@ -373,6 +375,7 @@ function _onTypeChange(type){
<?=gettext("FreeDNS (freedns.afraid.org): Enter your \"Authentication Token\" provided by FreeDNS.");?>
<br /><?= gettext("Route 53: Enter your Secret Access Key.");?>
<br /><?= gettext("GleSYS: Enter your API key.");?>
<br /><?= gettext("DNSimple: Enter your API token.");?>
</td>
</tr>
@ -381,6 +384,7 @@ function _onTypeChange(type){
<td width="78%" class="vtable">
<input name="zoneid" type="text" class="formfld user" id="zoneid" size="20" value="<?=htmlspecialchars($pconfig['zoneid']);?>" />
<br /><?= gettext("Enter Zone ID that you received when you created your domain in Route 53.");?>
<br /><?= gettext("DNSimple: Enter the Record ID of record to update.");?>
</td>
</tr>
<tr id="_urltr">