comparison mod_e2e_policy/mod_e2e_policy.lua @ 3385:762c7e7ee64b

mod_e2e_policy: Verify that the bare JID of stanza to and from is not in the whitelist
author Michel Le Bihan <michel@lebihan.pl>
date Fri, 30 Nov 2018 19:17:16 +0100
parents 58d61459cdb1
children a76c420eca61
comparison
equal deleted inserted replaced
3384:4321c71cc535 3385:762c7e7ee64b
1 local st = require "util.stanza"; 1 local st = require "util.stanza";
2 local jid_bare = require "util.jid".bare;
2 local host = module.host; 3 local host = module.host;
3 local e2e_policy_chat = module:get_option_string("e2e_policy_chat", "optional"); -- possible values: none, optional and required 4 local e2e_policy_chat = module:get_option_string("e2e_policy_chat", "optional"); -- possible values: none, optional and required
4 local e2e_policy_muc = module:get_option_string("e2e_policy_muc", "optional"); -- possible values: none, optional and required 5 local e2e_policy_muc = module:get_option_string("e2e_policy_muc", "optional"); -- possible values: none, optional and required
5 local e2e_policy_whitelist = module:get_option_set("e2e_policy_whitelist", { }); -- make this module ignore messages sent to and from this JIDs or MUCs 6 local e2e_policy_whitelist = module:get_option_set("e2e_policy_whitelist", { }); -- make this module ignore messages sent to and from this JIDs or MUCs
6 7
9 local e2e_policy_message_optional_muc = module:get_option_string("e2e_policy_message_optional_muc", "For security reasons, OMEMO, OTR or PGP encryption is STRONGLY recommended for MUC on this server."); 10 local e2e_policy_message_optional_muc = module:get_option_string("e2e_policy_message_optional_muc", "For security reasons, OMEMO, OTR or PGP encryption is STRONGLY recommended for MUC on this server.");
10 local e2e_policy_message_required_muc = module:get_option_string("e2e_policy_message_required_muc", "For security reasons, OMEMO, OTR or PGP encryption is required for MUC on this server."); 11 local e2e_policy_message_required_muc = module:get_option_string("e2e_policy_message_required_muc", "For security reasons, OMEMO, OTR or PGP encryption is required for MUC on this server.");
11 12
12 function warn_on_plaintext_messages(event) 13 function warn_on_plaintext_messages(event)
13 -- check if JID is whitelisted 14 -- check if JID is whitelisted
14 if e2e_policy_whitelist:contains(event.stanza.attr.from) or e2e_policy_whitelist:contains(event.stanza.attr.to) then 15 if e2e_policy_whitelist:contains(jid_bare(stanza.attr.from)) or e2e_policy_whitelist:contains(jid_bare(stanza.attr.to)) then
15 return nil; 16 return nil;
16 end 17 end
17 local body = event.stanza:get_child_text("body"); 18 local body = event.stanza:get_child_text("body");
18 -- do not warn for status messages 19 -- do not warn for status messages
19 if not body or event.stanza.attr.type == "error" then 20 if not body or event.stanza.attr.type == "error" then