From 0c3910bafd02567ac0f82d9057107f144703aa78 Mon Sep 17 00:00:00 2001 From: Goffi Date: Wed, 8 Sep 2021 11:16:52 +0200 Subject: [PATCH] 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. --- sat/plugins/plugin_xep_0353.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sat/plugins/plugin_xep_0353.py b/sat/plugins/plugin_xep_0353.py index 5ed87fb7..fd24856f 100644 --- a/sat/plugins/plugin_xep_0353.py +++ b/sat/plugins/plugin_xep_0353.py @@ -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 @@ class XEP_0353: 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