Mercurial > prosody-modules
changeset 6556:7477e97a9045
mod_firewall: Apply pre-reload state before re-reading config
This change makes load/reload a bit more robust. module.load() runs before
module.restore() and it reads from the config and updates the state (if
needed).
However, after this, module.restore() could run and apply the old state again.
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sun, 24 May 2026 20:03:20 +0100 |
| parents | d81bb13c0e87 |
| children | 2d916ba3253c |
| files | mod_firewall/mod_firewall.lua |
| diffstat | 1 files changed, 7 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_firewall/mod_firewall.lua Sun May 24 19:58:55 2026 +0100 +++ b/mod_firewall/mod_firewall.lua Sun May 24 20:03:20 2026 +0100 @@ -800,6 +800,13 @@ function module.load() if not prosody.arg then return end -- Don't run in prosodyctl + + local state = module.saved_state; + if state then + active_definitions = state.active_definitions; + loaded_scripts = state.loaded_scripts; + end + local firewall_scripts = module:get_option_set("firewall_scripts", {}); load_unload_scripts(firewall_scripts); -- Replace contents of definitions table (shared) with active definitions @@ -811,11 +818,6 @@ return { active_definitions = active_definitions, loaded_scripts = loaded_scripts }; end -function module.restore(state) - active_definitions = state.active_definitions; - loaded_scripts = state.loaded_scripts; -end - module:hook_global("config-reloaded", function () load_unload_scripts(module:get_option_set("firewall_scripts", {})); end);
