feat: 添加deny动作同样为block

This commit is contained in:
potatso 2023-07-11 16:46:26 +08:00
parent ed1bc2b098
commit c7055d1e99

View File

@ -75,16 +75,9 @@ function _M.do_handle()
-- Response which was disrupted doesn't make sense.
if ngx_ctx.action ~= nil and ngx_ctx.transaction ~= nil then
nlog(warn_fmt([[Transaction %s request: "%s" is interrupted by policy. Action is %s]], ngx_ctx.request_id, ngx_var.request, ngx_ctx.action))
if ngx_ctx.action == "drop" then
if ngx_ctx.action == "drop" or ngx_ctx.action == "deny" then
ngx_ctx.is_disrupted = true
return ngx_ctx.status_code, fmt(consts.BLOCK_CONTENT_FORMAT, ngx_ctx.status_code)
-- TODO: disrupted by more action
--elseif ngx_ctx.action == "deny" then
-- ngx.status = ngx_ctx.status_code
-- -- NYI: cannot call this C function (yet)
-- -- ngx.header.content_type = consts.BLOCK_CONTENT_TYPE
-- ngx.say(fmt(consts.BLOCK_CONTENT_FORMAT, ngx_ctx.status_code))
-- return ngx.exit(ngx.status)
end
end
end
@ -106,13 +99,6 @@ function _M.do_interrupt()
nlog(err_fmt(msg))
end
return ngx.exit(ngx.status)
-- TODO: disrupted by more action
-- elseif ngx_ctx.action == "deny" then
-- ngx.status = ngx_ctx.status_code
---- NYI: cannot call this C function (yet)
---- ngx.header.content_type = consts.BLOCK_CONTENT_TYPE
-- ngx.say(fmt(consts.BLOCK_CONTENT_FORMAT, ngx_ctx.status_code))
-- eturn ngx.exit(ngx.status)
end
end