summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2011-05-25 16:41:26 +0000
committerErmal <eri@pfsense.org>2011-05-25 16:41:43 +0000
commitdd575ea43699b452e1e925518bc9e59f5db78d6f (patch)
tree5dd473cc06cda3373befc8be9773ce504edc5f5c /etc
parent7788c76a4e9e04b356f40f2129ff5309617dad99 (diff)
downloadpfsense-dd575ea43699b452e1e925518bc9e59f5db78d6f.zip
pfsense-dd575ea43699b452e1e925518bc9e59f5db78d6f.tar.gz
Improve some code and check return value from _checkIP.
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/dyndns.class25
1 files changed, 13 insertions, 12 deletions
diff --git a/etc/inc/dyndns.class b/etc/inc/dyndns.class
index 8f9a695..4697da7 100644
--- a/etc/inc/dyndns.class
+++ b/etc/inc/dyndns.class
@@ -795,15 +795,14 @@
if($successful_update == true) {
/* Write WAN IP to cache file */
$wan_ip = $this->_checkIP();
- if (is_ipaddr($wan_ip)) {
+ conf_mount_rw();
+ if ($wan_ip > 0) {
$currentTime = time();
log_error("phpDynDNS: updating cache file {$this->_cacheFile}: {$wan_ip}");
- conf_mount_rw();
- $file = fopen($this->_cacheFile, 'w');
- fwrite($file, $wan_ip.':'.$currentTime);
- fclose($file);
- conf_mount_ro();
- }
+ @file_put_contents($this->_cacheFile, "{$wan_ip}:{$currentTime}");
+ } else
+ @unlink($this->_cacheFile);
+ conf_mount_ro();
}
$this->status = $status;
log_error($status);
@@ -861,6 +860,10 @@
$currentTime = time();
$wan_ip = $this->_checkIP();
+ if ($wan_ip == 0) {
+ log_error("DynDns: Current WAN IP could not be determined.");
+ return true;
+ }
$this->_dnsIP = $wan_ip;
log_error("DynDns: Current WAN IP: {$wan_ip}");
@@ -872,11 +875,9 @@
log_error("DynDns: Cached IP: {$cacheIP}");
} else {
conf_mount_rw();
- $file = fopen($this->_cacheFile, 'w');
- fwrite($file, '0.0.0.0:'.$currentTime);
- fclose($file);
- conf_mount_ro();
$cacheIP = '0.0.0.0';
+ @file_put_contents($this->_cacheFile, "0.0.0.0:{$currentTime}");
+ conf_mount_ro();
$cacheTime = $currentTime;
$initial = true;
log_error("DynDns: No Cached IP found.");
@@ -946,7 +947,7 @@
}
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! */
+ return 0;
}
$ip_ch = curl_init("http://{$checkip}");
curl_setopt($ip_ch, CURLOPT_RETURNTRANSFER, 1);
OpenPOWER on IntegriCloud