summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2010-06-07 21:07:47 +0000
committerErmal <eri@pfsense.org>2010-06-07 21:08:11 +0000
commit66a96e72c06a808f75b8c87ef80aea0c0f95d946 (patch)
tree93e2e95a125bd8badb4bdec54b7f79947f8086a9
parentac7609c2b663693fbbaaba7de2d2a9ab906def07 (diff)
downloadpfsense-66a96e72c06a808f75b8c87ef80aea0c0f95d946.zip
pfsense-66a96e72c06a808f75b8c87ef80aea0c0f95d946.tar.gz
Reorganize code to be able to actually use the lookup_gateway_ip_by_name() function to find even dynamic gateways ip.
-rw-r--r--etc/inc/gwlb.inc25
-rwxr-xr-xusr/local/www/status_gateways.php2
-rw-r--r--usr/local/www/widgets/widgets/gateways.widget.php3
3 files changed, 15 insertions, 15 deletions
diff --git a/etc/inc/gwlb.inc b/etc/inc/gwlb.inc
index 70bfd52..99fcfa3 100644
--- a/etc/inc/gwlb.inc
+++ b/etc/inc/gwlb.inc
@@ -458,19 +458,15 @@ function dhclient_update_gateway_groups_defaultroute($interface = "wan") {
}
function lookup_gateway_ip_by_name($name) {
- global $config;
- if(is_array($config['gateways']['gateway_item'])) {
- foreach($config['gateways']['gateway_item'] as $gateway) {
- if($gateway['name'] == $name)
- return ($gateway['gateway']);
- }
- } else
- return (false);
+ $gateways_arr = return_gateways_array();
+ if (!empty($gateways_arr[$name]))
+ return $gateways_arr[$name]['gateway'];
+
+ return false;
}
function lookup_gateway_monitor_ip_by_name($name) {
- global $config;
$gateways_arr = return_gateways_array();
if (!empty($gateways_arr[$name])) {
@@ -489,7 +485,6 @@ function lookup_gateway_monitor_ip_by_name($name) {
}
function lookup_gateway_interface_by_name($name) {
- global $config;
$gateways_arr = return_gateways_array();
if (!empty($gateways_arr[$name])) {
@@ -509,8 +504,14 @@ function get_interface_gateway($interface, &$dynamic = false) {
$gwcfg = $config['interfaces'][$interface];
if (is_ipaddr($gwcfg['gateway']))
$gw = $gwcfg['gateway'];
- else if (!empty($gwcfg['gateway']))
- $gw = lookup_gateway_ip_by_name($gwcfg['gateway']);
+ else if (!empty($gwcfg['gateway']) && is_array($config['gateways']['gateway_item'])) {
+ foreach($config['gateways']['gateway_item'] as $gateway) {
+ if ($gateway['name'] == $gwcfg['gateway']) {
+ $gw = $gateway['gateway'];
+ break;
+ }
+ }
+ }
// for dynamic interfaces we handle them through the $interface_router file.
if (!is_ipaddr($gw) && !is_ipaddr($gwcfg['ipaddr'])) {
diff --git a/usr/local/www/status_gateways.php b/usr/local/www/status_gateways.php
index 8ca69f6..125100b 100755
--- a/usr/local/www/status_gateways.php
+++ b/usr/local/www/status_gateways.php
@@ -82,7 +82,7 @@ include("head.inc");
<?=strtoupper($gateway['name']);?>
</td>
<td class="listr" align="center" >
- <?=$a_gateways[$gateway['name']['gateway'];?>
+ <?php echo lookup_gateway_ip_by_name($gateway['name']);?>
</td>
<td class="listr" align="center" >
<?=$target;?>
diff --git a/usr/local/www/widgets/widgets/gateways.widget.php b/usr/local/www/widgets/widgets/gateways.widget.php
index c2f5645..b8bca28 100644
--- a/usr/local/www/widgets/widgets/gateways.widget.php
+++ b/usr/local/www/widgets/widgets/gateways.widget.php
@@ -30,7 +30,6 @@ require_once("guiconfig.inc");
require_once("pfsense-utils.inc");
require_once("functions.inc");
-$a_gateways = return_gateways_array();
$gateways_status = array();
$gateways_status = return_gateways_status();
@@ -58,7 +57,7 @@ $counter = 1;
<?php $counter++; ?>
</td>
<td class="listr" align="center" id="gateway<?= $counter; ?>">
- <?=$a_gateways[$gateway['name']]['gateway'];?>
+ <?php echo lookup_gateway_ip_by_name($gateway['name']);?>
<?php $counter++; ?>
</td>
<td class="listr" align="center" id="gateway<?= $counter; ?>">
OpenPOWER on IntegriCloud