Adjust lua get_server_names

This commit is contained in:
Thomas Lynch
2023-09-18 23:14:32 +10:00
parent bf3e2571c1
commit 2f9823bf51

View File

@ -1,13 +1,16 @@
package.path = package.path .. "./?.lua;/etc/haproxy/scripts/?.lua;/etc/haproxy/libs/?.lua"
local bot_check = require("bot-check")
local utils = require("utils")
local backends_map = Map.new('/etc/haproxy/map/backends.map', Map._str)
function get_server_names(txn)
local key = txn.sf:hdr("Host")
local value = backends_map:lookup(key or "")
if value ~= nil then
return value
local vals = utils.split(value, ",")
-- todo: something smarter?
return vals[math.random(#vals)]
else
return ""
end