# HG changeset patch # User Matthew Wild # Date 1779649400 -3600 # Node ID 7477e97a9045b7eac139c38b4d2985d862557211 # Parent d81bb13c0e87fc7fb9d62e1c863bcccc30e06ac8 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. diff -r d81bb13c0e87 -r 7477e97a9045 mod_firewall/mod_firewall.lua --- 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);