annotate mod_s2s_whitelist/mod_s2s_whitelist.lua @ 3656:3e0f4d727825

mod_vcard_muc: Add an alternative method of signaling avatar change When the avatar has been changed, a signal is sent that the room configuration has changed. Clients then do a disco#info query to find the SHA-1 of the new avatar. They can then fetch it as before, or not if they have it cached already. This is meant to be less disruptive than signaling via presence, which caused problems for some clients. If clients transition to the new method, the old one can eventually be removed. The namespace is made up while waiting for standardization. Otherwise it is very close to what's described in https://xmpp.org/extensions/inbox/muc-avatars.html
author Kim Alvefur <zash@zash.se>
date Sun, 25 Aug 2019 20:46:43 +0200
parents c1a8ce147885
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1288
c1a8ce147885 mod_s2s_whitelist: The opposite of mod_s2s_blacklist
Kim Alvefur <zash@zash.se>
parents:
diff changeset
1 local st = require "util.stanza";
c1a8ce147885 mod_s2s_whitelist: The opposite of mod_s2s_blacklist
Kim Alvefur <zash@zash.se>
parents:
diff changeset
2
c1a8ce147885 mod_s2s_whitelist: The opposite of mod_s2s_blacklist
Kim Alvefur <zash@zash.se>
parents:
diff changeset
3 local whitelist = module:get_option_inherited_set("s2s_whitelist", {});
c1a8ce147885 mod_s2s_whitelist: The opposite of mod_s2s_blacklist
Kim Alvefur <zash@zash.se>
parents:
diff changeset
4
c1a8ce147885 mod_s2s_whitelist: The opposite of mod_s2s_blacklist
Kim Alvefur <zash@zash.se>
parents:
diff changeset
5 module:hook("route/remote", function (event)
c1a8ce147885 mod_s2s_whitelist: The opposite of mod_s2s_blacklist
Kim Alvefur <zash@zash.se>
parents:
diff changeset
6 if not whitelist:contains(event.to_host) then
c1a8ce147885 mod_s2s_whitelist: The opposite of mod_s2s_blacklist
Kim Alvefur <zash@zash.se>
parents:
diff changeset
7 module:send(st.error_reply(event.stanza, "cancel", "not-allowed", "Communication with this domain is restricted"));
c1a8ce147885 mod_s2s_whitelist: The opposite of mod_s2s_blacklist
Kim Alvefur <zash@zash.se>
parents:
diff changeset
8 return true;
c1a8ce147885 mod_s2s_whitelist: The opposite of mod_s2s_blacklist
Kim Alvefur <zash@zash.se>
parents:
diff changeset
9 end
c1a8ce147885 mod_s2s_whitelist: The opposite of mod_s2s_blacklist
Kim Alvefur <zash@zash.se>
parents:
diff changeset
10 end, 100);
c1a8ce147885 mod_s2s_whitelist: The opposite of mod_s2s_blacklist
Kim Alvefur <zash@zash.se>
parents:
diff changeset
11
c1a8ce147885 mod_s2s_whitelist: The opposite of mod_s2s_blacklist
Kim Alvefur <zash@zash.se>
parents:
diff changeset
12 module:hook("s2s-stream-features", function (event)
c1a8ce147885 mod_s2s_whitelist: The opposite of mod_s2s_blacklist
Kim Alvefur <zash@zash.se>
parents:
diff changeset
13 if not whitelist:contains(event.origin.from_host) then
c1a8ce147885 mod_s2s_whitelist: The opposite of mod_s2s_blacklist
Kim Alvefur <zash@zash.se>
parents:
diff changeset
14 event.origin:close({
c1a8ce147885 mod_s2s_whitelist: The opposite of mod_s2s_blacklist
Kim Alvefur <zash@zash.se>
parents:
diff changeset
15 condition = "policy-violation";
c1a8ce147885 mod_s2s_whitelist: The opposite of mod_s2s_blacklist
Kim Alvefur <zash@zash.se>
parents:
diff changeset
16 text = "Communication with this domain is restricted";
c1a8ce147885 mod_s2s_whitelist: The opposite of mod_s2s_blacklist
Kim Alvefur <zash@zash.se>
parents:
diff changeset
17 });
c1a8ce147885 mod_s2s_whitelist: The opposite of mod_s2s_blacklist
Kim Alvefur <zash@zash.se>
parents:
diff changeset
18 end
c1a8ce147885 mod_s2s_whitelist: The opposite of mod_s2s_blacklist
Kim Alvefur <zash@zash.se>
parents:
diff changeset
19 end, 1000);