mirror of
https://gitgud.io/fatchan/haproxy-protection.git
synced 2025-05-09 02:05:37 +00:00
feat: add per-user cookie generation
This commit is contained in:
@ -15,5 +15,29 @@ function _M.resolve_fqdn(fqdn)
|
||||
return result:gsub("\n", "")
|
||||
end
|
||||
|
||||
function _M.generate_secret(args)
|
||||
--[[ args: {
|
||||
-- context: enum(applet, txn),
|
||||
-- mode: enum('service', 'action')
|
||||
-- }
|
||||
--]]
|
||||
local context = args.context
|
||||
local mode = args.mode or "service"
|
||||
|
||||
local ip = context.sf:src() or ""
|
||||
|
||||
local hostname = _M.get_hostname() or ""
|
||||
|
||||
local user_agent
|
||||
if mode == "service" then
|
||||
user_agent = context.headers['user-agent'] or {}
|
||||
user_agent = user_agent[0]
|
||||
else
|
||||
user_agent = context.sf:req_hdr('user-agent') or ""
|
||||
end
|
||||
|
||||
return context.sc:xxh32(ip .. hostname .. user_agent)
|
||||
end
|
||||
|
||||
return _M
|
||||
|
||||
|
Reference in New Issue
Block a user