Mercurial > prosody-modules
changeset 537:50be30f203f3
mod_host_guard: fixed plugin, minor code refactor.
author | Marco Cirillo <maranda@lightwitch.org> |
---|---|
date | Sun, 08 Jan 2012 05:25:49 +0000 |
parents | 09280dd0b22e |
children | de64963d8e7a |
files | mod_host_guard/mod_host_guard.lua |
diffstat | 1 files changed, 13 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_host_guard/mod_host_guard.lua Sun Jan 08 03:53:09 2012 +0000 +++ b/mod_host_guard/mod_host_guard.lua Sun Jan 08 05:25:49 2012 +0000 @@ -77,29 +77,30 @@ end end +local function init_hosts() + for n,table in pairs(hosts) do + hosts[n].events.remove_handler("stanza/jabber:server:dialback:result", sdr_hook) + if guard_blockall:contains(n) or guard_protect:contains(n) then handle_activation(n) end + end +end + local function reload() module:log ("debug", "server configuration reloaded, rehashing plugin tables...") guard_blockall = module:get_option_set("host_guard_blockall", {}) guard_ball_wl = module:get_option_set("host_guard_blockall_exceptions", {}) - guard_protect = module:get_option_set("host_guard_components", {}) + guard_protect = module:get_option_set("host_guard_selective", {}) guard_block_bl = module:get_option_set("host_guard_blacklist", {}) + + init_hosts() end local function setup() module:log ("debug", "initializing host guard module...") - - module:hook ("component-activated", handle_activation) - module:hook ("component-deactivated", handle_deactivation) + module:hook ("host-activated", handle_activation) + module:hook ("host-deactivated", handle_deactivation) module:hook ("config-reloaded", reload) - for n,table in pairs(hosts) do - if table.type == "component" then - if guard_blockall:contains(n) or guard_protect:contains(n) then - hosts[n].events.remove_handler("stanza/jabber:server:dialback:result", sdr_hook) - handle_activation(n) - end - end - end + init_hosts() end if prosody.start_time then