Mercurial > libervia-backend
comparison sat/plugins/plugin_xep_0353.py @ 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 | 524856bd7b19 |
comparison
equal
deleted
inserted
replaced
3651:867a15f05476 | 3652:6e34307319c0 |
---|---|
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 17 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
18 | 18 |
19 from zope.interface import implementer | 19 from zope.interface import implementer |
20 from twisted.internet import defer | 20 from twisted.internet import defer |
21 from twisted.internet import reactor | 21 from twisted.internet import reactor |
22 from twisted.words.protocols.jabber import xmlstream, jid | 22 from twisted.words.protocols.jabber import xmlstream, jid, error |
23 from twisted.words.xish import domish | 23 from twisted.words.xish import domish |
24 from wokkel import disco, iwokkel | 24 from wokkel import disco, iwokkel |
25 from sat.core.i18n import _, D_ | 25 from sat.core.i18n import _, D_ |
26 from sat.core.constants import Const as C | 26 from sat.core.constants import Const as C |
27 from sat.core import exceptions | 27 from sat.core import exceptions |
83 # FIXME: check that at least one resource of the peer_jid can handle the feature | 83 # FIXME: check that at least one resource of the peer_jid can handle the feature |
84 peer_jid = session['peer_jid'] | 84 peer_jid = session['peer_jid'] |
85 if peer_jid.resource: | 85 if peer_jid.resource: |
86 return True | 86 return True |
87 | 87 |
88 infos = await self.host.memory.disco.getInfos(client, peer_jid) | 88 try: |
89 categories = {c for c, __ in infos.identities} | 89 infos = await self.host.memory.disco.getInfos(client, peer_jid) |
90 except error.StanzaError as e: | |
91 if e.condition == "service-unavailable": | |
92 categories = {} | |
93 else: | |
94 raise e | |
95 else: | |
96 categories = {c for c, __ in infos.identities} | |
90 if "component" in categories: | 97 if "component" in categories: |
91 # we don't use message initiation with components | 98 # we don't use message initiation with components |
92 return True | 99 return True |
93 | 100 |
94 if peer_jid.userhostJID() not in client.roster: | 101 if peer_jid.userhostJID() not in client.roster: |