summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErmal Luçi <eri@pfsense.org>2009-11-30 01:54:05 +0000
committerErmal Luçi <eri@pfsense.org>2009-11-30 01:54:05 +0000
commit7ae7a9720fc06c6c24de29b50197b1d0b19de4ef (patch)
tree0ca3c0f2f51cb2be14dea756d17d9fa4ad3f6088
parent9d96a4759019862034be4bf361d4db889787663f (diff)
downloadpfsense-7ae7a9720fc06c6c24de29b50197b1d0b19de4ef.zip
pfsense-7ae7a9720fc06c6c24de29b50197b1d0b19de4ef.tar.gz
Resolves #68 When checking for the secondary wan ip address curl is forced to go through the it for all traffic. This might mean that DNS fails. Resolve the checkip.dyndns.org ip outside of curl so it can be guaranteed that the traffic of curl will be just http and nothing else. This allows pfSense installation without internet access to work still since if gethostbyname fails now it just extracts the ip from the local interface. To be checked out is what behaviour this should give for CARPgit diff! (Write now surely it does the wrong thing!)
-rw-r--r--etc/inc/dyndns.class28
1 files changed, 17 insertions, 11 deletions
diff --git a/etc/inc/dyndns.class b/etc/inc/dyndns.class
index a6f4463..3d47747 100644
--- a/etc/inc/dyndns.class
+++ b/etc/inc/dyndns.class
@@ -895,17 +895,23 @@
log_error("DynDns: _checkIP() starting.");
- $ip_ch = curl_init('http://checkip.dyndns.org');
- curl_setopt($ip_ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ip_ch, CURLOPT_SSL_VERIFYPEER, FALSE);
- curl_setopt($ip_ch, CURLOPT_INTERFACE, $this->_if);
- $ip_result_page = curl_exec($ip_ch);
- curl_close($ip_ch);
- $ip_result_decoded = urldecode($ip_result_page);
- preg_match('=Current IP Address: (.*)</body>=siU', $ip_result_decoded, $matches);
- $ip_address = trim($matches[1]);
-
- log_error("DynDns debug information: {$ip_address}");
+ $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_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, $this->_if);
+ $ip_result_page = curl_exec($ip_ch);
+ curl_close($ip_ch);
+ $ip_result_decoded = urldecode($ip_result_page);
+ preg_match('=Current IP Address: (.*)</body>=siU', $ip_result_decoded, $matches);
+ $ip_address = trim($matches[1]);
+ log_error("DynDns debug information: {$ip_address} extracted from {$hosttocheck}");
+ }
return $ip_address;
}
OpenPOWER on IntegriCloud