Mercurial > libervia-backend
diff libervia/backend/plugins/plugin_xep_0260.py @ 4180:b86912d3fd33
plugin IP: fix use of legacy URL + coroutine use:
An https:/salut-a-toi.org URL was used to retrieve external IP, but it's not valid
anymore, resulting in an exception. This feature is currently disabled.
Also moved several methods from legacy inline callbacks to coroutines.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 09 Dec 2023 14:30:54 +0100 |
parents | 4b842c1fb686 |
children | e11b13418ba6 |
line wrap: on
line diff
--- a/libervia/backend/plugins/plugin_xep_0260.py Sat Dec 09 14:05:02 2023 +0100 +++ b/libervia/backend/plugins/plugin_xep_0260.py Sat Dec 09 14:30:54 2023 +0100 @@ -134,8 +134,7 @@ candidate_elt["type"] = candidate.type return transport_elt - @defer.inlineCallbacks - def jingle_session_init(self, client, session, content_name): + async def jingle_session_init(self, client, session, content_name): content_data = session["contents"][content_name] transport_data = content_data["transport_data"] sid = transport_data["sid"] = str(uuid.uuid4()) @@ -146,14 +145,14 @@ session["peer_jid"], session["local_jid"], sid ) # requester and target are inversed for peer candidates transport_data["stream_d"] = self._s5b.register_hash(client, session_hash, None) - candidates = transport_data["candidates"] = yield self._s5b.get_candidates( + candidates = transport_data["candidates"] = await self._s5b.get_candidates( client, session["local_jid"]) mode = "tcp" # XXX: we only manage tcp for now transport_elt = self._build_candidates( session, candidates, sid, session_hash, client, mode ) - defer.returnValue(transport_elt) + return transport_elt def _proxy_activated_cb(self, iq_result_elt, client, candidate, session, content_name): """Called when activation confirmation has been received from proxy @@ -398,8 +397,7 @@ else: activation_d.errback(ProxyError()) - @defer.inlineCallbacks - def jingle_handler(self, client, action, session, content_name, transport_elt): + async def jingle_handler(self, client, action, session, content_name, transport_elt): content_data = session["contents"][content_name] transport_data = content_data["transport_data"] @@ -451,7 +449,7 @@ d.addCallback( self._found_peer_candidate, session, transport_data, content_name, client ) - candidates = yield self._s5b.get_candidates(client, session["local_jid"]) + candidates = await self._s5b.get_candidates(client, session["local_jid"]) # we remove duplicate candidates candidates = [ candidate for candidate in candidates if candidate not in peer_candidates @@ -493,7 +491,7 @@ else: log.warning("FIXME: unmanaged action {}".format(action)) - defer.returnValue(transport_elt) + return transport_elt def jingle_terminate(self, client, action, session, content_name, reason_elt): if reason_elt.decline: