Add Gandi LiveDNS DynDNS client.

This commit is contained in:
Eric Vantillard 2019-06-03 18:54:13 +02:00
parent 69a2f6ccb8
commit edfe22f8ba
3 changed files with 84 additions and 5 deletions

View File

@ -49,6 +49,7 @@
* - Cloudflare (www.cloudflare.com)
* - Cloudflare IPv6 (www.cloudflare.com)
* - Eurodns (eurodns.com)
* - Gandi LiveDNS (www.gandi.net)
* - GratisDNS (gratisdns.dk)
* - City Network (citynetwork.se)
* - GleSYS (glesys.com)
@ -126,6 +127,7 @@
* GoDaddy IPv6 - Last Tested: 22 November 2017
* DigitalOcean - Not Yet Tested
* Azure DNS - Last Tested: 08 March 2018
* Gandi LiveDNS - Not Yet Tested
* +====================================================+
*
* @author E.Kristensen
@ -261,6 +263,12 @@
if (!$dnsZoneID) $this->_error(8);
if (!$dnsTTL) $this->_error(9);
break;
case 'gandi-livedns': // NOTE: same as digitalocean
if (!$dnsPass) $this->_error(4);//API key
if (!$dnsHost) $this->_error(5); //DNS Record to update
if (!$dnsDomain) $this->_error(5);//domain
if (!$dnsTTL) $this->_error(9);//ttl
break;
case 'custom':
case 'custom-v6':
if (!$dnsUpdateURL) $this->_error(7);
@ -379,6 +387,7 @@
case 'azurev6':
case 'linode':
case 'linode-v6':
case 'gandi-livedns':
$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.
@ -1212,6 +1221,43 @@
curl_setopt($ch, CURLOPT_URL, "{$linode_api}/domains/{$domain_id}/records");
}
break;
case 'gandi-livedns':
// NOTE: quite similar to digitalocean case but with json content like azure case
// Get record href
$server = 'https://dns.api.gandi.net/api/v5/domains/';
$url = $server . $this->_dnsDomain . '/records';
curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Api-Key: {$this->_dnsPass}"));
curl_setopt($ch, CURLOPT_URL, $url);
$output = json_decode(curl_exec($ch));
if (!is_array($output)) {
$output = array();
}
foreach($output as $dnsRecord) {
// NS records are named @ in DO's API, so check type as well
if ($this->_dnsHost == $dnsRecord->rrset_name && $dnsRecord->rrset_type == 'A') {
$recordHref = $dnsRecord->rrset_href;
break;
}
}
$request_headers = array();
//$request_headers[] = 'Accept: application/json';
$request_headers[] = 'X-Api-Key: ' .$this->_dnsPass;
$request_headers[] = 'Content-Type: application/json';
//create or update record
if ($recordHref == null) {
//create record
$url = $server . $this->_dnsDomain . '/records';
$body = '{"rrset_type": "A", "rrset_ttl": ' . $this->_dnsTTL . ', "rrset_name": "' . $this->_dnsHost . '", "rrset_values": ["' . $this->_dnsIP . '"]}';
} else {
//update record
$url = $recordHref;
$body = '{"rrset_ttl": ' . $this->_dnsTTL . ', "rrset_values": ["' . $this->_dnsIP . '"]}';
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
}
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $request_headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
break;
default:
break;
@ -2217,6 +2263,24 @@
( isset($domains_result["errors"][0]["reason"]) ? $domains_result["errors"][0]["reason"] : "HTTP {$http_code}" );
}
break;
case 'gandi-livedns':
// NOTE: same as azure
// Creating new records returns an HTTP 201, updating existing records get 200
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($http_code == 401) {
$status = $status_intro . $error_str . gettext("User Authorization Failed");
} else if ($http_code == 201) {
$status = $status_intro . $success_str . gettext("IP Address Changed Successfully!");
$successful_update = true;
} else if ($http_code == 200) {
$status = $status_intro . $success_str . gettext("IP Address Changed Successfully!");
$successful_update = true;
} else {
$status = $status_intro . "(" . gettext("Unknown Response") . ")";
log_error($status_intro . gettext("PAYLOAD:") . " " . $http_code);
$this->_debug($data);
}
break;
default:
break;
}

View File

@ -24,8 +24,8 @@
*/
define('DYNDNS_PROVIDER_VALUES', 'all-inkl azure azurev6 citynetwork cloudflare cloudflare-v6 cloudns custom custom-v6 digitalocean digitalocean-v6 dnsexit dnsimple dnsmadeeasy dnsomatic dreamhost dreamhost-v6 duiadns duiadns-v6 dyndns dyndns-custom dyndns-static dyns easydns eurodns freedns freedns-v6 glesys godaddy godaddy-v6 googledomains gratisdns he-net he-net-v6 he-net-tunnelbroker hover linode linode-v6 loopia namecheap noip noip-free ods opendns ovh-dynhost route53 route53-v6 selfhost spdyn spdyn-v6 zoneedit');
define('DYNDNS_PROVIDER_DESCRIPTIONS', 'All-Inkl.com,Azure DNS,Azure DNS (v6),City Network,Cloudflare,Cloudflare (v6),ClouDNS,Custom,Custom (v6),DigitalOcean,DigitalOcean (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,GoDaddy,GoDaddy (v6),Google Domains,GratisDNS,HE.net,HE.net (v6),HE.net Tunnelbroker,Hover,Linode,Linode (v6),Loopia,Namecheap,No-IP,No-IP (free),ODS.org,OpenDNS,OVH DynHOST,Route 53,Route 53 (v6),SelfHost,SPDYN,SPDYN (v6),ZoneEdit');
define('DYNDNS_PROVIDER_VALUES', 'all-inkl azure azurev6 citynetwork cloudflare cloudflare-v6 cloudns custom custom-v6 digitalocean digitalocean-v6 dnsexit dnsimple dnsmadeeasy dnsomatic dreamhost dreamhost-v6 duiadns duiadns-v6 dyndns dyndns-custom dyndns-static dyns easydns eurodns freedns freedns-v6 glesys gandi-livedns godaddy godaddy-v6 googledomains gratisdns he-net he-net-v6 he-net-tunnelbroker hover linode linode-v6 loopia namecheap noip noip-free ods opendns ovh-dynhost route53 route53-v6 selfhost spdyn spdyn-v6 zoneedit');
define('DYNDNS_PROVIDER_DESCRIPTIONS', 'All-Inkl.com,Azure DNS,Azure DNS (v6),City Network,Cloudflare,Cloudflare (v6),ClouDNS,Custom,Custom (v6),DigitalOcean,DigitalOcean (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,Gandi Live DNS,GoDaddy,GoDaddy (v6),Google Domains,GratisDNS,HE.net,HE.net (v6),HE.net Tunnelbroker,Hover,Linode,Linode (v6),Loopia,Namecheap,No-IP,No-IP (free),ODS.org,OpenDNS,OVH DynHOST,Route 53,Route 53 (v6),SelfHost,SPDYN,SPDYN (v6),ZoneEdit');
/* implement ipv6 route advertising daemon */
function services_radvd_configure($blacklist = array()) {

View File

@ -73,8 +73,7 @@ if ($_POST['save'] || $_POST['force']) {
unset($input_errors);
$pconfig = $_POST;
if (($pconfig['type'] == "freedns" || $pconfig['type'] == "freedns-v6" || $pconfig['type'] == "namecheap" || $pconfig['type'] == "digitalocean" || $pconfig['type'] == "digitalocean-v6") ||
($pconfig['type'] == "linode" || $pconfig['type'] == "linode-v6")
if (($pconfig['type'] == "freedns" || $pconfig['type'] == "freedns-v6" || $pconfig['type'] == "namecheap" || $pconfig['type'] == "digitalocean" || $pconfig['type'] == "digitalocean-v6" || $pconfig['type'] == "linode" || $pconfig['type'] == "linode-v6" || $pconfig['type'] == "gandi-livedns")
&& $_POST['username'] == "") {
$_POST['username'] = "none";
}
@ -117,7 +116,7 @@ if ($_POST['save'] || $_POST['force']) {
$allow_wildcard = true;
} elseif ((($pconfig['type'] == "godaddy") || ($pconfig['type'] == "godaddy-v6")) && ($_POST['host'] == '@.' || $_POST['host'] == '@')) {
$host_to_check = $_POST['domainname'];
} elseif ((($pconfig['type'] == "digitalocean") || ($pconfig['type'] == "digitalocean-v6")) && ($_POST['host'] == '@.' || $_POST['host'] == '@')) {
} elseif (($pconfig['type'] == "digitalocean" || $pconfig['type'] == "digitalocean-v6" || $pconfig['type'] == "gandi-livedns") && ($_POST['host'] == '@.' || $_POST['host'] == '@')) {
$host_to_check = $_POST['domainname'];
} elseif (($pconfig['type'] == "linode") || ($pconfig['type'] == "linode-v6")) {
$host_to_check = $_POST['host'] == '@' ? $_POST['domainname'] : ( $_POST['host'] . '.' . $_POST['domainname'] );
@ -389,6 +388,7 @@ $section->addPassword(new Form_Input(
'Route 53: Enter the Secret Access Key.%1$s' .
'GleSYS: Enter the API key.%1$s' .
'Dreamhost: Enter the API Key.%1$s' .
'Gandi LiveDNS: Enter API token%1$s' .
'GoDaddy: Enter the API secret.%1$s' .
'DNSimple: Enter the API token.%1$s' .
'Linode: Enter the Personal Access Token.%1$s' .
@ -629,6 +629,21 @@ events.push(function() {
hideInput('zoneid', true);
hideInput('ttl', false);
break;
case "gandi-livedns": // NOTE: same as digitalocean
hideGroupInput('domainname', false);
hideInput('resultmatch', true);
hideInput('updateurl', true);
hideInput('requestif', true);
hideCheckbox('curl_ipresolve_v4', true);
hideCheckbox('curl_ssl_verifypeer', true);
hideInput('username', true);
hideInput('host', false);
hideInput('mx', true);
hideCheckbox('wildcard', true);
hideCheckbox('proxied', true);
hideInput('zoneid', true);
hideInput('ttl', false);
break;
default:
hideGroupInput('domainname', true);
hideInput('resultmatch', true);