From 52e952864906792ffd2a03fa630df6b4f17c0073 Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 13 Apr 2010 22:19:00 +0000 Subject: Add a timeout for curl_exec. Combine all dyndns.org methods to one catching up with its API changes. --- etc/inc/dyndns.class | 41 +++++------------------------------------ 1 file changed, 5 insertions(+), 36 deletions(-) (limited to 'etc') diff --git a/etc/inc/dyndns.class b/etc/inc/dyndns.class index a4f542b..29011fb 100644 --- a/etc/inc/dyndns.class +++ b/etc/inc/dyndns.class @@ -171,29 +171,15 @@ curl_setopt($ch, CURLOPT_USERAGENT, $this->_UserAgent); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_INTERFACE, $this->_ifIP); + curl_setopt($ch, CURLOPT_TIMEOUT, 30); // Completely empirical } switch ($this->_dnsService) { case 'dyndns': - $needsIP = FALSE; - log_error("DynDns: DynDns _update() starting. Dynamic"); - if (isset($this->_dnsWildcard) && $this->_dnsWildcard != "OFF") $this->_dnsWildcard = "ON"; - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); - curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass); - $server = "https://members.dyndns.org/nic/update"; - $port = ""; - if($this->_dnsServer) - $server = $this->_dnsServer; - if($this->_dnsPort) - $port = ":" . $this->_dnsPort; - curl_setopt($ch, CURLOPT_URL, $server .$port . '?system=dyndns&hostname=' . $this->_dnsHost . '&myip=' . $this->_dnsIP . '&wildcard='.$this->_dnsWildcard . '&mx=' . $this->_dnsMX . '&backmx=NO'); - $data = curl_exec($ch); - if (@curl_error($ch)) log_error("Curl error occurred: " . curl_error($ch)); - curl_close($ch); - $this->_checkStatus($data); - break; case 'dyndns-static': + case 'dyndns-custom': $needsIP = FALSE; + //log_error("DynDns: DynDns _update() starting. Dynamic"); if (isset($this->_dnsWildcard) && $this->_dnsWildcard != "OFF") $this->_dnsWildcard = "ON"; curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass); @@ -203,29 +189,12 @@ $server = $this->_dnsServer; if($this->_dnsPort) $port = ":" . $this->_dnsPort; - curl_setopt($ch, CURLOPT_URL, $server.$port.'?system=statdns&hostname='.$this->_dnsHost.'&myip='.$this->_dnsIP.'&wildcard='.$this->_dnsWildcard.'&mx='.$this->_dnsMX.'&backmx=NO'); + curl_setopt($ch, CURLOPT_URL, $server .$port . '?system=dyndns&hostname=' . $this->_dnsHost . '&myip=' . $this->_dnsIP . '&wildcard='.$this->_dnsWildcard . '&mx=' . $this->_dnsMX . '&backmx=NO'); $data = curl_exec($ch); if (@curl_error($ch)) log_error("Curl error occurred: " . curl_error($ch)); curl_close($ch); $this->_checkStatus($data); break; - case 'dyndns-custom': - $needsIP = FALSE; - if (isset($this->_dnsWildcard) && $this->_dnsWildcard != "OFF") $this->_dnsWildcard = "ON"; - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); - curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass); - $server = "https://members.dyndns.org/nic/update"; - $port = ""; - if($this->_dnsServer) - $server = $this->_dnsServer; - if($this->_dnsPort) - $port = ":" . $this->_dnsPort; - curl_setopt($ch, CURLOPT_URL, $server.$port.'?system=custom&hostname='.$this->_dnsHost.'&myip='.$this->_dnsIP.'&wildcard='.$this->_dnsWildcard.'&mx='.$this->_dnsMX.'&backmx=NO'); - $data = curl_exec($ch); - if (@curl_error($ch)) log_error("Curl errror occured: " . curl_error($ch)); - curl_close($ch); - $this->_checkStatus($data); - break; case 'dhs': $needsIP = TRUE; $post_data['hostscmd'] = 'edit'; @@ -403,7 +372,6 @@ break; case 'opendns': $needsIP = FALSE; - log_error("DynDns: DynDns _update() starting. Dynamic"); if (isset($this->_dnsWildcard) && $this->_dnsWildcard != "OFF") $this->_dnsWildcard = "ON"; curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass); @@ -896,6 +864,7 @@ log_error("DynDns: _checkIP() starting."); $ip_address = find_interface_ip($this->_if); + $this->_ifIP = $ip_address; if (is_private_ip($ip_address)) { $hosttocheck = "checkip.dyndns.org"; $checkip = gethostbyname($hosttocheck); -- cgit v1.1