summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@world.inf.org>2013-02-24 23:13:12 +0545
committerPhil Davis <phil.davis@world.inf.org>2013-02-24 23:13:12 +0545
commit0333f968e5d29cf40830f3be66f09fab6ae42ffe (patch)
tree32581fedf1a63f33899e4404f099a5a3b8f2b52b /etc
parent528d5f17456f4933e87f0cd6ba9b39bd41d4b7f2 (diff)
downloadpfsense-0333f968e5d29cf40830f3be66f09fab6ae42ffe.zip
pfsense-0333f968e5d29cf40830f3be66f09fab6ae42ffe.tar.gz
Add DynDNS No-IP Free account support
The free No-IP account requires the IP address to be changed within every 30 days. If there is no change, the "last updated" date at No-IP does not get updated and the account lapses. This change implements a double-update when the cache age reaches 25 days, or the user does "Save & Force Update" on the GUI. It updates the IP to a dummy address (192.168.1.1) and then 10 seconds later puts it back the way it was. After this process, the "last updated" date on the No-IP site updates. To get this behavious, users have to select "No-IP (free)" as their DynDNS service type.
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/dyndns.class32
1 files changed, 29 insertions, 3 deletions
diff --git a/etc/inc/dyndns.class b/etc/inc/dyndns.class
index 82b8197..82a0e9b 100644
--- a/etc/inc/dyndns.class
+++ b/etc/inc/dyndns.class
@@ -97,6 +97,8 @@
var $_dnsRequestIf;
var $_dnsRequestIfIP;
var $_dnsMaxCacheAgeDays;
+ var $_dnsDummyUpdateDone;
+ var $_forceUpdateNeeded;
/*
* Public Constructor Function (added 12 July 05) [beta]
@@ -162,7 +164,9 @@
log_error("DynDNS ({$this->_dnsHost}): running get_failover_interface for {$dnsRequestIf}. found {$this->_dnsRequestIf}");
$this->_dnsRequestIfIP = get_interface_ip($dnsRequestIf);
$this->_dnsMaxCacheAgeDays = 25;
-
+ $this->_dnsDummyUpdateDone = false;
+ $this->_forceUpdateNeeded = $forceUpdate;
+
// Ensure that we were able to lookup the IP
if(!is_ipaddr($this->_dnsIP)) {
log_error("DynDNS ({$this->_dnsHost}) There was an error trying to determine the public IP for interface - {$dnsIf}({$this->_if}). Probably interface is not a WAN interface.");
@@ -182,6 +186,7 @@
case 'dyndns-custom':
case 'dhs':
case 'noip':
+ case 'noip-free':
case 'easydns':
case 'hn':
case 'zoneedit':
@@ -198,7 +203,15 @@
case 'selfhost':
case 'he-net-tunnelbroker':
case 'route53':
- $this->_update();
+ $this->_update();
+ if($this->_dnsDummyUpdateDone == true) {
+ // If a dummy update was needed, then sleep a while and do the update again to put the proper address back.
+ // Some providers (e.g. No-IP free accounts) need to have at least 1 address change every month.
+ // If the address has not changed recently, or the user did "Force Update", then the code does
+ // a dummy address change for providers like this.
+ sleep(10);
+ $this->_update();
+ }
break;
default:
$this->_error(6);
@@ -271,6 +284,7 @@
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
break;
case 'noip':
+ case 'noip-free':
$needsIP = TRUE;
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$server = "http://dynupdate.no-ip.com/ducupdate.php";
@@ -279,7 +293,17 @@
$server = $this->_dnsServer;
if($this->_dnsPort)
$port = ":" . $this->_dnsPort;
- curl_setopt($ch, CURLOPT_URL, $server . $port . '?username=' . urlencode($this->_dnsUser) . '&pass=' . urlencode($this->_dnsPass) . '&hostname=' . $this->_dnsHost.'&ip=' . $this->_dnsIP);
+ if(($this->_dnsService == "noip-free") &&
+ ($this->_forceUpdateNeeded == true) &&
+ ($this->_dnsDummyUpdateDone == false)) {
+ // Update the IP to a dummy value to force No-IP free accounts to see a change.
+ $iptoset = "192.168.1.1";
+ $this->_dnsDummyUpdateDone = true;
+ log_error("DynDNS ({$this->_dnsHost}): Processing dummy update on No-IP free account. IP temporarily set to " . $iptoset);
+ } else {
+ $iptoset = $this->_dnsIP;
+ }
+ curl_setopt($ch, CURLOPT_URL, $server . $port . '?username=' . urlencode($this->_dnsUser) . '&pass=' . urlencode($this->_dnsPass) . '&hostname=' . $this->_dnsHost.'&ip=' . $iptoset);
break;
case 'easydns':
$needsIP = TRUE;
@@ -629,6 +653,7 @@
case 'dhs':
break;
case 'noip':
+ case 'noip-free':
list($ip,$code) = explode(":",$data);
switch ($code) {
case 0:
@@ -1061,6 +1086,7 @@
}
if (($currentTime - $cacheTime) > $maxCacheAgeSecs) {
$needs_updating = true;
+ $this->_forceUpdateNeeded = true;
$update_reason = "DynDns: More than " . $this->_dnsMaxCacheAgeDays . " days. Updating. ";
$update_reason .= "{$currentTime} - {$cacheTime} > {$maxCacheAgeSecs} ";
}
OpenPOWER on IntegriCloud