mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 16:09:32 +00:00
Split user script template logic into separate script
This commit is contained in:
parent
25212db5ce
commit
1c8c93ff6e
4 changed files with 208 additions and 56 deletions
|
|
@ -249,6 +249,8 @@ local function validateOperator(mode)
|
|||
return validateChoice(modes, mode)
|
||||
end
|
||||
|
||||
http_lint.validateOperator = validateOperator
|
||||
|
||||
local function validateAlertValue(value)
|
||||
return validateEmpty(value) or
|
||||
validateNumber(value) or
|
||||
|
|
@ -1067,57 +1069,7 @@ local function validateListItems(script, value)
|
|||
return true, value
|
||||
end
|
||||
|
||||
-- #################################################################
|
||||
|
||||
function http_lint.validateHookConfig(script, hook, value)
|
||||
local rv = true
|
||||
|
||||
if(value.enabled == nil) then
|
||||
return false, "Missing 'enabled' item"
|
||||
end
|
||||
|
||||
if(value.script_conf == nil) then
|
||||
return false, "Missing 'script_conf' item"
|
||||
end
|
||||
|
||||
local conf = value.script_conf
|
||||
|
||||
if script.gui and script.gui.input_builder then
|
||||
local input_builder = script.gui.input_builder
|
||||
local mandatory_fields = {}
|
||||
|
||||
if(input_builder == "threshold_cross") then
|
||||
if(value.enabled and (not validateOperator(conf.operator))) then
|
||||
return false, "bad operator"
|
||||
end
|
||||
|
||||
if(value.enabled and tonumber(conf.threshold) == nil) then
|
||||
return false, "bad threshold"
|
||||
end
|
||||
elseif(input_builder == "items_list") then
|
||||
rv, value = validateListItems(script, value)
|
||||
elseif(input_builder == "elephant_flows") then
|
||||
if(value.enabled and tonumber(conf.l2r_bytes_value) == nil) then
|
||||
return false, "bad l2r_bytes_value value"
|
||||
end
|
||||
|
||||
if(value.enabled and tonumber(conf.r2l_bytes_value) == nil) then
|
||||
return false, "bad r2l_bytes_value value"
|
||||
end
|
||||
|
||||
rv, value = validateListItems(script, value)
|
||||
elseif(input_builder == "long_lived") then
|
||||
if(value.enabled and tonumber(conf.min_duration) == nil) then
|
||||
return false, "bad min_duration value"
|
||||
end
|
||||
|
||||
rv, value = validateListItems(script, value)
|
||||
end
|
||||
end
|
||||
|
||||
-- Assume valid by default
|
||||
return rv, value
|
||||
end
|
||||
http_lint.validateListItems = validateListItems
|
||||
|
||||
-- #################################################################
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue