Mercurial > prosody-modules
annotate mod_proxy65_whitelist/mod_proxy65_whitelist.lua @ 4515:2e33eeafe962
mod_muc_markers: Prevent any markers from reaching the archive, even if untracked
Original intention was to leave alone things that this module isn't
handling. However markers in archives are just problematic without
more advanced logic about what is markable and what is not. It also
requires a more advanced query in mod_muc_rai to determine the latest
markable message instead of the latest archived message.
I'd rather keep the "is archivable" and "is markable" definition the
same for simplicity. I don't want to introduce yet another set of rules
for no reason.
No markers in MAM.
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Mon, 22 Mar 2021 15:55:02 +0000 |
| parents | f96b947303a2 |
| children |
| 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 |
|
1512
cf572280b4dc
mod_proxy65_whitelist: Fix variable name
Kim Alvefur <zash@zash.se>
parents:
1511
diff
changeset
|
5 if host.modules.proxy65 then |
|
1513
4ef0a1a499fa
mod_proxy65_whitelist: Fix util.set use (thanks deoren)
Kim Alvefur <zash@zash.se>
parents:
1512
diff
changeset
|
6 allowed_streamhosts:add(hostname); |
|
1510
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 |
|
2358
f96b947303a2
mod_proxy65_whitelist: Only add proxy hosts enabled after module is loaded if allow_local_streamhosts = true
Kim Alvefur <zash@zash.se>
parents:
2350
diff
changeset
|
9 |
|
f96b947303a2
mod_proxy65_whitelist: Only add proxy hosts enabled after module is loaded if allow_local_streamhosts = true
Kim Alvefur <zash@zash.se>
parents:
2350
diff
changeset
|
10 module:hook_global("host-activated", function (host) |
|
f96b947303a2
mod_proxy65_whitelist: Only add proxy hosts enabled after module is loaded if allow_local_streamhosts = true
Kim Alvefur <zash@zash.se>
parents:
2350
diff
changeset
|
11 if hosts[host].modules.proxy65 then |
|
f96b947303a2
mod_proxy65_whitelist: Only add proxy hosts enabled after module is loaded if allow_local_streamhosts = true
Kim Alvefur <zash@zash.se>
parents:
2350
diff
changeset
|
12 allowed_streamhosts:add(host); |
|
f96b947303a2
mod_proxy65_whitelist: Only add proxy hosts enabled after module is loaded if allow_local_streamhosts = true
Kim Alvefur <zash@zash.se>
parents:
2350
diff
changeset
|
13 end |
|
f96b947303a2
mod_proxy65_whitelist: Only add proxy hosts enabled after module is loaded if allow_local_streamhosts = true
Kim Alvefur <zash@zash.se>
parents:
2350
diff
changeset
|
14 end); |
|
1510
094e9d5a4d94
mod_block_p2pft: Plugin for forcing local clients to use approved file transfer proxies
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 end |
|
094e9d5a4d94
mod_block_p2pft: Plugin for forcing local clients to use approved file transfer proxies
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
16 |
|
094e9d5a4d94
mod_block_p2pft: Plugin for forcing local clients to use approved file transfer proxies
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 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
|
18 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
|
19 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
|
20 end |
|
094e9d5a4d94
mod_block_p2pft: Plugin for forcing local clients to use approved file transfer proxies
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
21 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
|
22 end |
|
094e9d5a4d94
mod_block_p2pft: Plugin for forcing local clients to use approved file transfer proxies
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
23 |
|
094e9d5a4d94
mod_block_p2pft: Plugin for forcing local clients to use approved file transfer proxies
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
24 module:hook("iq/full", function (event) |
|
2350
67990e045d4f
mod_proxy65_whitelist: Remove unused variable [luacheck]
Kim Alvefur <zash@zash.se>
parents:
2349
diff
changeset
|
25 local stanza = event.stanza; |
|
1510
094e9d5a4d94
mod_block_p2pft: Plugin for forcing local clients to use approved file transfer proxies
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
26 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
|
27 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
|
28 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
|
29 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
|
30 end |
|
094e9d5a4d94
mod_block_p2pft: Plugin for forcing local clients to use approved file transfer proxies
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
31 end |
|
094e9d5a4d94
mod_block_p2pft: Plugin for forcing local clients to use approved file transfer proxies
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
32 end, 1); |
