diff options
Diffstat (limited to 'src/etc/inc/dyndns.class')
-rw-r--r-- | src/etc/inc/dyndns.class | 65 |
1 files changed, 53 insertions, 12 deletions
diff --git a/src/etc/inc/dyndns.class b/src/etc/inc/dyndns.class index 610afad..1d1641b 100644 --- a/src/etc/inc/dyndns.class +++ b/src/etc/inc/dyndns.class @@ -33,6 +33,8 @@ * - DNSimple (dnsimple.com) * - Google Domains (domains.google.com) * - DNS Made Easy (www.dnsmadeeasy.com) + * - SPDNS (spdns.de) + * - SPDNS IPv6 (spdns.de) * +----------------------------------------------------+ * Requirements: * - PHP version 4.0.2 or higher with the CURL Library and the PCRE Library @@ -79,6 +81,8 @@ * DNSimple - Last Tested: 09 February 2015 * Google Domains - Last Tested: 27 April 2015 * DNS Made Easy - Last Tested: 27 April 2015 + * SPDNS - Last Tested: 04 December 2015 + * SPDNS IPv6 - Last Tested: 04 December 2015 * +====================================================+ * * @author E.Kristensen @@ -179,6 +183,7 @@ switch ($dnsService) { case 'he-net-v6': case 'custom-v6': + case 'spdns-v6': $this->_useIPv6 = true; break; default: @@ -254,6 +259,8 @@ case 'dnsimple': case 'googledomains': case 'dnsmadeeasy': + case 'spdns': + case 'spdns-v6': $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. @@ -293,7 +300,7 @@ $ch = curl_init(); if ($this->_useIPv6 == false) { - curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 ); + curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); } if ($this->_dnsService != 'ods' and $this->_dnsService != 'route53 ') { @@ -684,7 +691,7 @@ case 'cloudflare': $needsIP = TRUE; $dnsServer ='api.cloudflare.com'; - $dnsHost = str_replace(' ','', $this->_dnsHost); + $dnsHost = str_replace(' ', '', $this->_dnsHost); $host_names = explode(".", $dnsHost); $bottom_host_name = $host_names[count($host_names)-2] . "." . $host_names[count($host_names)-1]; @@ -700,12 +707,12 @@ curl_setopt($ch, CURLOPT_URL, $getZoneId); $output = json_decode(curl_exec($ch)); $zone = $output->result[0]->id; - if ($zone){ // If zone ID was found get host ID + if ($zone) { // If zone ID was found get host ID $getHostId = "https://{$dnsServer}/client/v4/zones/{$zone}/dns_records?name={$this->_dnsHost}"; curl_setopt($ch, CURLOPT_URL, $getHostId); $output = json_decode(curl_exec($ch)); $host = $output->result[0]->id; - if ($host){ // If host ID was found update host + if ($host) { // If host ID was found update host $hostData = array( "content" => "{$this->_dnsIP}", "type" => "A", @@ -717,7 +724,7 @@ $updateHostId = "https://{$dnsServer}/client/v4/zones/{$zone}/dns_records/{$host}"; curl_setopt($ch, CURLOPT_URL, $updateHostId); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); - curl_setopt($ch, CURLOPT_POSTFIELDS,$data_json); + curl_setopt($ch, CURLOPT_POSTFIELDS, $data_json); } } break; @@ -821,6 +828,23 @@ $server = "https://cp.dnsmadeeasy.com/servlet/updateip"; curl_setopt($ch, CURLOPT_URL, $server . '?username=' . $this->_dnsUser . '&password=' . $this->_dnsPass . '&id=' . $this->_dnsHost . '&ip=' . $this->_dnsIP); break; + case 'spdns': + case 'spdns-v6': + $needsIP = FALSE; + if ($this->_dnsVerboseLog) { + log_error("SPDNS: ({$this->_dnsHost}) DNS update() starting."); + } + curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass); + $server = "https://update.spdns.de/nic/update"; + $port = ""; + if ($this->_dnsServer) { + $server = $this->_dnsServer; + } + if ($this->_dnsPort) { + $port = ":" . $this->_dnsPort; + } + curl_setopt($ch, CURLOPT_URL, $server .$port . '?hostname=' . $this->_dnsHost . '&myip=' . $this->_dnsIP); + break; default: break; } @@ -1279,17 +1303,14 @@ break; case 'cloudflare': $output = json_decode($data); - if ($output->result->content === $this->_dnsIP){ + if ($output->result->content === $this->_dnsIP) { $status = "DynDNS: (Success) {$this->_dnsHost} updated to {$this->_dnsIP}"; $successful_update = true; - } - elseif ($output->errors[0]->code === 9103){ + } elseif ($output->errors[0]->code === 9103) { $status = "DynDNS ({$this->_dnsHost}): ERROR - Invalid Credentials! Don't forget to use API Key for password field with CloudFlare."; - } - elseif (($output->success) && (!$output->result[0]->id)) { + } elseif (($output->success) && (!$output->result[0]->id)) { $status = "DynDNS ({$this->_dnsHost}): ERROR - Zone or Host ID was not found, check your hostname."; - } - else { + } else { $status = "DynDNS ({$this->_dnsHost}): UNKNOWN ERROR - {$output->errors[0]->message}"; log_error("DynDNS ({$this->_dnsHost}): PAYLOAD: {$data}"); } @@ -1417,6 +1438,26 @@ break; } break; + case 'spdns': + case 'spdns-v6': + if (preg_match('/notfqdn/i', $data)) { + $status = "phpDynDNS ({$this->_dnsHost}): (Error) Not A FQDN!"; + } else if (preg_match('/nohost/i', $data)) { + $status = "phpDynDNS ({$this->_dnsHost}): (Error) No such host"; + } else if (preg_match('/nochg/i', $data)) { + $status = "phpDynDNS ({$this->_dnsHost}): (Success) No Change In IP Address"; + $successful_update = true; + } else if (preg_match('/good/i', $data)) { + $status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Changed Successfully! (".$this->_dnsIP.")"; + $successful_update = true; + } else if (preg_match('/badauth/i', $data)) { + $status = "phpDynDNS ({$this->_dnsHost}): (Error) User Authorization Failed"; + } else { + $status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)"; + log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$data}"); + $this->_debug($data); + } + break; } if ($successful_update == true) { |