mirror of
https://gitgud.io/fatchan/haproxy-protection.git
synced 2025-05-09 02:05:37 +00:00
make the useragent header fetch properly
add a salt to the generate_secret function -- that was kinda important right? lol just pass through to `end` if not POST or GET make it not use calls to hostname and dig in lua scripts, use haproxy backend resolving instead improve the template a lot and make it theme-matched to my site and similar to ngx_http_js_challenge robot page fix various bugs
This commit is contained in:
@ -609,7 +609,7 @@ function M.send(method, t)
|
||||
else
|
||||
return nil, "http." .. method:lower() .. ": Invalid URL schema " .. tostring(schema)
|
||||
end
|
||||
print("ADDR IS", addr)
|
||||
|
||||
local c, err = connect(socket, addr, port)
|
||||
|
||||
if c then
|
||||
|
@ -15,28 +15,16 @@ 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)
|
||||
function _M.generate_secret(context, salt, is_applet)
|
||||
local ip = context.sf:src()
|
||||
local user_agent
|
||||
if is_applet == true then
|
||||
user_agent = context.headers['user-agent'] or {}
|
||||
user_agent = user_agent[0]
|
||||
else
|
||||
user_agent = context.sf:req_hdr('user-agent')
|
||||
end
|
||||
return context.sc:xxh32(salt .. ip .. user_agent)
|
||||
end
|
||||
|
||||
return _M
|
||||
|
Reference in New Issue
Block a user