feat: 新增rules_add函数返回值

This commit is contained in:
potatso 2023-07-04 18:15:56 +08:00
parent df1b4b1085
commit 5fbe3ec1b0
2 changed files with 8 additions and 4 deletions

View File

@ -22,11 +22,11 @@ function _M.do_init()
end
function _M.rules_add_file(file)
coraza.rules_add_file(_M.waf, file)
return coraza.rules_add_file(_M.waf, file)
end
function _M.rules_add(directives)
coraza.rules_add(_M.waf, directives)
return coraza.rules_add(_M.waf, directives)
end
function _M.do_access_filter()

View File

@ -113,7 +113,9 @@ function _M.rules_add_file(waf, conf_file)
-- extern int coraza_rules_add_file(coraza_waf_t w, char* file, char** er);
local code = coraza.coraza_rules_add_file(waf, cast_to_c_char(conf_file), err_Ptr)
if code == 0 then
nlog(err_fmt(ffi.string(err_Ptr[0])))
local err_log = ffi.string(err_Ptr[0])
nlog(err_fmt(err_log))
return false, err_log
else
nlog(debug_fmt("Success to load rule file with %s", conf_file))
end
@ -123,7 +125,9 @@ function _M.rules_add(waf, rule)
-- extern int coraza_rules_add(coraza_waf_t w, char* directives, char** er);
local code = coraza.coraza_rules_add(waf, cast_to_c_char(rule), err_Ptr)
if code == 0 then
nlog(err_fmt(ffi.string(err_Ptr[0])))
local err_log = ffi.string(err_Ptr[0])
nlog(err_fmt(err_log))
return false, err_log
else
nlog(debug_fmt("Success to load rule with %s", rule))
end