Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 69 additions & 21 deletions src/etc/inc/dyndns.class
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
* - DuiaDNS IPv6 (www.duiadns.net)
* - Hover (www.hover.com)
* - DreamHost DNS (www.dreamhost.com)
* - GoDaddy DNS (www.godaddy.com)
* +----------------------------------------------------+
* Requirements:
* - PHP version 4.0.2 or higher with the CURL Library and the PCRE Library
Expand Down Expand Up @@ -118,6 +119,7 @@
* Hover - Last Tested: 15 February 2017
* DreamHost - Last Tested: 30 April 2017
* DreamHost IPv6 - Not Yet Tested
* GoDaddy - Last Tested: 24 September 2017
* +====================================================+
*
* @author E.Kristensen
Expand Down Expand Up @@ -215,6 +217,7 @@
break;
case "cloudflare-v6":
case "cloudflare":
case "godaddy":
case "gratisdns":
case "hover":
if (!$dnsUser) $this->_error(3);
Expand Down Expand Up @@ -322,6 +325,7 @@
case 'ovh-dynhost':
case 'citynetwork':
case 'dnsimple':
case 'godaddy':
case 'googledomains':
case 'dnsmadeeasy':
case 'spdyn':
Expand Down Expand Up @@ -668,7 +672,7 @@
}
curl_setopt($ch, CURLOPT_URL, $server .$port . '?system=dyndns&hostname=' . $this->_dnsHost . '&myip=' . $this->_dnsIP . '&wildcard='.$this->_dnsWildcard . '&mx=' . $this->_dnsMX . '&backmx=NO');
break;
case 'route53':
case 'route53':
require_once("r53.class");
$r53 = new Route53($this->_dnsUser, $this->_dnsPass);
$apiurl = $r53->getApiUrl($this->_dnsZoneID);
Expand Down Expand Up @@ -909,6 +913,31 @@
curl_setopt($ch, CURLOPT_URL, $server . $port);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
break;
case 'godaddy':
$this->_FQDN = ltrim($this->_FQDN, '@.');
$recordType = "A";
$needsIP = TRUE;
$dnsServer ='api.godaddy.com';
$dnsHost = str_replace(' ', '', $this->_dnsHost);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: sso-key '.$this->_dnsUser.':'.$this->_dnsPass.'',
'Content-Type: application/json'
));

$updateHost = "https://{$dnsServer}/v1/domains/{$this->_dnsDomain}/records/{$recordType}/{$dnsHost}";
$hostData = array(
"data" => "{$this->_dnsIP}",
"type" => "{$recordType}",
"ttl" => 600
);
$data_json = json_encode($hostData);

curl_setopt($ch, CURLOPT_URL, $updateHost);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_json);
break;
default:
break;
}
Expand All @@ -922,40 +951,40 @@
@curl_close($ch);
}
}

/**
* Private Function (added 23 Feb 17)
* Send Removal To Selected Service.
*
*
* Some services do not perform an inplace upgrade. If they do not then the solution
* is to remove the existing record and add a new record.
*
*
* @param unknown $existing_ip If required, an existing IP address for the record.
*/
function _remove($existing_ip = NULL) {
$remove_allowed = false;
if ($this->_dnsVerboseLog) {
log_error(sprintf(gettext('Dynamic DNS %1$s (%2$s): _remove() starting.'), $this->_dnsService, $this->_FQDN));
}

if (strstr($this->_dnsRequestIf, "_vip")) {
$parentif = get_configured_vip_interface($this->_dnsRequestIf);
$realparentif = convert_friendly_interface_to_real_interface_name($parentif);
} else {
$realparentif = $this->_dnsRequestIf;
}

$ch = curl_init();

if ($this->_useIPv6 == false) {
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
}

curl_setopt($ch, CURLOPT_USERAGENT, $this->_UserAgent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_INTERFACE, 'if!' . $realparentif);
curl_setopt($ch, CURLOPT_TIMEOUT, 120); // Completely empirical

switch ($this->_dnsService) {
case 'dreamhost':
case 'dreamhost-v6':
Expand Down Expand Up @@ -992,38 +1021,38 @@
@curl_close($ch);
}
}

/**
* Private Function (added 23 Feb 17)
* Retrieves current DNS records from an external API source.
*
* Some services cannot perform new operations without the caller
* providing existing record information.
*
* Some services cannot perform new operations without the caller
* providing existing record information.
*/
function _lookup_current() {
$lookup_allowed = false;
if ($this->_dnsVerboseLog) {
log_error(sprintf(gettext('Dynamic DNS %1$s (%2$s): _listCurrent() starting.'), $this->_dnsService, $this->_FQDN));
}

if (strstr($this->_dnsRequestIf, "_vip")) {
$parentif = get_configured_vip_interface($this->_dnsRequestIf);
$realparentif = convert_friendly_interface_to_real_interface_name($parentif);
} else {
$realparentif = $this->_dnsRequestIf;
}

$ch = curl_init();

if ($this->_useIPv6 == false) {
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
}

curl_setopt($ch, CURLOPT_USERAGENT, $this->_UserAgent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_INTERFACE, 'if!' . $realparentif);
curl_setopt($ch, CURLOPT_TIMEOUT, 120); // Completely empirical

switch ($this->_dnsService) {
case 'dreamhost':
case 'dreamhost-v6':
Expand Down Expand Up @@ -1058,7 +1087,7 @@
}

/*
* Private Function (added 23 Feb 17)
* Private Function (added 23 Feb 17)
* Retrieve Lookup Status from the provided data and/or header
*/
function _checkLookupStatus($ch, $data, $header) {
Expand All @@ -1085,7 +1114,7 @@
return;
} else {
foreach($result["data"] as $key => $row) {
if($row["record"] == $this->_dnsHost &&
if($row["record"] == $this->_dnsHost &&
(($row["type"] == "A" && !$this->_useIPv6)
|| ($row["type"] == "AAAA" && $this->_useIPv6)
)) {
Expand Down Expand Up @@ -1750,7 +1779,7 @@
$status = $status_intro . $error_str . gettext("Result did not match.");
} else if (preg_match("/\s401\sUnauthorized/i", $header)) {
$status = $status_intro . $error_str . gettext("Invalid username or password");
}
}
else {
$status = $status_intro . "(" . gettext("Unknown Response") . ")";
log_error($status_intro . gettext("PAYLOAD:") . " " . $header.$data);
Expand Down Expand Up @@ -1832,6 +1861,25 @@
default:
break;
}
case 'godaddy':
// Responds with HTTP 200 on success.
if (preg_match("/\s200\sOK/i", $header)) {
$status = $status_intro . $success_str . gettext("IP Address Updated Successfully!");
$successful_update = true;
} else if (preg_match("/\s401\d\d\s/i", $header)) {
$status = $status_intro . $error_str . gettext("User Authorization Failed");
} else if (preg_match("/\s403\d\d\s/i", $header)) {
$status = $status_intro . $error_str . gettext("User Authorization Failed");
} else if (preg_match("/\s404\d\d\s/i", $header)) {
$status = $status_intro . $error_str . gettext("No such zone exists.");
} else if (preg_match("/\s422\d\d\s/i", $header)) {
$status = $status_intro . $error_str . gettext("The specified record is invalid.");
} else {
$status = $status_intro . "(" . gettext("Unknown Response") . ")";
log_error($status_intro . gettext("PAYLOAD:") . " " . $data);
$this->_debug($data);
}
break;
default:
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/etc/inc/globals.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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", "godaddy", "gratisdns");
?>
10 changes: 5 additions & 5 deletions src/etc/inc/services.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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 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 godaddy 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,GoDaddy,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()) {
Expand Down Expand Up @@ -2275,18 +2275,18 @@ function services_unbound_configure($restart_dhcp = true) {
$wanif = get_real_interface("wan", "inet6");
if (platform_booting()) {
for ($i=1; $i <= 10; $i++) {
if (!file_exists("/tmp/{$wanif}_dhcp6_complete")) {
if (!file_exists("/tmp/{$wanif}_dhcp6_complete")) {
log_error(gettext("Unbound start waiting on dhcp6c."));
sleep(1);
} else {
unlink_if_exists("/tmp/{$wanif}_dhcp6_complete");
log_error(gettext("dhcp6 init complete. Continuing"));
break;
}
}
}
}
}

sync_unbound_service();
if (platform_booting()) {
log_error(gettext("sync unbound done."));
Expand Down
14 changes: 14 additions & 0 deletions src/usr/local/www/services_dyndns_edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,20 @@ function setVisible(service) {
hideInput('zoneid', true);
hideInput('ttl', true);
break;
case "godaddy":
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', true);
hideCheckbox('wildcard', true);
hideCheckbox('proxied', true);
hideInput('zoneid', true);
hideInput('ttl', true);
break;
default:
hideGroupInput('domainname', true);
hideInput('resultmatch', true);
Expand Down