# HG changeset patch # User Matthew Wild # Date 1779616104 -3600 # Node ID 430584888704612375e15f2f0b9f7c0dcdf797ab # Parent cfcd2d2f7119707a9da926dbf7b84dff7e84593c mod_firewall: marks: load marks from storage on login diff -r cfcd2d2f7119 -r 430584888704 mod_firewall/marks.lib.lua --- a/mod_firewall/marks.lib.lua Sun May 24 18:42:43 2026 +0100 +++ b/mod_firewall/marks.lib.lua Sun May 24 10:48:24 2026 +0100 @@ -3,6 +3,19 @@ local user_sessions = prosody.hosts[module.host].sessions; +module:hook("resource-bind", function (event) + local session = event.session; + local username = session.username; + local user = user_sessions[username]; + local marks = user.firewall_marks; + if not marks then + marks = mark_storage:get(username) or {}; + user.firewall_marks = marks; -- luacheck: ignore 122 + end + session.firewall_marks = marks; +end); + + module:hook("firewall/marked/user", function (event) local user = user_sessions[event.username]; local marks = user and user.firewall_marks; diff -r cfcd2d2f7119 -r 430584888704 mod_firewall/mod_firewall.lua --- a/mod_firewall/mod_firewall.lua Sun May 24 18:42:43 2026 +0100 +++ b/mod_firewall/mod_firewall.lua Sun May 24 10:48:24 2026 +0100 @@ -718,6 +718,7 @@ local events_hooked = {}; for chain, chain_info in pairs(chain_functions) do local handler_code = chain_info.code; + module:log("warn", "Hooking %s for %s", chain, base_name); local new_handler, err = compile_handler(handler_code, "mod_firewall:"..base_name.."::"..chain, chain_info.rules); if not new_handler then module:log("error", "Compilation error for %s: %s", script, err); @@ -728,11 +729,14 @@ if chain_definition and chain_definition.type == "event" then local handler = new_handler(chain_definition.pass_return); for _, event_name in ipairs(chain_definition) do + module:log("warn", "Hooking %s...", event_name); events_hooked[event_name] = handler; module:hook(event_name, handler, chain_definition.priority); end elseif chain:sub(1, 5) ~= "user/" then module:log("warn", "Unknown chain %q", chain); + else + module:log("warn", "Sad"); end local event_name, handler = "firewall/chains/"..chain, new_handler(false); events_hooked[event_name] = handler;