Fully convert to data plane api

Change global ACL to a map to realtime update with data plane api
Change how on setartup servers are registered in lua
This commit is contained in:
Thomas Lynch
2023-02-18 15:13:40 +11:00
parent 9f95f1c9ac
commit 3cc7482084
13 changed files with 82 additions and 62 deletions

View File

@ -56,35 +56,6 @@ else
captcha_backend_name = "recaptcha"
end
-- setup initial server backends based on hosts.map into backends.map
function _M.setup_servers()
if pow_difficulty < 8 then
error("POW_DIFFICULTY must be > 8. Around 16-32 is better")
end
local backend_name = os.getenv("BACKEND_NAME")
local server_prefix = os.getenv("SERVER_PREFIX")
if backend_name == nil or server_prefix == nil then
return;
end
local hosts_map = Map.new("/etc/haproxy/map/hosts.map", Map._str);
local handle = io.open("/etc/haproxy/map/hosts.map", "r")
local line = handle:read("*line")
local counter = 1
while line do
local domain, backend_host = line:match("([^%s]+)%s+([^%s]+)")
local port_index = backend_host:match'^.*():'
local backend_hostname = backend_host:sub(0, port_index-1)
local backend_port = backend_host:sub(port_index + 1)
core.set_map("/etc/haproxy/map/backends.map", domain, server_prefix..counter)
local proxy = core.proxies[backend_name].servers[server_prefix..counter]
proxy:set_addr(backend_hostname, backend_port)
proxy:set_ready()
line = handle:read("*line")
counter = counter + 1
end
handle:close()
end
-- kill a tor circuit
function _M.kill_tor_circuit(txn)
local ip = txn.sf:src()