mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 02:20:17 +00:00
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:
@@ -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" );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -96,6 +96,7 @@ public:
|
||||
* @return true if the firewall is running, false if not
|
||||
*/
|
||||
bool IsRunning();
|
||||
bool IsEnabled();
|
||||
/**
|
||||
* @brief Starts the firewall
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user