Comparison

mod_host_guard/mod_host_guard.lua @ 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
parent 533:47b9053dba38
child 680:a2cea070f2c7
comparison
equal deleted inserted replaced
536:09280dd0b22e 537:50be30f203f3
75 module:log ("debug", "removing host protection for: "..host) 75 module:log ("debug", "removing host protection for: "..host)
76 end 76 end
77 end 77 end
78 end 78 end
79 79
80 local function init_hosts()
81 for n,table in pairs(hosts) do
82 hosts[n].events.remove_handler("stanza/jabber:server:dialback:result", sdr_hook)
83 if guard_blockall:contains(n) or guard_protect:contains(n) then handle_activation(n) end
84 end
85 end
86
80 local function reload() 87 local function reload()
81 module:log ("debug", "server configuration reloaded, rehashing plugin tables...") 88 module:log ("debug", "server configuration reloaded, rehashing plugin tables...")
82 guard_blockall = module:get_option_set("host_guard_blockall", {}) 89 guard_blockall = module:get_option_set("host_guard_blockall", {})
83 guard_ball_wl = module:get_option_set("host_guard_blockall_exceptions", {}) 90 guard_ball_wl = module:get_option_set("host_guard_blockall_exceptions", {})
84 guard_protect = module:get_option_set("host_guard_components", {}) 91 guard_protect = module:get_option_set("host_guard_selective", {})
85 guard_block_bl = module:get_option_set("host_guard_blacklist", {}) 92 guard_block_bl = module:get_option_set("host_guard_blacklist", {})
93
94 init_hosts()
86 end 95 end
87 96
88 local function setup() 97 local function setup()
89 module:log ("debug", "initializing host guard module...") 98 module:log ("debug", "initializing host guard module...")
90 99 module:hook ("host-activated", handle_activation)
91 module:hook ("component-activated", handle_activation) 100 module:hook ("host-deactivated", handle_deactivation)
92 module:hook ("component-deactivated", handle_deactivation)
93 module:hook ("config-reloaded", reload) 101 module:hook ("config-reloaded", reload)
94 102
95 for n,table in pairs(hosts) do 103 init_hosts()
96 if table.type == "component" then
97 if guard_blockall:contains(n) or guard_protect:contains(n) then
98 hosts[n].events.remove_handler("stanza/jabber:server:dialback:result", sdr_hook)
99 handle_activation(n)
100 end
101 end
102 end
103 end 104 end
104 105
105 if prosody.start_time then 106 if prosody.start_time then
106 setup() 107 setup()
107 else 108 else