Comparison

mod_s2s_whitelist/mod_s2s_whitelist.lua @ 1288:c1a8ce147885

mod_s2s_whitelist: The opposite of mod_s2s_blacklist
author Kim Alvefur <zash@zash.se>
date Sat, 25 Jan 2014 15:33:26 +0100
comparison
equal deleted inserted replaced
1287:da2e593317d7 1288:c1a8ce147885
1 local st = require "util.stanza";
2
3 local whitelist = module:get_option_inherited_set("s2s_whitelist", {});
4
5 module:hook("route/remote", function (event)
6 if not whitelist:contains(event.to_host) then
7 module:send(st.error_reply(event.stanza, "cancel", "not-allowed", "Communication with this domain is restricted"));
8 return true;
9 end
10 end, 100);
11
12 module:hook("s2s-stream-features", function (event)
13 if not whitelist:contains(event.origin.from_host) then
14 event.origin:close({
15 condition = "policy-violation";
16 text = "Communication with this domain is restricted";
17 });
18 end
19 end, 1000);