Software /
code /
prosody-modules
Changeset
2940:0167a102ed35
mod_muc_gc10: Gather statistics on use of the Groupchat 1.0 protocol
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 22 Mar 2018 14:28:27 +0100 |
parents | 2939:280305c043b0 |
children | 2941:a57ed544fece |
files | mod_muc_gc10/README.markdown mod_muc_gc10/mod_muc_gc10.lua |
diffstat | 2 files changed, 76 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_muc_gc10/README.markdown Thu Mar 22 14:28:27 2018 +0100 @@ -0,0 +1,18 @@ +# Groupchat 1.0 usage statistics gathering + +Groupchat 1.0 was probably the protocol that predated +[XEP-0045: Multi-User Chat] and there is still some compatibility that +lives on, in the XEP and in implementations. + +This module tries to detect clients still using the GC 1.0 protocol and +what software they run, to determine if support can be removed. + +Since joins in the GC 1.0 protocol are highly ambiguous, some hits +reported will be because of desynchronized MUC clients + +# Compatibility + +Should work with Prosody 0.10.x and earlier. + +It will not work with current trunk, since the MUC code has had major +changes.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_muc_gc10/mod_muc_gc10.lua Thu Mar 22 14:28:27 2018 +0100 @@ -0,0 +1,58 @@ +local jid_bare = require "util.jid".bare; +local st = require "util.stanza"; + +local rooms = module:depends"muc".rooms; + +module:hook("presence/bare", function (event) + local stanza, origin = event.stanza, event.origin; + if stanza.attr.type ~= nil then return end + + local muc_x = stanza:get_child("x", "http://jabber.org/protocol/muc"); + + local room_jid = jid_bare(stanza.attr.to); + local room = rooms[room_jid]; + if not room then + if muc_x then + -- Normal MUC creation + else + module:log("info", "GC 1.0 room creation from %s", stanza.attr.from); + module:send(st.iq({type="get",id=module.name,from=module.host,to=stanza.attr.from}):query("jabber:iq:version")); + end + return; + end + local current_nick = room._jid_nick[stanza.attr.from]; + + if current_nick then + -- present + if muc_x then + module:log("info", "MUC desync with %s", stanza.attr.from); + module:send(st.iq({type="get",id=module.name,from=module.host,to=stanza.attr.from}):query("jabber:iq:version")); + else + -- normal presence update + end + else + -- joining + if muc_x then + -- normal join + else + module:log("info", "GC 1.0 join from %s", stanza.attr.from); + module:send(st.iq({type="get",id=module.name,from=module.host,to=stanza.attr.from}):query("jabber:iq:version")); + end + end +end); + +module:hook("iq-result/host/"..module.name, function (event) + local stanza, origin = event.stanza, event.origin; + local version = stanza:get_child("query", "jabber:iq:version"); + if not version then + module:log("info", "%s replied with an invalid version reply: %s", stanza.attr.from, tostring(stanza)); + return true; + end + module:log("info", "%s is running: %s %s", stanza.attr.from, version:get_child_text("name"), version:get_child_text("version")); +end); + +module:hook("iq-error/host/"..module.name, function (event) + local stanza, origin = event.stanza, event.origin; + module:log("info", "%s replied with an error: %s %s", stanza.attr.from, stanza:get_error()); + return true; +end);