Mercurial > prosody-modules
comparison mod_block_p2pft/mod_block_p2pft.lua @ 1510:094e9d5a4d94
mod_block_p2pft: Plugin for forcing local clients to use approved file transfer proxies
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 22 Sep 2014 18:17:48 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1509:01e37ce7532e | 1510:094e9d5a4d94 |
---|---|
1 local allowed_streamhosts = module:get_option_set("allowed_streamhosts", {}); -- eg proxy.eu.jabber.org | |
2 | |
3 if module:get_option_boolean("allow_local_streamhosts", true) then | |
4 for hostname, host in pairs(hosts) do | |
5 if streamhost.modules.proxy65 then | |
6 allowed_streamhosts:include(hostname); | |
7 end | |
8 end | |
9 end | |
10 | |
11 local function filter_streamhosts(tag) | |
12 if tag.name == "streamhost" and not allowed_streamhosts:contains(tag.attr.jid) then | |
13 return nil; | |
14 end | |
15 return tag; | |
16 end | |
17 | |
18 module:hook("iq/full", function (event) | |
19 local stanza, origin = event.stanza, event.origin; | |
20 if stanza.attr.type == "set" then | |
21 local payload = stanza:get_child("query", "http://jabber.org/protocol/bytestreams"); | |
22 if payload then | |
23 payload:maptags(filter_streamhosts); | |
24 end | |
25 end | |
26 end, 1); |