summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsmos <seth.mos@dds.nl>2012-06-03 13:00:23 +0200
committersmos <seth.mos@dds.nl>2012-06-03 13:00:23 +0200
commitbf001dec385b1b733a01ca07fdc9946ae994c63e (patch)
tree704407a028674d678a1a180014a7cfa3cca011e8
parent3e1eec5850cdd50974190146459c9361fe156ff5 (diff)
downloadpfsense-bf001dec385b1b733a01ca07fdc9946ae994c63e.zip
pfsense-bf001dec385b1b733a01ca07fdc9946ae994c63e.tar.gz
Allow for failover DynDNS hostnames.
replace get_real_interface() calls with get_failover_interface. If it isn't a group we call get_real_interface() anyhow. We can't put the logic inside get_real_interface() as this would create a recursion Redmine ticket #1965
-rw-r--r--etc/inc/dyndns.class5
-rw-r--r--etc/inc/interfaces.inc25
-rwxr-xr-xusr/local/www/services_dyndns.php12
-rwxr-xr-xusr/local/www/system_gateway_groups_edit.php4
4 files changed, 36 insertions, 10 deletions
diff --git a/etc/inc/dyndns.class b/etc/inc/dyndns.class
index e5ae147..9b97781 100644
--- a/etc/inc/dyndns.class
+++ b/etc/inc/dyndns.class
@@ -153,11 +153,12 @@
$this->_dnsMX = $dnsMX;
$this->_dnsZoneID = $dnsZoneID;
$this->_dnsTTL = $dnsTTL;
- $this->_if = get_real_interface($dnsIf);
+ $this->_if = get_failover_interface($dnsIf);
$this->_checkIP();
$this->_dnsUpdateURL = $dnsUpdateURL;
$this->_dnsResultMatch = $dnsResultMatch;
- $this->_dnsRequestIf = get_real_interface($dnsRequestIf);
+ $this->_dnsRequestIf = get_failover_interface($dnsRequestIf);
+ log_error("running get_failover_interface for {$dnsRequestIf}. found {$this->_dnsRequestIf}");
$this->_dnsRequestIfIP = get_interface_ip($dnsRequestIf);
// Ensure that we where able to lookup the IP
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc
index 86184dd..679ae1d 100644
--- a/etc/inc/interfaces.inc
+++ b/etc/inc/interfaces.inc
@@ -3814,6 +3814,7 @@ function get_real_interface($interface = "wan") {
$wanif = $interface;
break;
}
+
if (empty($config['interfaces'][$interface]))
break;
@@ -4320,7 +4321,7 @@ function ip_in_interface_alias_subnet($interface, $ipalias) {
function get_interface_ip($interface = "wan")
{
- $realif = get_real_interface($interface);
+ $realif = get_failover_interface($interface);
if (!$realif) {
if (preg_match("/^carp/i", $interface))
$realif = $interface;
@@ -4340,7 +4341,7 @@ function get_interface_ip($interface = "wan")
function get_interface_ipv6($interface = "wan")
{
global $config;
- $realif = get_real_interface($interface);
+ $realif = get_failover_interface($interface);
switch($config['interfaces'][$interface]['ipaddrv6']) {
case "6rd":
case "6to4":
@@ -4365,7 +4366,7 @@ function get_interface_ipv6($interface = "wan")
function get_interface_linklocal($interface = "wan")
{
- $realif = get_real_interface($interface);
+ $realif = get_failover_interface($interface);
if (!$realif) {
if (preg_match("/^carp/i", $interface))
$realif = $interface;
@@ -4767,4 +4768,22 @@ function interfaces_staticarp_configure($if) {
return 0;
}
+function get_failover_interface($interface) {
+ global $config;
+ /* compare against gateway groups */
+ $a_groups = return_gateway_groups_array();
+ if(is_array($a_groups[$interface])) {
+ /* we found a gateway group, fetch the interface or vip */
+ if($a_groups[$interface][0]['vip'] <> "")
+ $wanif = $a_groups[$interface][0]['vip'];
+ else
+ $wanif = $a_groups[$interface][0]['int'];
+
+ return $wanif;
+ }
+ /* fall through to get_real_interface */
+ $wanif = get_real_interface($interface);
+ return $wanif;
+}
+
?>
diff --git a/usr/local/www/services_dyndns.php b/usr/local/www/services_dyndns.php
index 14402c9..b4fdc32 100755
--- a/usr/local/www/services_dyndns.php
+++ b/usr/local/www/services_dyndns.php
@@ -119,13 +119,15 @@ include("head.inc");
foreach ($iflist as $if => $ifdesc) {
if ($dyndns['interface'] == $if) {
echo "{$ifdesc}";
+ $iface = $if;
break;
}
}
$groupslist = return_gateway_groups_array();
- foreach ($groupslist as $name => $group) {
- if ($dyndns['interface'] == $name) {
- echo "{$name}";
+ foreach ($groupslist as $if => $group) {
+ if ($dyndns['interface'] == $if) {
+ echo "{$if}";
+ $iface = $if;
break;
}
}
@@ -147,8 +149,8 @@ include("head.inc");
</td>
<td class="listr">
<?php
- $filename = "{$g['conf_path']}/dyndns_{$if}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}.cache";
- $ipaddr = dyndnsCheckIP($if);
+ $filename = "{$g['conf_path']}/dyndns_{$iface}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}.cache";
+ $ipaddr = dyndnsCheckIP($iface);
if(file_exists($filename)) {
$cached_ip_s = explode(":", file_get_contents($filename));
$cached_ip = $cached_ip_s[0];
diff --git a/usr/local/www/system_gateway_groups_edit.php b/usr/local/www/system_gateway_groups_edit.php
index 242e9ea..85e6e91 100755
--- a/usr/local/www/system_gateway_groups_edit.php
+++ b/usr/local/www/system_gateway_groups_edit.php
@@ -133,6 +133,10 @@ if ($_POST) {
$a_gateway_groups[] = $gateway_group;
mark_subsystem_dirty('staticroutes');
+ /* perform RFC 2136 DNS update */
+ services_dnsupdate_process();
+ /* signal dyndns update */
+ services_dyndns_configure();
write_config();
OpenPOWER on IntegriCloud