Mercurial > libervia-backend
changeset 3652:6e34307319c0
plugin XEP-0353: fix jingle initiation on disco "Service Unavailable" error:
When requesting disco info on a bare jid which is not in our roster, server may return
"Service Unavailable" (to avoid leaking valid JIDs). In this case, the initiation was
failing, this is now fixed by using empty categories in this case.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 08 Sep 2021 11:16:52 +0200 |
parents | 867a15f05476 |
children | d2b17f0f2615 |
files | sat/plugins/plugin_xep_0353.py |
diffstat | 1 files changed, 10 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0353.py Wed Sep 08 11:16:48 2021 +0200 +++ b/sat/plugins/plugin_xep_0353.py Wed Sep 08 11:16:52 2021 +0200 @@ -19,7 +19,7 @@ from zope.interface import implementer from twisted.internet import defer from twisted.internet import reactor -from twisted.words.protocols.jabber import xmlstream, jid +from twisted.words.protocols.jabber import xmlstream, jid, error from twisted.words.xish import domish from wokkel import disco, iwokkel from sat.core.i18n import _, D_ @@ -85,8 +85,15 @@ if peer_jid.resource: return True - infos = await self.host.memory.disco.getInfos(client, peer_jid) - categories = {c for c, __ in infos.identities} + try: + infos = await self.host.memory.disco.getInfos(client, peer_jid) + except error.StanzaError as e: + if e.condition == "service-unavailable": + categories = {} + else: + raise e + else: + categories = {c for c, __ in infos.identities} if "component" in categories: # we don't use message initiation with components return True