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