API CHANGE: New action for sysadm/firewall

"action":"status"
Returns the current status of the firewall

REST Request (example):
-------------------------------
PUT /sysadm/firewall
{
   "action" : "status"
}

WebSocket Request:
-------------------------------
{
   "name" : "firewall",
   "args" : {
      "action" : "status"
   },
   "id" : "fooid",
   "namespace" : "sysadm"
}

Response:
-------------------------------
{
  "args": {
    "is_enabled": "true",
    "is_running": "true"
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
This commit is contained in:
Ken Moore
2016-09-12 15:29:24 -04:00
parent 6b348c3940
commit 108a2da675
3 changed files with 12 additions and 0 deletions

View File

@@ -1130,6 +1130,12 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmFirewallRequest(const QJsonV
oports << QString::number(all[i].Port)+"/"+all[i].Type;
}
out->insert("openports", QJsonArray::fromStringList(oports));
}else if(action=="status"){
ok = true;
out->insert("is_running", FMGR.IsRunning() ? "true" : "false" );
out->insert("is_enabled", FMGR.IsEnabled() ? "true" : "false" );
}

View File

@@ -147,6 +147,11 @@ bool Firewall::IsRunning()
return General::sysctlAsInt("net.inet.ip.fw.enable") == 1;
}
bool Firewall::IsEnabled(){
ServiceManager serviceManager;
return serviceManager.isEnabled( serviceManager.GetService("ipfw") );
}
void Firewall::Start()
{
ServiceManager serviceManager;

View File

@@ -96,6 +96,7 @@ public:
* @return true if the firewall is running, false if not
*/
bool IsRunning();
bool IsEnabled();
/**
* @brief Starts the firewall
*/