comparison mod_host_guard/mod_host_guard.lua @ 725:f79fda2d7e51

mod_host_guard: host handlers are now cleaned properly on module unload (and also still on re/load to be safe).
author Marco Cirillo <maranda@lightwitch.org>
date Mon, 25 Jun 2012 23:26:09 +0000
parents b94010de43f6
children 455a9b8fac27
comparison
equal deleted inserted replaced
724:b94010de43f6 725:f79fda2d7e51
61 end 61 end
62 end 62 end
63 end 63 end
64 64
65 local function init_hosts() 65 local function init_hosts()
66 for n,table in pairs(hosts) do 66 for n in pairs(hosts) do
67 -- This is a bit redundant but better safe then sorry.
67 hosts[n].events.remove_handler("s2sin-established", s2s_hook) 68 hosts[n].events.remove_handler("s2sin-established", s2s_hook)
68 hosts[n].events.remove_handler("route/remote", rr_hook) 69 hosts[n].events.remove_handler("route/remote", rr_hook)
69 hosts[n].events.remove_handler("stanza/jabber:server:dialback:result", s2s_hook) 70 hosts[n].events.remove_handler("stanza/jabber:server:dialback:result", s2s_hook)
70 if guard_blockall:contains(n) or guard_protect:contains(n) then handle_activation(n) end 71 if guard_blockall:contains(n) or guard_protect:contains(n) then handle_activation(n) end
71 end 72 end
88 module:hook ("config-reloaded", reload) 89 module:hook ("config-reloaded", reload)
89 90
90 init_hosts() 91 init_hosts()
91 end 92 end
92 93
94 function module.unload()
95 module:log ("debug", "removing host handlers as module is being unloaded...")
96 for n in pairs(hosts) do
97 hosts[n].events.remove_handler("s2sin-established", s2s_hook)
98 hosts[n].events.remove_handler("route/remote", rr_hook)
99 hosts[n].events.remove_handler("stanza/jabber:server:dialback:result", s2s_hook)
100 end
101 end
102
93 if prosody.start_time then 103 if prosody.start_time then
94 setup() 104 setup()
95 else 105 else
96 module:hook ("server-started", setup) 106 module:hook ("server-started", setup)
97 end 107 end
108