Mercurial > prosody-modules
annotate mod_muc_ping/mod_muc_ping.lua @ 4877:adc6241e5d16
mod_measure_process: Report the enforced limit
The soft limit is what the kernel actually enforces, while the hard
limit is is how far you can change the soft limit without privileges.
Unless the process dynamically adjusts the soft limit, knowing the hard
limit is not as useful as knowing the soft limit.
Reporting the soft limit and the number of in-use FDs allows placing
alerts on expressions like 'process_open_fds / process_max_fds >= 0.95'
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 18 Jan 2022 18:55:20 +0100 |
parents | a0ca5d0a49ba |
children |
rev | line source |
---|---|
3349
35dc7c38e362
mod_muc_ping: Implements the Server Optimization part of XEP-0410: MUC Self-Ping
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
1 local st = require "util.stanza"; |
35dc7c38e362
mod_muc_ping: Implements the Server Optimization part of XEP-0410: MUC Self-Ping
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
2 local jid_bare = import("util.jid", "bare"); |
35dc7c38e362
mod_muc_ping: Implements the Server Optimization part of XEP-0410: MUC Self-Ping
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
3 |
35dc7c38e362
mod_muc_ping: Implements the Server Optimization part of XEP-0410: MUC Self-Ping
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 local mod_muc = module:depends"muc"; |
35dc7c38e362
mod_muc_ping: Implements the Server Optimization part of XEP-0410: MUC Self-Ping
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 local rooms = rawget(mod_muc, "rooms"); |
35dc7c38e362
mod_muc_ping: Implements the Server Optimization part of XEP-0410: MUC Self-Ping
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
6 if not rooms then |
35dc7c38e362
mod_muc_ping: Implements the Server Optimization part of XEP-0410: MUC Self-Ping
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
7 module:log("warn", "mod_%s is compatible with Prosody up to 0.10.x", module.name); |
35dc7c38e362
mod_muc_ping: Implements the Server Optimization part of XEP-0410: MUC Self-Ping
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 return; |
35dc7c38e362
mod_muc_ping: Implements the Server Optimization part of XEP-0410: MUC Self-Ping
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 end |
35dc7c38e362
mod_muc_ping: Implements the Server Optimization part of XEP-0410: MUC Self-Ping
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 |
35dc7c38e362
mod_muc_ping: Implements the Server Optimization part of XEP-0410: MUC Self-Ping
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
11 module:hook("iq/full", function (event) |
35dc7c38e362
mod_muc_ping: Implements the Server Optimization part of XEP-0410: MUC Self-Ping
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
12 local origin, stanza = event.origin, event.stanza; |
35dc7c38e362
mod_muc_ping: Implements the Server Optimization part of XEP-0410: MUC Self-Ping
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
13 if stanza.attr.type ~= "get" or not stanza:get_child("ping", "urn:xmpp:ping") then |
35dc7c38e362
mod_muc_ping: Implements the Server Optimization part of XEP-0410: MUC Self-Ping
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
14 return; |
35dc7c38e362
mod_muc_ping: Implements the Server Optimization part of XEP-0410: MUC Self-Ping
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 end |
35dc7c38e362
mod_muc_ping: Implements the Server Optimization part of XEP-0410: MUC Self-Ping
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
16 |
35dc7c38e362
mod_muc_ping: Implements the Server Optimization part of XEP-0410: MUC Self-Ping
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 local from = stanza.attr.from; |
35dc7c38e362
mod_muc_ping: Implements the Server Optimization part of XEP-0410: MUC Self-Ping
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
18 local room_nick = stanza.attr.to; |
35dc7c38e362
mod_muc_ping: Implements the Server Optimization part of XEP-0410: MUC Self-Ping
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
19 local room_jid = jid_bare(room_nick); |
35dc7c38e362
mod_muc_ping: Implements the Server Optimization part of XEP-0410: MUC Self-Ping
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
20 |
35dc7c38e362
mod_muc_ping: Implements the Server Optimization part of XEP-0410: MUC Self-Ping
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
21 local room = rooms[room_jid]; |
35dc7c38e362
mod_muc_ping: Implements the Server Optimization part of XEP-0410: MUC Self-Ping
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
22 if not room then return; end |
35dc7c38e362
mod_muc_ping: Implements the Server Optimization part of XEP-0410: MUC Self-Ping
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
23 |
35dc7c38e362
mod_muc_ping: Implements the Server Optimization part of XEP-0410: MUC Self-Ping
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
24 if room._jid_nick[from] == room_nick then |
35dc7c38e362
mod_muc_ping: Implements the Server Optimization part of XEP-0410: MUC Self-Ping
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
25 origin.send(st.reply(stanza)); |
35dc7c38e362
mod_muc_ping: Implements the Server Optimization part of XEP-0410: MUC Self-Ping
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
26 return true; |
35dc7c38e362
mod_muc_ping: Implements the Server Optimization part of XEP-0410: MUC Self-Ping
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
27 end |
35dc7c38e362
mod_muc_ping: Implements the Server Optimization part of XEP-0410: MUC Self-Ping
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
28 end); |
35dc7c38e362
mod_muc_ping: Implements the Server Optimization part of XEP-0410: MUC Self-Ping
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
29 |
35dc7c38e362
mod_muc_ping: Implements the Server Optimization part of XEP-0410: MUC Self-Ping
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
30 module:hook("muc-disco#info", function(event) |
35dc7c38e362
mod_muc_ping: Implements the Server Optimization part of XEP-0410: MUC Self-Ping
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
31 event.reply:tag("feature", {var="urn:xmpp:ping"}):up(); |
3647
a0ca5d0a49ba
mod_muc_ping: Advertise XEP-0410 feature
Kim Alvefur <zash@zash.se>
parents:
3349
diff
changeset
|
32 event.reply:tag("feature", {var = "http://jabber.org/protocol/muc#self-ping-optimization"}):up(); |
3349
35dc7c38e362
mod_muc_ping: Implements the Server Optimization part of XEP-0410: MUC Self-Ping
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
33 end); |