comparison mod_s2s_blacklist/mod_s2s_blacklist.lua @ 1324:853a382c9bd6

mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
author Kim Alvefur <zash@zash.se>
date Fri, 28 Feb 2014 15:36:06 +0100
parents 27b4e01ddbc4
children b21236b6b8d8
comparison
equal deleted inserted replaced
1323:c84ff82658cb 1324:853a382c9bd6
1 local st = require "util.stanza"; 1 local st = require "util.stanza";
2 2
3 local blacklist = module:get_option_inherited_set("s2s_blacklist", {}); 3 local whitelist = module:get_option_inherited_set("s2s_whitelist", {});
4 4
5 module:hook("route/remote", function (event) 5 module:hook("route/remote", function (event)
6 if blacklist:contains(event.to_host) then 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")); 7 module:send(st.error_reply(event.stanza, "cancel", "not-allowed", "Communication with this domain is restricted"));
8 return true; 8 return true;
9 end 9 end
10 end, 100); 10 end, 100);
11 11
12 module:hook("s2s-stream-features", function (event) 12 module:hook("s2s-stream-features", function (event)
13 if blacklist:contains(event.origin.from_host) then 13 if not whitelist:contains(event.origin.from_host) then
14 event.origin:close({ 14 event.origin:close({
15 condition = "policy-violation"; 15 condition = "policy-violation";
16 text = "Communication with this domain is restricted"; 16 text = "Communication with this domain is restricted";
17 }); 17 });
18 end 18 end