mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 15:39:33 +00:00
Optimizes plugins http lint using require
This commit is contained in:
parent
6d1e8697a1
commit
1e3fa9a389
1 changed files with 23 additions and 22 deletions
|
|
@ -882,35 +882,36 @@ end
|
|||
-- ##############################################
|
||||
|
||||
function plugins_utils.extendLintParams(http_lint, params)
|
||||
init_runtime_paths()
|
||||
init_runtime_paths()
|
||||
|
||||
for fname in pairs(ntop.readdir(RUNTIME_PATHS.http_lint)) do
|
||||
local full_path = os_utils.fixPath(RUNTIME_PATHS.http_lint .. "/" .. fname)
|
||||
local lint = dofile(full_path)
|
||||
lua_path_utils.package_path_preprend(RUNTIME_PATHS.http_lint)
|
||||
for fname in pairs(ntop.readdir(RUNTIME_PATHS.http_lint)) do
|
||||
local key = string.sub(fname, 1, string.len(fname) - 4)
|
||||
local lint = require(key)
|
||||
|
||||
if(lint == nil) then
|
||||
traceError(TRACE_ERROR, TRACE_CONSOLE, string.format("Could not load '%s'", full_path))
|
||||
goto continue
|
||||
end
|
||||
if(lint == nil) then
|
||||
traceError(TRACE_ERROR, TRACE_CONSOLE, string.format("Could not load lint for '%s'", key))
|
||||
goto continue
|
||||
end
|
||||
|
||||
if(lint.getAdditionalParameters == nil) then
|
||||
traceError(TRACE_ERROR, TRACE_CONSOLE, string.format("Missing mandatory function 'getAdditionalParameters' in '%s'", full_path))
|
||||
goto continue
|
||||
end
|
||||
if(lint.getAdditionalParameters == nil) then
|
||||
traceError(TRACE_ERROR, TRACE_CONSOLE, string.format("Missing mandatory function 'getAdditionalParameters' in '%s'", key))
|
||||
goto continue
|
||||
end
|
||||
|
||||
local rv = lint.getAdditionalParameters(http_lint)
|
||||
local rv = lint.getAdditionalParameters(http_lint)
|
||||
|
||||
if(type(rv) ~= "table") then
|
||||
traceError(TRACE_ERROR, TRACE_CONSOLE, string.format("function 'getAdditionalParameters' in '%s' returned a non-table value", full_path))
|
||||
goto continue
|
||||
end
|
||||
if(type(rv) ~= "table") then
|
||||
traceError(TRACE_ERROR, TRACE_CONSOLE, string.format("function 'getAdditionalParameters' in '%s' returned a non-table value", key))
|
||||
goto continue
|
||||
end
|
||||
|
||||
for k, v in pairs(rv) do
|
||||
params[k] = v
|
||||
end
|
||||
for k, v in pairs(rv) do
|
||||
params[k] = v
|
||||
end
|
||||
|
||||
::continue::
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue