Software /
code /
prosody-modules
Comparison
mod_s2s_blacklist/mod_s2s_blacklist.lua @ 1325:b21236b6b8d8
Backed out changeset 853a382c9bd6
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 28 Feb 2014 15:37:55 +0100 |
parent | 1324:853a382c9bd6 |
child | 2893:d958558e0058 |
comparison
equal
deleted
inserted
replaced
1324:853a382c9bd6 | 1325:b21236b6b8d8 |
---|---|
1 local st = require "util.stanza"; | 1 local st = require "util.stanza"; |
2 | 2 |
3 local whitelist = module:get_option_inherited_set("s2s_whitelist", {}); | 3 local blacklist = module:get_option_inherited_set("s2s_blacklist", {}); |
4 | 4 |
5 module:hook("route/remote", function (event) | 5 module:hook("route/remote", function (event) |
6 if not whitelist:contains(event.to_host) then | 6 if blacklist: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 not whitelist:contains(event.origin.from_host) then | 13 if blacklist: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 |