mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 10:20:26 +00:00
API CHANGE: New action for sysadm/firewall
"action":"open"
REQUIRES: "ports":[<number>/<type>, <number2>/<type2>]
REST Request (example):
-------------------------------
PUT /sysadm/firewall
{
"action" : "open",
"ports" : [
"12151/tcp"
]
}
WebSocket Request:
-------------------------------
{
"namespace" : "sysadm",
"name" : "firewall",
"args" : {
"ports" : [
"12151/tcp"
],
"action" : "open"
},
"id" : "fooid"
}
Response:
-------------------------------
{
"args": {
"result": "success"
},
"id": "fooid",
"name": "response",
"namespace": "sysadm"
}
This commit is contained in:
@@ -1136,6 +1136,23 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmFirewallRequest(const QJsonV
|
||||
out->insert("is_running", FMGR.IsRunning() ? "true" : "false" );
|
||||
out->insert("is_enabled", FMGR.IsEnabled() ? "true" : "false" );
|
||||
|
||||
}else if(action=="open" && in_args.toObject().contains("ports")){
|
||||
//REQUIRED: "ports" = [<num>/<type>, <num2>/<type2>, etc..]
|
||||
QJsonValue val = in_args.toObject().value("ports");
|
||||
QStringList ports;
|
||||
QList<sysadm::PortInfo> P;
|
||||
if(val.isString()){ ports << val.toString(); }
|
||||
else if(val.isArray()){ ports = JsonArrayToStringList(val.toArray()); }
|
||||
for(int i=0; i<ports.length(); i++){
|
||||
sysadm::PortInfo info = FMGR.LookUpPort(ports[i].section("/",0,0).toInt(), ports[i].section("/",1,1));
|
||||
if(info.Port<0 || (info.Type!="tcp" && info.Type!="udp") ){ continue; }
|
||||
P << info;
|
||||
}
|
||||
if(!P.isEmpty()){
|
||||
ok = true;
|
||||
FMGR.OpenPort(P);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user