Revision e26e1f76
Added by Andrew Senetar about 12 years ago
etc/inc/dyndns.class | ||
---|---|---|
24 | 24 |
* - Amazon Route 53 (aws.amazon.com) |
25 | 25 |
* - DNS-O-Matic (dnsomatic.com) |
26 | 26 |
* - Custom DDNS (any URL) |
27 |
* - CloudFlare (www.cloudflare.com) |
|
27 | 28 |
* +----------------------------------------------------+ |
28 | 29 |
* Requirements: |
29 | 30 |
* - PHP version 4.0.2 or higher with the CURL Library and the PCRE Library |
... | ... | |
60 | 61 |
* SelfHost - Last Tested: 26 December 2011 |
61 | 62 |
* Amazon Route 53 - Last tested: 01 April 2012 |
62 | 63 |
* DNS-O-Matic - Last Tested: 9 September 2010 |
64 |
* CloudFlare - Last Tested: 30 May 2013 |
|
63 | 65 |
* +====================================================+ |
64 | 66 |
* |
65 | 67 |
* @author E.Kristensen |
... | ... | |
207 | 209 |
case 'selfhost': |
208 | 210 |
case 'he-net-tunnelbroker': |
209 | 211 |
case 'route53': |
212 |
case 'cloudflare': |
|
210 | 213 |
$this->_update(); |
211 | 214 |
if($this->_dnsDummyUpdateDone == true) { |
212 | 215 |
// If a dummy update was needed, then sleep a while and do the update again to put the proper address back. |
... | ... | |
574 | 577 |
log_error("Sending request to: ".$server); |
575 | 578 |
curl_setopt($ch, CURLOPT_URL, $server); |
576 | 579 |
break; |
580 |
case 'cloudflare': |
|
581 |
$needsIP = TRUE; |
|
582 |
$dnsServer ='www.cloudflare.com'; |
|
583 |
$dnsHost = str_replace(' ','', $this->_dnsHost); |
|
584 |
$URL = "https://{$dnsServer}/api.html?a=DIUP&email={$this->_dnsUser}&tkn={$this->_dnsPass}&ip={$this->dnsIP}&hosts={$dnsHost}"; |
|
585 |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); |
|
586 |
curl_setopt($ch, CURLOPT_URL, $URL); |
|
587 |
break; |
|
577 | 588 |
default: |
578 | 589 |
break; |
579 | 590 |
} |
... | ... | |
996 | 1007 |
else |
997 | 1008 |
$status = "phpDynDNS: (Error) Result did not match."; |
998 | 1009 |
break; |
1010 |
case 'cloudflare': |
|
1011 |
// recieve multipe results |
|
1012 |
$data = explode("\n",$data); |
|
1013 |
$lines = count($data)-1; |
|
1014 |
|
|
1015 |
// loop over the lines |
|
1016 |
for ($pos=0; ($successful_update || $pos == 0) && $pos < $lines; $pos++){ |
|
1017 |
$resp = $data[$pos]; |
|
1018 |
if (preg_match('/UAUTH/i', $resp)) { |
|
1019 |
$status = "DynDNS: The username specified is not authorized to update this hostname and domain."; |
|
1020 |
} else if (preg_match('/NOHOST/i', $resp)) { |
|
1021 |
$status = "DynDNS: No valid FQDN (fully qualified domain name) was specified"; |
|
1022 |
} else if (preg_match('/INVLDHST/i', $resp)) { |
|
1023 |
$status = "DynDNS: An invalid hostname was specified. This may be due to the fact the hostname has not been created in the system. Creating new host names via clients is not supported."; |
|
1024 |
} else if (preg_match('/INVLDIP/i', $resp)) { |
|
1025 |
$status = "DynDNS: The IP address given is not valid."; |
|
1026 |
} else if (preg_match('/DUPHST/i', $resp)) { |
|
1027 |
$status = "DynDNS: Duplicate values exist for a record. Only single values for records are supported currently."; |
|
1028 |
} else if (preg_match('/NOUPDATE/i', $resp)) { |
|
1029 |
$status = "DynDNS: No changes made to the hostname (".strtok($resp,' ')."). Continual updates with no changes lead to blocked clients."; |
|
1030 |
$successful_update = true; //success if it is the same so that it saves |
|
1031 |
} else if (preg_match('/OK/i', $resp)) { |
|
1032 |
$status = "DynDNS: (Success) (".strtok($resp,' ').") IP Address for Changed Successfully! ($IP)"; |
|
1033 |
$successful_update = true; |
|
1034 |
} else { |
|
1035 |
$status = "DynDNS: (Unknown Response)"; |
|
1036 |
log_error("DynDNS: PAYLOAD: {$resp}"); |
|
1037 |
$this->_debug($resp); |
|
1038 |
} |
|
1039 |
log_error($status); |
|
1040 |
} |
|
1041 |
break; |
|
999 | 1042 |
} |
1000 | 1043 |
|
1001 | 1044 |
if($successful_update == true) { |
Also available in: Unified diff
Update dyndns.class add CloudFlare
Add CloudFlare Support to dyndns.class