Reworked flows page

This commit is contained in:
Matteo Biscosi 2024-03-15 06:41:53 -04:00
parent 7c936f9d09
commit 3a61763447
26 changed files with 1936 additions and 372 deletions

View file

@ -15,21 +15,39 @@ local rest_utils = require("rest_utils")
--
-- NOTE: in case of invalid login, no error is returned but redirected to login
--
local application = _GET["application"]
if not isEmptyString(application) then
if string.starts(application, "cat_") then
local category = split(application, "cat_")
_GET["category"] = category[2]
_GET["application"] = nil
end
end
local flows_filter = getFlowsFilter()
local rc = rest_utils.consts.success.ok
local res
local ifid = _GET["ifid"]
if isEmptyString(ifid) then
rc = rest_utils.consts.err.invalid_interface
rest_utils.answer(rc)
return
local host = _GET["host"]
local talking_with = _GET["talkingWith"]
local client = _GET["client"]
local server = _GET["server"]
local flow_info = _GET["flow_info"]
local application = _GET["application"]
if not isEmptyString(application) then
if string.starts(application, "cat_") then
local category = split(application, "cat_")
_GET["category"] = category[2]
_GET["application"] = nil
end
end
interface.select(ifid)
local flows_filter = getFlowsFilter()
-- This is used to get the current bytes rcvd and sent by these specific filters
res = interface.getActiveFlowsStats(flows_filter["hostFilter"], flows_filter, true)
local stats = interface.getActiveFlowsStats(host, flows_filter, false, talking_with, client, server, flow_info)
res = {
totBytesSent = stats.totBytesSent,
totBytesRcvd = stats.totBytesRcvd
}
rest_utils.answer(rc, res)