mirror of
https://gitgud.io/fatchan/haproxy-protection.git
synced 2025-05-09 02:05:37 +00:00
Fix issue with pplet.qs taking whole query but not parsing the path out of it for the map loopup, caused issues with selecting captcha mode
This commit is contained in:
@ -394,7 +394,6 @@ function M.parse(url)
|
|||||||
M.setAuthority(comp, v)
|
M.setAuthority(comp, v)
|
||||||
return ''
|
return ''
|
||||||
end)
|
end)
|
||||||
|
|
||||||
comp.path = url:gsub("([^/]+)", function (s) return encode(decode(s), M.options.legal_in_path) end)
|
comp.path = url:gsub("([^/]+)", function (s) return encode(decode(s), M.options.legal_in_path) end)
|
||||||
|
|
||||||
setmetatable(comp, {
|
setmetatable(comp, {
|
||||||
@ -406,6 +405,15 @@ function M.parse(url)
|
|||||||
return comp
|
return comp
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Parse and return just the path from applet.qs
|
||||||
|
-- @param qs string
|
||||||
|
-- @return path string
|
||||||
|
function M.getpath(qs)
|
||||||
|
qs = qs:gsub('%?(.*)', '')
|
||||||
|
local path = qs:gsub("([^/]+)", function (s) return encode(decode(s), M.options.legal_in_path) end)
|
||||||
|
return path or ""
|
||||||
|
end
|
||||||
|
|
||||||
--- removes dots and slashes in urls when possible
|
--- removes dots and slashes in urls when possible
|
||||||
-- This function will also remove multiple slashes
|
-- This function will also remove multiple slashes
|
||||||
-- @param path The string representing the path to clean
|
-- @param path The string representing the path to clean
|
||||||
|
@ -154,7 +154,7 @@ function _M.view(applet)
|
|||||||
|
|
||||||
-- check if captcha is enabled, path+domain priority, then just domain, and 0 otherwise
|
-- check if captcha is enabled, path+domain priority, then just domain, and 0 otherwise
|
||||||
local captcha_enabled = false
|
local captcha_enabled = false
|
||||||
local path = applet.qs; --because on /.basedflare/bot-check?/whatever, .qs (query string) holds the "path"
|
local path = url.getpath(applet.qs); --because on /.basedflare/bot-check?/whatever, .qs (query string) holds the old path
|
||||||
|
|
||||||
local ddos_map_lookup = ddos_map:lookup(host..path) or ddos_map:lookup(host)
|
local ddos_map_lookup = ddos_map:lookup(host..path) or ddos_map:lookup(host)
|
||||||
if ddos_map_lookup ~= nil then
|
if ddos_map_lookup ~= nil then
|
||||||
|
@ -2,13 +2,6 @@ package.path = package.path .. "./?.lua;/etc/haproxy/scripts/?.lua;/etc/haproxy
|
|||||||
|
|
||||||
local bot_check = require("bot-check")
|
local bot_check = require("bot-check")
|
||||||
|
|
||||||
core.register_service("bot-check", "http", bot_check.view)
|
|
||||||
core.register_action("captcha-check", { 'http-req', }, bot_check.check_captcha_status)
|
|
||||||
core.register_action("pow-check", { 'http-req', }, bot_check.check_pow_status)
|
|
||||||
core.register_action("decide-checks-necessary", { 'http-req', }, bot_check.decide_checks_necessary)
|
|
||||||
core.register_action("kill-tor-circuit", { 'http-req', }, bot_check.kill_tor_circuit)
|
|
||||||
core.register_action("set-lang-json", { 'http-req', }, bot_check.set_lang_json)
|
|
||||||
|
|
||||||
local backends_map = Map.new('/etc/haproxy/map/backends.map', Map._str)
|
local backends_map = Map.new('/etc/haproxy/map/backends.map', Map._str)
|
||||||
function get_server_names(txn)
|
function get_server_names(txn)
|
||||||
local key = txn.sf:hdr("Host")
|
local key = txn.sf:hdr("Host")
|
||||||
@ -21,3 +14,10 @@ function get_server_names(txn)
|
|||||||
end
|
end
|
||||||
|
|
||||||
core.register_fetches("get_server_names", get_server_names)
|
core.register_fetches("get_server_names", get_server_names)
|
||||||
|
|
||||||
|
core.register_service("bot-check", "http", bot_check.view)
|
||||||
|
core.register_action("captcha-check", { 'http-req', }, bot_check.check_captcha_status)
|
||||||
|
core.register_action("pow-check", { 'http-req', }, bot_check.check_pow_status)
|
||||||
|
core.register_action("decide-checks-necessary", { 'http-req', }, bot_check.decide_checks_necessary)
|
||||||
|
core.register_action("kill-tor-circuit", { 'http-req', }, bot_check.kill_tor_circuit)
|
||||||
|
core.register_action("set-lang-json", { 'http-req', }, bot_check.set_lang_json)
|
||||||
|
Reference in New Issue
Block a user