mod_host_guard/mod_host_guard.lua
changeset 725 f79fda2d7e51
parent 724 b94010de43f6
child 726 455a9b8fac27
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