From 911f6e7ec2d7fb5991342ddb923ea31e4feb78fe Mon Sep 17 00:00:00 2001 From: Frank Wall Date: Thu, 2 Feb 2017 00:00:33 +0100 Subject: [PATCH] net/haproxy: make isEnabled() more accurate --- .../mvc/app/models/OPNsense/HAProxy/HAProxy.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/net/haproxy/src/opnsense/mvc/app/models/OPNsense/HAProxy/HAProxy.php b/net/haproxy/src/opnsense/mvc/app/models/OPNsense/HAProxy/HAProxy.php index d3b69504a..742303782 100644 --- a/net/haproxy/src/opnsense/mvc/app/models/OPNsense/HAProxy/HAProxy.php +++ b/net/haproxy/src/opnsense/mvc/app/models/OPNsense/HAProxy/HAProxy.php @@ -39,13 +39,20 @@ class HAProxy extends BaseModel { /** * check if module is enabled - * @return bool is the HAProxy enabled (1 or more active frontends) + * @param $checkFrontends bool enable in-depth check (1 or more active frontends) + * @return bool is the HAProxy service enabled */ - public function isEnabled() + public function isEnabled($checkFrontends=true) { - foreach ($this->frontends->frontend->__items as $frontend) { - if ((string)$frontend->enabled == "1") { - return true; + if ((string)$this->general->enabled === "1") { + if ($checkFrontends === true) { + foreach ($this->frontends->frontend->__items as $frontend) { + if ((string)$frontend->enabled === "1") { + return true; // Found a active frontend + } + } + } else { + return true; // HAProxy enabled } } return false;