mirror of
https://gitgud.io/fatchan/haproxy-protection.git
synced 2025-05-09 02:05:37 +00:00
fix useragent bug in utils due to not using req_fhdr instead of req_hdr http://cbonte.github.io/haproxy-dconv/2.4/configuration.html\#7.3.6-req.fhdr close #3
This commit is contained in:
@ -2,19 +2,19 @@ local _M = {}
|
|||||||
|
|
||||||
local sha = require("sha")
|
local sha = require("sha")
|
||||||
local secret_bucket_duration = 43200 -- 60 * 60 * 12 -- 12 hours
|
local secret_bucket_duration = 43200 -- 60 * 60 * 12 -- 12 hours
|
||||||
|
require("print_r")
|
||||||
function _M.generate_secret(context, salt, is_applet, iterations)
|
function _M.generate_secret(context, salt, is_applet, iterations)
|
||||||
local start_sec = core.now()['sec']
|
local start_sec = core.now()['sec']
|
||||||
local bucket = start_sec - (start_sec % secret_bucket_duration)
|
local bucket = start_sec - (start_sec % secret_bucket_duration)
|
||||||
local ip = context.sf:src()
|
local ip = context.sf:src()
|
||||||
local user_agent = ""
|
local user_agent = ""
|
||||||
--TODO: fix bug here making this not be same value
|
if is_applet == true then
|
||||||
-- if is_applet == true then
|
user_agent = context.headers['user-agent'] or {}
|
||||||
-- user_agent = context.headers['user-agent'] or {}
|
user_agent = user_agent[0]
|
||||||
-- user_agent = user_agent[0]
|
else
|
||||||
-- else
|
--note req_fhdr not req_hdr otherwise commas in useragent become a delimiter
|
||||||
-- user_agent = context.sf:req_hdr('user-agent')
|
user_agent = context.sf:req_fhdr('user-agent')
|
||||||
-- end
|
end
|
||||||
if iterations == nil then
|
if iterations == nil then
|
||||||
--hcaptcha secret is just this
|
--hcaptcha secret is just this
|
||||||
return context.sc:xxh32(salt .. bucket .. ip .. user_agent)
|
return context.sc:xxh32(salt .. bucket .. ip .. user_agent)
|
||||||
|
Reference in New Issue
Block a user