summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Becker <razzfazz@gmail.com>2013-07-07 12:39:13 -0700
committerDaniel Becker <razzfazz@gmail.com>2013-07-10 19:00:03 -0700
commit5a55d9d7d4c1e52d43abf1c5a8a99a4eabd0037d (patch)
tree87fe2c3f578ee6881c37fd3a2595b103c2f55c98
parent26f80aff92ea3f70301273d869d30c68d4b73d48 (diff)
downloadpfsense-5a55d9d7d4c1e52d43abf1c5a8a99a4eabd0037d.zip
pfsense-5a55d9d7d4c1e52d43abf1c5a8a99a4eabd0037d.tar.gz
Add backend support for HE.net AAAA record updates.
Defines a new DynDNS provider 'he-net-v6' for updating AAAA entries on dns.he.net.
-rw-r--r--etc/inc/dyndns.class117
-rw-r--r--etc/inc/services.inc4
2 files changed, 118 insertions, 3 deletions
diff --git a/etc/inc/dyndns.class b/etc/inc/dyndns.class
index 5ac93d4..0a2789d 100644
--- a/etc/inc/dyndns.class
+++ b/etc/inc/dyndns.class
@@ -36,8 +36,10 @@
* - _checkStatus()
* - _error()
* - _detectChange()
+ * - _detectChangev6()
* - _debug()
* - _checkIP()
+ * - _checkIPv6()
* +----------------------------------------------------+
* DynDNS Dynamic - Last Tested: 12 July 2005
* DynDNS Static - Last Tested: NEVER
@@ -74,6 +76,7 @@
class updatedns {
var $_cacheFile;
+ var $_cacheFilev6;
var $_debugFile;
var $_UserAgent = 'User-Agent: phpDynDNS/0.7';
var $_errorVerbosity = 0;
@@ -82,6 +85,7 @@
var $_dnsPass;
var $_dnsHost;
var $_dnsIP;
+ var $_dnsIPv6;
var $_dnsWildcard;
var $_dnsMX;
var $_dnsBackMX;
@@ -100,6 +104,7 @@
var $_dnsMaxCacheAgeDays;
var $_dnsDummyUpdateDone;
var $_forceUpdateNeeded;
+ var $_useIPv6;
/*
* Public Constructor Function (added 12 July 05) [beta]
@@ -119,6 +124,7 @@
global $config, $g;
$this->_cacheFile = "{$g['conf_path']}/dyndns_{$dnsIf}{$dnsService}" . escapeshellarg($dnsHost) . "{$dnsID}.cache";
+ $this->_cacheFilev6 = "{$g['conf_path']}/dyndns_{$dnsIf}{$dnsService}" . escapeshellarg($dnsHost) . "{$dnsID}_v6.cache";
$this->_debugFile = "{$g['varetc_path']}/dyndns_{$dnsIf}{$dnsService}" . escapeshellarg($dnsHost) . "{$dnsID}.debug";
$this->_dnsVerboseLog = $dnsVerboseLog;
@@ -149,6 +155,13 @@
if (!$dnsHost) $this->_error(5);
}
+ switch ($dnsService) {
+ case 'he-net-v6':
+ $this->_useIPv6 = true;
+ break;
+ default:
+ $this->_useIPv6 = false;
+ }
$this->_dnsService = strtolower($dnsService);
$this->_dnsUser = $dnsUser;
$this->_dnsPass = $dnsPass;
@@ -161,6 +174,8 @@
$this->_dnsTTL = $dnsTTL;
$this->_if = get_failover_interface($dnsIf);
$this->_checkIP();
+ if($this->_useIPv6 == true)
+ $this->_checkIPv6();
$this->_dnsUpdateURL = $dnsUpdateURL;
$this->_dnsResultMatch = $dnsResultMatch;
$this->_dnsRequestIf = get_failover_interface($dnsRequestIf);
@@ -180,7 +195,7 @@
$this->_debugID = rand(1000000, 9999999);
- if ($forceUpdate == false && $this->_detectChange() == false) {
+ if ($forceUpdate == false && $this->_detectChange() == false && ($this->_useIPv6 == false || $this->_detectChangev6() == false)) {
$this->_error(10);
} else {
switch ($this->_dnsService) {
@@ -204,6 +219,7 @@
case 'opendns':
case 'namecheap':
case 'he-net':
+ case 'he-net-v6':
case 'selfhost':
case 'he-net-tunnelbroker':
case 'route53':
@@ -480,6 +496,15 @@
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
curl_setopt($ch, CURLOPT_URL, $server . 'hostname=' . $this->_dnsHost . '&password=' . $this->_dnsPass . '&myip=' . $this->_dnsIP);
break;
+ case 'he-net-v6':
+ $needsIP = FALSE;
+ if ($this->_dnsVerboseLog)
+ log_error("HE.net IPv6 ({$this->_dnsHost}): DNS update() starting.");
+ $server = "https://dyn.dns.he.net/nic/update?";
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
+ curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
+ curl_setopt($ch, CURLOPT_URL, $server . 'hostname=' . $this->_dnsHost . '&password=' . $this->_dnsPass . '&myip=' . $this->_dnsIPv6);
+ break;
case 'he-net-tunnelbroker':
$needsIP = FALSE;
if ($this->_dnsVerboseLog)
@@ -912,6 +937,7 @@
break;
case 'he-net':
+ case 'he-net-v6':
if (preg_match("/badip/i", $data)) {
$status = "phpDynDNS: (Error) Bad Request - The IP provided was invalid.";
} else if (preg_match('/nohost/i', $data)) {
@@ -1001,6 +1027,8 @@
if($successful_update == true) {
/* Write WAN IP to cache file */
$wan_ip = $this->_checkIP();
+ if ($this->_useIPv6 == true)
+ $wan_ipv6 = $this->_checkIPv6();
conf_mount_rw();
if ($wan_ip > 0) {
$currentTime = time();
@@ -1009,6 +1037,13 @@
@file_put_contents($this->_cacheFile, "{$wan_ip}:{$currentTime}");
} else
@unlink($this->_cacheFile);
+ if ($this->_useIPv6 == true && $wan_ipv6 > 0) {
+ $currentTime = time();
+ notify_all_remote(sprintf(gettext("DynDNS updated IPv6 Address on %s (%s) to %s"), convert_real_interface_to_friendly_descr($this->_if), $this->_if, $wan_ipv6));
+ log_error("phpDynDNS: updating cache file {$this->_cacheFilev6}: {$wan_ipv6}");
+ @file_put_contents($this->_cacheFilev6, "{$wan_ipv6}@{$currentTime}");
+ } else
+ @unlink($this->_cacheFilev6);
conf_mount_ro();
}
$this->status = $status;
@@ -1131,6 +1166,71 @@
return false;
}
+ function _detectChangev6() {
+ global $debug;
+
+ if ($debug)
+ log_error("DynDns ({$this->_dnsHost}): _detectChangev6() starting.");
+
+ $currentTime = time();
+
+ $wan_ipv6 = $this->_checkIPv6();
+ if ($wan_ipv6 == 0) {
+ log_error("DynDns ({$this->_dnsHost}): Current WAN IPv6 could not be determined, skipping update process.");
+ return false;
+ }
+ $log_error = "DynDns ({$this->_dnsHost}): Current WAN IPv6: {$wan_ipv6} ";
+
+ if (file_exists($this->_cacheFilev6)) {
+ $contents = file_get_contents($this->_cacheFilev6);
+ list($cacheIPv6,$cacheTime) = explode('@', $contents);
+ $this->_debug($cacheIPv6.'/'.$cacheTime);
+ $initial = false;
+ $log_error .= "Cached IPv6: {$cacheIPv6} ";
+ } else {
+ conf_mount_rw();
+ $cacheIPv6 = '::';
+ @file_put_contents($this->_cacheFilev6, "::@{$currentTime}");
+ conf_mount_ro();
+ $cacheTime = $currentTime;
+ $initial = true;
+ $log_error .= "No Cached IPv6 found.";
+ }
+ if ($this->_dnsVerboseLog)
+ log_error($log_error);
+
+ // Convert seconds = days * hr/day * min/hr * sec/min
+ $maxCacheAgeSecs = $this->_dnsMaxCacheAgeDays * 24 * 60 * 60;
+
+ $needs_updating = FALSE;
+ /* lets determine if the item needs updating */
+ if ($cacheIPv6 != $wan_ipv6) {
+ $needs_updating = true;
+ $update_reason = "DynDns: cacheIPv6 != wan_ipv6. Updating. ";
+ $update_reason .= "Cached IPv6: {$cacheIPv6} WAN IPv6: {$wan_ipv6} ";
+ }
+ if (($currentTime - $cacheTime) > $maxCacheAgeSecs) {
+ $needs_updating = true;
+ $this->_forceUpdateNeeded = true;
+ $update_reason = "DynDns: More than " . $this->_dnsMaxCacheAgeDays . " days. Updating. ";
+ $update_reason .= "{$currentTime} - {$cacheTime} > {$maxCacheAgeSecs} ";
+ }
+ if ($initial == true) {
+ $needs_updating = true;
+ $update_reason .= "Initial update. ";
+ }
+
+ /* finally if we need updating then store the
+ * new cache value and return true
+ */
+ if ($needs_updating == true) {
+ if ($this->_dnsVerboseLog)
+ log_error("DynDns ({$this->_dnsHost}): {$update_reason}");
+ return true;
+ }
+
+ return false;
+ }
/*
* Private Function (added 16 July 05) [beta]
@@ -1198,6 +1298,21 @@
return $ip_address;
}
+ function _checkIPv6() {
+ global $debug;
+
+ if ($debug)
+ log_error("DynDns ({$this->_dnsHost}): _checkIPv6() starting.");
+
+ $ipv6_address = find_interface_ipv6($this->_if);
+ if (!is_ipaddrv6($ipv6_address))
+ return 0;
+ if ($this->_dnsVerboseLog)
+ log_error("DynDns ({$this->_dnsHost}): {$ipv6_address} extracted from local system.");
+ $this->_dnsIPv6 = $ipv6_address;
+
+ return $ipv6_address;
+ }
}
diff --git a/etc/inc/services.inc b/etc/inc/services.inc
index e292aaf..7ed1b0a 100644
--- a/etc/inc/services.inc
+++ b/etc/inc/services.inc
@@ -38,8 +38,8 @@
pfSense_MODULE: utils
*/
-define('DYNDNS_PROVIDER_VALUES', 'dnsomatic dyndns dyndns-static dyndns-custom dhs dyns easydns noip noip-free ods zoneedit loopia freedns dnsexit opendns namecheap he-net he-net-tunnelbroker selfhost route53 custom');
-define('DYNDNS_PROVIDER_DESCRIPTIONS', 'DNS-O-Matic,DynDNS (dynamic),DynDNS (static),DynDNS (custom),DHS,DyNS,easyDNS,No-IP,No-IP (free),ODS.org,ZoneEdit,Loopia,freeDNS,DNSexit,OpenDNS,Namecheap,HE.net,HE.net Tunnelbroker,SelfHost,Route 53,Custom');
+define('DYNDNS_PROVIDER_VALUES', 'dnsomatic dyndns dyndns-static dyndns-custom dhs dyns easydns noip noip-free ods zoneedit loopia freedns dnsexit opendns namecheap he-net he-net-v6 he-net-tunnelbroker selfhost route53 custom');
+define('DYNDNS_PROVIDER_DESCRIPTIONS', 'DNS-O-Matic,DynDNS (dynamic),DynDNS (static),DynDNS (custom),DHS,DyNS,easyDNS,No-IP,No-IP (free),ODS.org,ZoneEdit,Loopia,freeDNS,DNSexit,OpenDNS,Namecheap,HE.net,HE.net (v6),HE.net Tunnelbroker,SelfHost,Route 53,Custom');
/* implement ipv6 route advertising deamon */
function services_radvd_configure() {
OpenPOWER on IntegriCloud