diff options
-rw-r--r-- | etc/inc/dyndns.class | 5 | ||||
-rw-r--r-- | etc/inc/interfaces.inc | 25 | ||||
-rwxr-xr-x | usr/local/www/services_dyndns.php | 12 | ||||
-rwxr-xr-x | usr/local/www/system_gateway_groups_edit.php | 4 |
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(); |