Mercurial > prosody-modules
comparison mod_restrict_federation/mod_restrict_federation.lua @ 6544:981c14bb8975
mod_restrict_federation: Allow some ad-hoc commands used by push services
This fixes push registration for Siskin, Conversations and Snikket Android+iOS
when used by restricted accounts.
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Thu, 21 May 2026 18:32:31 +0100 |
| parents | ba2c344e1bdd |
| children | cfcd2d2f7119 |
comparison
equal
deleted
inserted
replaced
| 6543:19bee2a6436a | 6544:981c14bb8975 |
|---|---|
| 15 if module:may("xmpp:federate", event) then | 15 if module:may("xmpp:federate", event) then |
| 16 -- Pass through | 16 -- Pass through |
| 17 return; | 17 return; |
| 18 end | 18 end |
| 19 | 19 |
| 20 if stanza.name == "iq" then | |
| 21 if stanza.attr.type == "result" or stanza.attr.type == "error" then | |
| 22 -- Allow responses to iqs | |
| 23 return; | |
| 24 end | |
| 25 local payload = stanza.tags[1]; | |
| 26 -- Allow push notification registration | |
| 27 if payload.name == "command" and payload.attr.xmlns == "http://jabber.org/protocol/commands" then | |
| 28 -- This should allow Tigase and p2 ad-hoc commands to pass through to push gateways | |
| 29 if node:match("^register%-") or node:match("^unregister%-") then | |
| 30 return; | |
| 31 end | |
| 32 end | |
| 33 end | |
| 34 | |
| 35 | |
| 20 -- Block | 36 -- Block |
| 21 module:log("debug", "Forbidding outgoing %s stanza from <%s> to <%s>", stanza.name, stanza.attr.from, stanza.attr.to); | 37 module:log("debug", "Forbidding outgoing %s stanza from <%s> to <%s>", stanza.name, stanza.attr.from, stanza.attr.to); |
| 22 local err_reply = st.error_reply(event.stanza, "auth", "policy-violation", "Communication with remote domains is not permitted"); | 38 local err_reply = st.error_reply(event.stanza, "auth", "policy-violation", "Communication with remote domains is not permitted"); |
| 23 origin.send(err_reply); | 39 origin.send(err_reply); |
| 24 return true; | 40 return true; |
| 29 | 45 |
| 30 if origin.type ~= "s2sin" then | 46 if origin.type ~= "s2sin" then |
| 31 -- We only filter incoming traffic from remote domains | 47 -- We only filter incoming traffic from remote domains |
| 32 -- Pass through | 48 -- Pass through |
| 33 return; | 49 return; |
| 50 end | |
| 51 | |
| 52 if stanza.name == "iq" then | |
| 53 if stanza.attr.type == "result" or stanza.attr.type == "error" then | |
| 54 -- Allow responses to iqs | |
| 55 return; | |
| 56 end | |
| 34 end | 57 end |
| 35 | 58 |
| 36 local recipient_username = jid_node(stanza.attr.to); | 59 local recipient_username = jid_node(stanza.attr.to); |
| 37 if not recipient_username then | 60 if not recipient_username then |
| 38 return; | 61 return; |
