From 1b6650903ac0770344012baee77c145b48d7b488 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ermal=20Lu=E7i?= Date: Sat, 12 Dec 2009 14:51:03 +0000 Subject: Only get ip address from internet if it is a private address on the interface. This should optimize the speed of dyndns a lot. --- etc/inc/dyndns.class | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/etc/inc/dyndns.class b/etc/inc/dyndns.class index af48efe..daa98ab 100644 --- a/etc/inc/dyndns.class +++ b/etc/inc/dyndns.class @@ -893,12 +893,10 @@ log_error("DynDns: _checkIP() starting."); - $hosttocheck = "checkip.dyndns.org"; - $checkip = gethostbyname($hosttocheck); - if ($hosttocheck == $checkip) { - $ip_address = find_interface_ip($this->_if); - log_error("DynDns debug information: {$ip_address} extracted from local system."); - } else { + $ip_address = find_interface_ip($this->if); + if (is_private_ip($ip_address)) { + $hosttocheck = "checkip.dyndns.org"; + $checkip = gethostbyname($hosttocheck); $ip_ch = curl_init("http://{$checkip}"); curl_setopt($ip_ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ip_ch, CURLOPT_SSL_VERIFYPEER, FALSE); @@ -909,7 +907,8 @@ preg_match('=Current IP Address: (.*)=siU', $ip_result_decoded, $matches); $ip_address = trim($matches[1]); log_error("DynDns debug information: {$ip_address} extracted from {$hosttocheck}"); - } + } else + log_error("DynDns debug information: {$ip_address} extracted from local system."); return $ip_address; } -- cgit v1.1