summaryrefslogtreecommitdiffstats
path: root/etc/inc
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2010-11-23 11:33:17 +0000
committerErmal <eri@pfsense.org>2010-11-23 11:33:17 +0000
commit83ae810386210eca593244035825296170281db4 (patch)
treec6cc9f4437e15e96e446b3ff510d1308bcd0762e /etc/inc
parent51d0f81698919935b0fe16255f3cc290ffc2122e (diff)
downloadpfsense-83ae810386210eca593244035825296170281db4.zip
pfsense-83ae810386210eca593244035825296170281db4.tar.gz
Try 3 times to resolve the host to ip before giving up. Leave a proper log if we fail to resolve. Ticket #943.
Diffstat (limited to 'etc/inc')
-rw-r--r--etc/inc/dyndns.class16
1 files changed, 14 insertions, 2 deletions
diff --git a/etc/inc/dyndns.class b/etc/inc/dyndns.class
index 05ec5c7..f60b52d 100644
--- a/etc/inc/dyndns.class
+++ b/etc/inc/dyndns.class
@@ -175,7 +175,7 @@
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
+ curl_setopt($ch, CURLOPT_TIMEOUT, 60); // Completely empirical
}
switch ($this->_dnsService) {
@@ -902,11 +902,23 @@
$this->_ifIP = $ip_address;
if (is_private_ip($ip_address)) {
$hosttocheck = "checkip.dyndns.org";
- $checkip = gethostbyname($hosttocheck);
+ $try = 0;
+ while ($try < 3) {
+ $checkip = gethostbyname($hosttocheck);
+ if (is_ipaddr($checkip))
+ break;
+ $try++;
+ }
+ if ($try >= 3) {
+ log_error("Dyndns debug information: Could not resolve {$hosttocheck} to ip using interface ip {$ip_address}.");
+ return $ip_address; /* XXX: Might return private ip address! */
+ }
$ip_ch = curl_init("http://{$checkip}");
curl_setopt($ip_ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ip_ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ip_ch, CURLOPT_INTERFACE, $ip_address);
+ curl_setopt($ip_ch, CURLOPT_CONNECTTIMEOUT, '30');
+ curl_setopt($ip_ch, CURLOPT_TIMEOUT, 60);
$ip_result_page = curl_exec($ip_ch);
curl_close($ip_ch);
$ip_result_decoded = urldecode($ip_result_page);
OpenPOWER on IntegriCloud