Mercurial > prosody-modules
annotate mod_s2s_blacklist/mod_s2s_blacklist.lua @ 1234:da39ba4047a7
mod_register_web: Pass request to captcha handler
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 30 Nov 2013 22:10:41 +0100 |
parents | 27b4e01ddbc4 |
children | 853a382c9bd6 |
rev | line source |
---|---|
1179
27b4e01ddbc4
mod_s2s_blacklist: A new _simple_ s2s blacklist module
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 local st = require "util.stanza"; |
27b4e01ddbc4
mod_s2s_blacklist: A new _simple_ s2s blacklist module
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 |
27b4e01ddbc4
mod_s2s_blacklist: A new _simple_ s2s blacklist module
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 local blacklist = module:get_option_inherited_set("s2s_blacklist", {}); |
27b4e01ddbc4
mod_s2s_blacklist: A new _simple_ s2s blacklist module
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 |
27b4e01ddbc4
mod_s2s_blacklist: A new _simple_ s2s blacklist module
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 module:hook("route/remote", function (event) |
27b4e01ddbc4
mod_s2s_blacklist: A new _simple_ s2s blacklist module
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 if blacklist:contains(event.to_host) then |
27b4e01ddbc4
mod_s2s_blacklist: A new _simple_ s2s blacklist module
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 module:send(st.error_reply(event.stanza, "cancel", "not-allowed", "Communication with this domain is restricted")); |
27b4e01ddbc4
mod_s2s_blacklist: A new _simple_ s2s blacklist module
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 return true; |
27b4e01ddbc4
mod_s2s_blacklist: A new _simple_ s2s blacklist module
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 end |
27b4e01ddbc4
mod_s2s_blacklist: A new _simple_ s2s blacklist module
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 end, 100); |
27b4e01ddbc4
mod_s2s_blacklist: A new _simple_ s2s blacklist module
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 |
27b4e01ddbc4
mod_s2s_blacklist: A new _simple_ s2s blacklist module
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 module:hook("s2s-stream-features", function (event) |
27b4e01ddbc4
mod_s2s_blacklist: A new _simple_ s2s blacklist module
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 if blacklist:contains(event.origin.from_host) then |
27b4e01ddbc4
mod_s2s_blacklist: A new _simple_ s2s blacklist module
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 event.origin:close({ |
27b4e01ddbc4
mod_s2s_blacklist: A new _simple_ s2s blacklist module
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
15 condition = "policy-violation"; |
27b4e01ddbc4
mod_s2s_blacklist: A new _simple_ s2s blacklist module
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 text = "Communication with this domain is restricted"; |
27b4e01ddbc4
mod_s2s_blacklist: A new _simple_ s2s blacklist module
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 }); |
27b4e01ddbc4
mod_s2s_blacklist: A new _simple_ s2s blacklist module
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 end |
27b4e01ddbc4
mod_s2s_blacklist: A new _simple_ s2s blacklist module
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 end, 1000); |