Mercurial > prosody-modules
comparison mod_firewall/mod_firewall.lua @ 6548:430584888704
mod_firewall: marks: load marks from storage on login
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sun, 24 May 2026 10:48:24 +0100 |
| parents | de1f17ed4dac |
| children | 7f3ad8a5b2ab |
comparison
equal
deleted
inserted
replaced
| 6547:cfcd2d2f7119 | 6548:430584888704 |
|---|---|
| 716 -- Loop through the chains in the script, and for each chain attach the compiled code to the | 716 -- Loop through the chains in the script, and for each chain attach the compiled code to the |
| 717 -- relevant events, keeping track in events_hooked so we can cleanly unload later | 717 -- relevant events, keeping track in events_hooked so we can cleanly unload later |
| 718 local events_hooked = {}; | 718 local events_hooked = {}; |
| 719 for chain, chain_info in pairs(chain_functions) do | 719 for chain, chain_info in pairs(chain_functions) do |
| 720 local handler_code = chain_info.code; | 720 local handler_code = chain_info.code; |
| 721 module:log("warn", "Hooking %s for %s", chain, base_name); | |
| 721 local new_handler, err = compile_handler(handler_code, "mod_firewall:"..base_name.."::"..chain, chain_info.rules); | 722 local new_handler, err = compile_handler(handler_code, "mod_firewall:"..base_name.."::"..chain, chain_info.rules); |
| 722 if not new_handler then | 723 if not new_handler then |
| 723 module:log("error", "Compilation error for %s: %s", script, err); | 724 module:log("error", "Compilation error for %s: %s", script, err); |
| 724 errs = true; | 725 errs = true; |
| 725 break; | 726 break; |
| 726 else | 727 else |
| 727 local chain_definition = chains[chain]; | 728 local chain_definition = chains[chain]; |
| 728 if chain_definition and chain_definition.type == "event" then | 729 if chain_definition and chain_definition.type == "event" then |
| 729 local handler = new_handler(chain_definition.pass_return); | 730 local handler = new_handler(chain_definition.pass_return); |
| 730 for _, event_name in ipairs(chain_definition) do | 731 for _, event_name in ipairs(chain_definition) do |
| 732 module:log("warn", "Hooking %s...", event_name); | |
| 731 events_hooked[event_name] = handler; | 733 events_hooked[event_name] = handler; |
| 732 module:hook(event_name, handler, chain_definition.priority); | 734 module:hook(event_name, handler, chain_definition.priority); |
| 733 end | 735 end |
| 734 elseif chain:sub(1, 5) ~= "user/" then | 736 elseif chain:sub(1, 5) ~= "user/" then |
| 735 module:log("warn", "Unknown chain %q", chain); | 737 module:log("warn", "Unknown chain %q", chain); |
| 738 else | |
| 739 module:log("warn", "Sad"); | |
| 736 end | 740 end |
| 737 local event_name, handler = "firewall/chains/"..chain, new_handler(false); | 741 local event_name, handler = "firewall/chains/"..chain, new_handler(false); |
| 738 events_hooked[event_name] = handler; | 742 events_hooked[event_name] = handler; |
| 739 module:hook(event_name, handler); | 743 module:hook(event_name, handler); |
| 740 end | 744 end |
