summaryrefslogtreecommitdiffstats
path: root/etc/inc/gwlb.inc
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2013-03-26 10:53:21 +0000
committerErmal <eri@pfsense.org>2013-03-26 10:53:38 +0000
commitfd34d6a97c31ae79f13d0018bec5ed56e234f227 (patch)
treec59769f4427e2b3080c301f32525bbee3518ff3f /etc/inc/gwlb.inc
parent58c40f9c4767667c13cf2e3d728dc5cfb5f51098 (diff)
downloadpfsense-fd34d6a97c31ae79f13d0018bec5ed56e234f227.zip
pfsense-fd34d6a97c31ae79f13d0018bec5ed56e234f227.tar.gz
Simplify a bit code branching no change on functionality
Diffstat (limited to 'etc/inc/gwlb.inc')
-rw-r--r--etc/inc/gwlb.inc64
1 files changed, 33 insertions, 31 deletions
diff --git a/etc/inc/gwlb.inc b/etc/inc/gwlb.inc
index 13cde22..3088a38 100644
--- a/etc/inc/gwlb.inc
+++ b/etc/inc/gwlb.inc
@@ -304,37 +304,39 @@ function return_gateways_status($byname = false) {
* or are down, which could cause gateway groups to fail */
$gateways_arr = return_gateways_array();
foreach($gateways_arr as $gwitem) {
- if(isset($gwitem['monitor_disable'])) {
- if(!is_ipaddr($gwitem['monitorip'])) {
- $realif = $gwitem['interface'];
- $tgtip = get_interface_gateway($realif);
- $srcip = find_interface_ip($realif);
- } else {
- $tgtip = $gwitem['monitorip'];
- $srcip = find_interface_ip($realif);
- }
- if($byname == true)
- $target = $gwitem['name'];
- else
- $target = $tgtip;
-
- /* failsafe for down interfaces */
- if($target == "") {
- $target = $gwitem['name'];
- $status[$target]['name'] = $gwitem['name'];
- $status[$target]['lastcheck'] = date('r');
- $status[$target]['delay'] = "0.0ms";
- $status[$target]['loss'] = "100.0%";
- $status[$target]['status'] = "down";
- } else {
- $status[$target]['monitorip'] = $tgtip;
- $status[$target]['srcip'] = $srcip;
- $status[$target]['name'] = $gwitem['name'];
- $status[$target]['lastcheck'] = date('r');
- $status[$target]['delay'] = "0.0ms";
- $status[$target]['loss'] = "0.0%";
- $status[$target]['status'] = "none";
- }
+ if(isset($gwitem['monitor_disable']))
+ continue;
+ if(!is_ipaddr($gwitem['monitorip'])) {
+ $realif = $gwitem['interface'];
+ $tgtip = get_interface_gateway($realif);
+ if (!is_ipaddr($tgtip))
+ $tgtip = "none";
+ $srcip = find_interface_ip($realif);
+ } else {
+ $tgtip = $gwitem['monitorip'];
+ $srcip = find_interface_ip($realif);
+ }
+ if($byname == true)
+ $target = $gwitem['name'];
+ else
+ $target = $tgtip;
+
+ /* failsafe for down interfaces */
+ if($target == "none") {
+ $target = $gwitem['name'];
+ $status[$target]['name'] = $gwitem['name'];
+ $status[$target]['lastcheck'] = date('r');
+ $status[$target]['delay'] = "0.0ms";
+ $status[$target]['loss'] = "100.0%";
+ $status[$target]['status'] = "down";
+ } else {
+ $status[$target]['monitorip'] = $tgtip;
+ $status[$target]['srcip'] = $srcip;
+ $status[$target]['name'] = $gwitem['name'];
+ $status[$target]['lastcheck'] = date('r');
+ $status[$target]['delay'] = "0.0ms";
+ $status[$target]['loss'] = "0.0%";
+ $status[$target]['status'] = "none";
}
}
return($status);
OpenPOWER on IntegriCloud