# HG changeset patch # User Marco Cirillo # Date 1326000349 0 # Node ID 50be30f203f37ceabdf4f2011a173fca62fe66f8 # Parent 09280dd0b22e7221a86f4972f83d0f9f8e9cae99 mod_host_guard: fixed plugin, minor code refactor. diff -r 09280dd0b22e -r 50be30f203f3 mod_host_guard/mod_host_guard.lua --- 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