Revision 6df12a8e
Added by Eric VANTILLARD over 5 years ago
src/etc/inc/dyndns.class | ||
---|---|---|
49 | 49 |
* - Cloudflare (www.cloudflare.com) |
50 | 50 |
* - Cloudflare IPv6 (www.cloudflare.com) |
51 | 51 |
* - Eurodns (eurodns.com) |
52 |
* - Gandi LiveDNS (www.gandi.net) |
|
52 | 53 |
* - GratisDNS (gratisdns.dk) |
53 | 54 |
* - City Network (citynetwork.se) |
54 | 55 |
* - GleSYS (glesys.com) |
... | ... | |
126 | 127 |
* GoDaddy IPv6 - Last Tested: 22 November 2017 |
127 | 128 |
* DigitalOcean - Not Yet Tested |
128 | 129 |
* Azure DNS - Last Tested: 08 March 2018 |
130 |
* Gandi LiveDNS - Not Yet Tested |
|
129 | 131 |
* +====================================================+ |
130 | 132 |
* |
131 | 133 |
* @author E.Kristensen |
... | ... | |
261 | 263 |
if (!$dnsZoneID) $this->_error(8); |
262 | 264 |
if (!$dnsTTL) $this->_error(9); |
263 | 265 |
break; |
266 |
case 'gandi-livedns': // NOTE: same as digitalocean |
|
267 |
if (!$dnsPass) $this->_error(4);//API key |
|
268 |
if (!$dnsHost) $this->_error(5); //DNS Record to update |
|
269 |
if (!$dnsDomain) $this->_error(5);//domain |
|
270 |
if (!$dnsTTL) $this->_error(9);//ttl |
|
271 |
break; |
|
264 | 272 |
case 'custom': |
265 | 273 |
case 'custom-v6': |
266 | 274 |
if (!$dnsUpdateURL) $this->_error(7); |
... | ... | |
379 | 387 |
case 'azurev6': |
380 | 388 |
case 'linode': |
381 | 389 |
case 'linode-v6': |
390 |
case 'gandi-livedns': |
|
382 | 391 |
$this->_update(); |
383 | 392 |
if ($this->_dnsDummyUpdateDone == true) { |
384 | 393 |
// If a dummy update was needed, then sleep a while and do the update again to put the proper address back. |
... | ... | |
1216 | 1225 |
curl_setopt($ch, CURLOPT_URL, "{$linode_api}/domains/{$domain_id}/records"); |
1217 | 1226 |
} |
1218 | 1227 |
|
1228 |
break; |
|
1229 |
case 'gandi-livedns': |
|
1230 |
// NOTE: quite similar to digitalocean case but with json content like azure case |
|
1231 |
// Get record href |
|
1232 |
$server = 'https://dns.api.gandi.net/api/v5/domains/'; |
|
1233 |
$url = $server . $this->_dnsDomain . '/records'; |
|
1234 |
curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Api-Key: {$this->_dnsPass}")); |
|
1235 |
curl_setopt($ch, CURLOPT_URL, $url); |
|
1236 |
$output = json_decode(curl_exec($ch)); |
|
1237 |
if (!is_array($output)) { |
|
1238 |
$output = array(); |
|
1239 |
} |
|
1240 |
foreach($output as $dnsRecord) { |
|
1241 |
// NS records are named @ in DO's API, so check type as well |
|
1242 |
if ($this->_dnsHost == $dnsRecord->rrset_name && $dnsRecord->rrset_type == 'A') { |
|
1243 |
$recordHref = $dnsRecord->rrset_href; |
|
1244 |
break; |
|
1245 |
} |
|
1246 |
} |
|
1247 |
$request_headers = array(); |
|
1248 |
//$request_headers[] = 'Accept: application/json'; |
|
1249 |
$request_headers[] = 'X-Api-Key: ' .$this->_dnsPass; |
|
1250 |
$request_headers[] = 'Content-Type: application/json'; |
|
1251 |
//create or update record |
|
1252 |
if ($recordHref == null) { |
|
1253 |
//create record |
|
1254 |
$url = $server . $this->_dnsDomain . '/records'; |
|
1255 |
$body = '{"rrset_type": "A", "rrset_ttl": ' . $this->_dnsTTL . ', "rrset_name": "' . $this->_dnsHost . '", "rrset_values": ["' . $this->_dnsIP . '"]}'; |
|
1256 |
} else { |
|
1257 |
//update record |
|
1258 |
$url = $recordHref; |
|
1259 |
$body = '{"rrset_ttl": ' . $this->_dnsTTL . ', "rrset_values": ["' . $this->_dnsIP . '"]}'; |
|
1260 |
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); |
|
1261 |
} |
|
1262 |
curl_setopt($ch, CURLOPT_URL, $url); |
|
1263 |
curl_setopt($ch, CURLOPT_HTTPHEADER, $request_headers); |
|
1264 |
curl_setopt($ch, CURLOPT_POSTFIELDS, $body); |
|
1219 | 1265 |
break; |
1220 | 1266 |
default: |
1221 | 1267 |
break; |
... | ... | |
2223 | 2269 |
( isset($domains_result["errors"][0]["reason"]) ? $domains_result["errors"][0]["reason"] : "HTTP {$http_code}" ); |
2224 | 2270 |
} |
2225 | 2271 |
break; |
2272 |
case 'gandi-livedns': |
|
2273 |
// NOTE: same as azure |
|
2274 |
// Creating new records returns an HTTP 201, updating existing records get 200 |
|
2275 |
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
2276 |
if ($http_code == 401) { |
|
2277 |
$status = $status_intro . $error_str . gettext("User Authorization Failed"); |
|
2278 |
} else if ($http_code == 201) { |
|
2279 |
$status = $status_intro . $success_str . gettext("IP Address Changed Successfully!"); |
|
2280 |
$successful_update = true; |
|
2281 |
} else if ($http_code == 200) { |
|
2282 |
$status = $status_intro . $success_str . gettext("IP Address Changed Successfully!"); |
|
2283 |
$successful_update = true; |
|
2284 |
} else { |
|
2285 |
$status = $status_intro . "(" . gettext("Unknown Response") . ")"; |
|
2286 |
log_error($status_intro . gettext("PAYLOAD:") . " " . $http_code); |
|
2287 |
$this->_debug($data); |
|
2288 |
} |
|
2289 |
break; |
|
2226 | 2290 |
default: |
2227 | 2291 |
break; |
2228 | 2292 |
} |
src/etc/inc/services.inc | ||
---|---|---|
24 | 24 |
*/ |
25 | 25 |
|
26 | 26 |
|
27 |
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'); |
|
28 |
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'); |
|
27 |
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');
|
|
28 |
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');
|
|
29 | 29 |
|
30 | 30 |
/* implement ipv6 route advertising daemon */ |
31 | 31 |
function services_radvd_configure($blacklist = array()) { |
src/usr/local/www/services_dyndns_edit.php | ||
---|---|---|
73 | 73 |
unset($input_errors); |
74 | 74 |
$pconfig = $_POST; |
75 | 75 |
|
76 |
if (($pconfig['type'] == "freedns" || $pconfig['type'] == "freedns-v6" || $pconfig['type'] == "namecheap" || $pconfig['type'] == "digitalocean" || $pconfig['type'] == "digitalocean-v6") || |
|
77 |
($pconfig['type'] == "linode" || $pconfig['type'] == "linode-v6") |
|
76 |
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") |
|
78 | 77 |
&& $_POST['username'] == "") { |
79 | 78 |
$_POST['username'] = "none"; |
80 | 79 |
} |
... | ... | |
119 | 118 |
$allow_wildcard = true; |
120 | 119 |
} elseif ((($pconfig['type'] == "godaddy") || ($pconfig['type'] == "godaddy-v6")) && ($_POST['host'] == '@.' || $_POST['host'] == '@')) { |
121 | 120 |
$host_to_check = $_POST['domainname']; |
122 |
} elseif ((($pconfig['type'] == "digitalocean") || ($pconfig['type'] == "digitalocean-v6")) && ($_POST['host'] == '@.' || $_POST['host'] == '@')) {
|
|
121 |
} elseif (($pconfig['type'] == "digitalocean" || $pconfig['type'] == "digitalocean-v6" || $pconfig['type'] == "gandi-livedns") && ($_POST['host'] == '@.' || $_POST['host'] == '@')) {
|
|
123 | 122 |
$host_to_check = $_POST['domainname']; |
124 | 123 |
} elseif (($pconfig['type'] == "linode") || ($pconfig['type'] == "linode-v6")) { |
125 | 124 |
$host_to_check = $_POST['host'] == '@' ? $_POST['domainname'] : ( $_POST['host'] . '.' . $_POST['domainname'] ); |
... | ... | |
393 | 392 |
'Route 53: Enter the Secret Access Key.%1$s' . |
394 | 393 |
'GleSYS: Enter the API key.%1$s' . |
395 | 394 |
'Dreamhost: Enter the API Key.%1$s' . |
395 |
'Gandi LiveDNS: Enter API token%1$s' . |
|
396 | 396 |
'GoDaddy: Enter the API secret.%1$s' . |
397 | 397 |
'DNSimple: Enter the API token.%1$s' . |
398 | 398 |
'Linode: Enter the Personal Access Token.%1$s' . |
... | ... | |
633 | 633 |
hideInput('zoneid', true); |
634 | 634 |
hideInput('ttl', false); |
635 | 635 |
break; |
636 |
case "gandi-livedns": // NOTE: same as digitalocean |
|
637 |
hideGroupInput('domainname', false); |
|
638 |
hideInput('resultmatch', true); |
|
639 |
hideInput('updateurl', true); |
|
640 |
hideInput('requestif', true); |
|
641 |
hideCheckbox('curl_ipresolve_v4', true); |
|
642 |
hideCheckbox('curl_ssl_verifypeer', true); |
|
643 |
hideInput('username', true); |
|
644 |
hideInput('host', false); |
|
645 |
hideInput('mx', true); |
|
646 |
hideCheckbox('wildcard', true); |
|
647 |
hideCheckbox('proxied', true); |
|
648 |
hideInput('zoneid', true); |
|
649 |
hideInput('ttl', false); |
|
650 |
break; |
|
636 | 651 |
default: |
637 | 652 |
hideGroupInput('domainname', true); |
638 | 653 |
hideInput('resultmatch', true); |
Also available in: Unified diff
Add Gandi LiveDNS DynDNS client.
(cherry picked from commit edfe22f8bae894eb678f3e7060cc91cea6f664da)