Mercurial > prosody-modules
annotate mod_block_strangers/mod_block_strangers.lua @ 6082:1a6cd0bbb7ab
mod_compliance_2023: Add 2023 Version of the compliance module, basis is the 2021 Version.
diff --git a/mod_compliance_2023/README.md b/mod_compliance_2023/README.md
new file mode 100644
--- /dev/null
+++ b/mod_compliance_2023/README.md
@@ -0,0 +1,22 @@
+---
+summary: XMPP Compliance Suites 2023 self-test
+labels:
+- Stage-Beta
+rockspec:
+ dependencies:
+ - mod_cloud_notify
+
+...
+
+Compare the list of enabled modules with
+[XEP-0479: XMPP Compliance Suites 2023] and produce basic report to the
+Prosody log file.
+
+If installed with the Prosody plugin installer then all modules needed for a green checkmark should be included. (With prosody 0.12 only [mod_cloud_notify] is not included with prosody and we need the community module)
+
+# Compatibility
+
+ Prosody-Version Status
+ --------------- ----------------------
+ trunk Works as of 2024-12-21
+ 0.12 Works
diff --git a/mod_compliance_2023/mod_compliance_2023.lua b/mod_compliance_2023/mod_compliance_2023.lua
new file mode 100644
--- /dev/null
+++ b/mod_compliance_2023/mod_compliance_2023.lua
@@ -0,0 +1,79 @@
+-- Copyright (c) 2021 Kim Alvefur
+--
+-- This module is MIT licensed.
+
+local hostmanager = require "core.hostmanager";
+
+local array = require "util.array";
+local set = require "util.set";
+
+local modules_enabled = module:get_option_inherited_set("modules_enabled");
+
+for host in pairs(hostmanager.get_children(module.host)) do
+ local component = module:context(host):get_option_string("component_module");
+ if component then
+ modules_enabled:add(component);
+ modules_enabled:include(module:context(host):get_option_set("modules_enabled", {}));
+ end
+end
+
+local function check(suggested, alternate, ...)
+ if set.intersection(modules_enabled, set.new({suggested; alternate; ...})):empty() then return suggested; end
+ return false;
+end
+
+local compliance = {
+ array {"Server"; check("tls"); check("disco")};
+
+ array {"Advanced Server"; check("pep", "pep_simple")};
+
+ array {"Web"; check("bosh"); check("websocket")};
+
+ -- No Server requirements for Advanced Web
+
+ array {"IM"; check("vcard_legacy", "vcard"); check("carbons"); check("http_file_share", "http_upload")};
+
+ array {
+ "Advanced IM";
+ check("vcard_legacy", "vcard");
+ check("blocklist");
+ check("muc");
+ check("private");
+ check("smacks");
+ check("mam");
+ check("bookmarks");
+ };
+
+ array {"Mobile"; check("smacks"); check("csi_simple", "csi_battery_saver")};
+
+ array {"Advanced Mobile"; check("cloud_notify")};
+
+ array {"A/V Calling"; check("turn_external", "external_services", "turncredentials", "extdisco")};
+
+};
+
+function check_compliance()
+ local compliant = true;
+ for _, suite in ipairs(compliance) do
+ local section = suite:pop(1);
+ if module:get_option_boolean("compliance_" .. section:lower():gsub("%A", "_"), true) then
+ local missing = set.new(suite:filter(function(m) return type(m) == "string" end):map(function(m) return "mod_" .. m end));
+ if suite[1] then
+ if compliant then
+ compliant = false;
+ module:log("warn", "Missing some modules for XMPP Compliance 2023");
+ end
+ module:log("info", "%s Compliance: %s", section, missing);
+ end
+ end
+ end
+
+ if compliant then module:log("info", "XMPP Compliance 2023: Compliant ✔️"); end
+end
+
+if prosody.start_time then
+ check_compliance()
+else
+ module:hook_global("server-started", check_compliance);
+end
+
| author | Menel <menel@snikket.de> |
|---|---|
| date | Sun, 22 Dec 2024 16:06:28 +0100 |
| parents | 38365c1f1fe4 |
| children |
| rev | line source |
|---|---|
|
772
954532e273be
mod_block_strangers: Module to block message and iqs from people not on your roster
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 |
|
1929
82834df1dea6
mod_block_strangers: Add missing import of util.stanza
Kim Alvefur <zash@zash.se>
parents:
1928
diff
changeset
|
2 local st = require"util.stanza"; |
|
772
954532e273be
mod_block_strangers: Module to block message and iqs from people not on your roster
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 local jid_split = require "util.jid".split; |
|
954532e273be
mod_block_strangers: Module to block message and iqs from people not on your roster
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 local jid_bare = require "util.jid".bare; |
|
954532e273be
mod_block_strangers: Module to block message and iqs from people not on your roster
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 local is_contact_subscribed = require "core.rostermanager".is_contact_subscribed; |
|
2196
09f6e1a09b2b
mod_block_strangers: Allow stanzas form jids the user has sent directed presence to
Kim Alvefur <zash@zash.se>
parents:
2060
diff
changeset
|
6 local full_sessions = prosody.full_sessions; |
|
09f6e1a09b2b
mod_block_strangers: Allow stanzas form jids the user has sent directed presence to
Kim Alvefur <zash@zash.se>
parents:
2060
diff
changeset
|
7 |
|
09f6e1a09b2b
mod_block_strangers: Allow stanzas form jids the user has sent directed presence to
Kim Alvefur <zash@zash.se>
parents:
2060
diff
changeset
|
8 local function has_directed_presence(user, jid) |
|
09f6e1a09b2b
mod_block_strangers: Allow stanzas form jids the user has sent directed presence to
Kim Alvefur <zash@zash.se>
parents:
2060
diff
changeset
|
9 local session = full_sessions[user]; |
|
2419
045d594a3707
mod_block_strangers: Check that the table of directed presence exists before indexing it (fixes traceback)
Kim Alvefur <zash@zash.se>
parents:
2196
diff
changeset
|
10 if session then |
|
045d594a3707
mod_block_strangers: Check that the table of directed presence exists before indexing it (fixes traceback)
Kim Alvefur <zash@zash.se>
parents:
2196
diff
changeset
|
11 local directed = session.directed; |
|
045d594a3707
mod_block_strangers: Check that the table of directed presence exists before indexing it (fixes traceback)
Kim Alvefur <zash@zash.se>
parents:
2196
diff
changeset
|
12 if directed then |
|
045d594a3707
mod_block_strangers: Check that the table of directed presence exists before indexing it (fixes traceback)
Kim Alvefur <zash@zash.se>
parents:
2196
diff
changeset
|
13 return directed[jid]; |
|
045d594a3707
mod_block_strangers: Check that the table of directed presence exists before indexing it (fixes traceback)
Kim Alvefur <zash@zash.se>
parents:
2196
diff
changeset
|
14 end |
|
045d594a3707
mod_block_strangers: Check that the table of directed presence exists before indexing it (fixes traceback)
Kim Alvefur <zash@zash.se>
parents:
2196
diff
changeset
|
15 end |
|
2196
09f6e1a09b2b
mod_block_strangers: Allow stanzas form jids the user has sent directed presence to
Kim Alvefur <zash@zash.se>
parents:
2060
diff
changeset
|
16 end |
|
772
954532e273be
mod_block_strangers: Module to block message and iqs from people not on your roster
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 |
|
954532e273be
mod_block_strangers: Module to block message and iqs from people not on your roster
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 function check_subscribed(event) |
|
954532e273be
mod_block_strangers: Module to block message and iqs from people not on your roster
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 local stanza = event.stanza; |
|
954532e273be
mod_block_strangers: Module to block message and iqs from people not on your roster
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 local to_user, to_host, to_resource = jid_split(stanza.attr.to); |
|
954532e273be
mod_block_strangers: Module to block message and iqs from people not on your roster
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 local from_jid = jid_bare(stanza.attr.from); |
|
2196
09f6e1a09b2b
mod_block_strangers: Allow stanzas form jids the user has sent directed presence to
Kim Alvefur <zash@zash.se>
parents:
2060
diff
changeset
|
22 if to_user and not has_directed_presence(stanza.attr.to, from_jid) and not is_contact_subscribed(to_user, to_host, from_jid) then |
|
3023
38365c1f1fe4
mod_block_strangers: Allow stanza from self (fixes #966, thanks Sergey Popov)
Matthew Wild <mwild1@gmail.com>
parents:
2419
diff
changeset
|
23 -- Allow all messages from your own jid |
|
38365c1f1fe4
mod_block_strangers: Allow stanza from self (fixes #966, thanks Sergey Popov)
Matthew Wild <mwild1@gmail.com>
parents:
2419
diff
changeset
|
24 if from_jid == to_user.."@"..to_host then |
|
38365c1f1fe4
mod_block_strangers: Allow stanza from self (fixes #966, thanks Sergey Popov)
Matthew Wild <mwild1@gmail.com>
parents:
2419
diff
changeset
|
25 return nil; -- Pass through |
|
38365c1f1fe4
mod_block_strangers: Allow stanza from self (fixes #966, thanks Sergey Popov)
Matthew Wild <mwild1@gmail.com>
parents:
2419
diff
changeset
|
26 end |
|
2060
bd0c5d546bf8
mod_block_strangers: Allow iq/full responses through
Matthew Wild <mwild1@gmail.com>
parents:
1929
diff
changeset
|
27 if to_resource and stanza.attr.type == "groupchat" |
|
bd0c5d546bf8
mod_block_strangers: Allow iq/full responses through
Matthew Wild <mwild1@gmail.com>
parents:
1929
diff
changeset
|
28 or stanza.name == "iq" and (stanza.attr.type == "result" or stanza.attr.type == "error") then |
|
772
954532e273be
mod_block_strangers: Module to block message and iqs from people not on your roster
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
29 return nil; -- Pass through |
|
954532e273be
mod_block_strangers: Module to block message and iqs from people not on your roster
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
30 end |
|
1928
252b634b065d
mod_block_strangers: Bounce IQ stanzas (they MUST be replied to)
Kim Alvefur <zash@zash.se>
parents:
1325
diff
changeset
|
31 if stanza.name == "iq" and ( stanza.attr.type == "get" or stanza.attr.type == "set" ) then |
|
252b634b065d
mod_block_strangers: Bounce IQ stanzas (they MUST be replied to)
Kim Alvefur <zash@zash.se>
parents:
1325
diff
changeset
|
32 event.origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); |
|
252b634b065d
mod_block_strangers: Bounce IQ stanzas (they MUST be replied to)
Kim Alvefur <zash@zash.se>
parents:
1325
diff
changeset
|
33 end |
|
1325
b21236b6b8d8
Backed out changeset 853a382c9bd6
Kim Alvefur <zash@zash.se>
parents:
1324
diff
changeset
|
34 return true; -- Drop stanza |
|
772
954532e273be
mod_block_strangers: Module to block message and iqs from people not on your roster
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
35 end |
|
954532e273be
mod_block_strangers: Module to block message and iqs from people not on your roster
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
36 end |
|
954532e273be
mod_block_strangers: Module to block message and iqs from people not on your roster
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
37 |
|
774
52caf54fc270
mod_block_strangers: Bump handler priority to 200 (just because)
Matthew Wild <mwild1@gmail.com>
parents:
772
diff
changeset
|
38 module:hook("message/bare", check_subscribed, 200); |
|
52caf54fc270
mod_block_strangers: Bump handler priority to 200 (just because)
Matthew Wild <mwild1@gmail.com>
parents:
772
diff
changeset
|
39 module:hook("message/full", check_subscribed, 200); |
|
52caf54fc270
mod_block_strangers: Bump handler priority to 200 (just because)
Matthew Wild <mwild1@gmail.com>
parents:
772
diff
changeset
|
40 module:hook("iq/full", check_subscribed, 200); |
