plugins (jingle) file transfer: use initial "from" attribute as local jid instead of client.jid:

while client.jid is fine in a client context, for components it's not the right jid to use: it is the jid of the component itself while the file transfer/jingle session entity may be established with this jid + a local part (e.g. if client is files.example.net, session may be established with louise@files.example.net, in which case "from" is louise@files.example.net, while client.jid will be files.example.net).

As a consequence, using client.jid was causing trouble with components.
This patch fixes it for jingle and plugins linked to file transfer by keeping a "local_jid" variable in the session, where the jid from the original "from" attribute is used.
This commit is contained in:
Goffi 2019-04-28 08:55:13 +02:00
commit a3c67e1072

View file

@ -140,13 +140,14 @@ class XEP_0260(object):
transport_data = content_data["transport_data"]
sid = transport_data["sid"] = unicode(uuid.uuid4())
session_hash = transport_data["session_hash"] = self._s5b.getSessionHash(
client.jid, session["peer_jid"], sid
session[u"local_jid"], session["peer_jid"], sid
)
transport_data["peer_session_hash"] = self._s5b.getSessionHash(
session["peer_jid"], client.jid, sid
session["peer_jid"], session[u"local_jid"], sid
) # requester and target are inversed for peer candidates
transport_data["stream_d"] = self._s5b.registerHash(client, session_hash, None)
candidates = transport_data["candidates"] = yield self._s5b.getCandidates(client)
candidates = transport_data["candidates"] = yield self._s5b.getCandidates(
client, session["local_jid"])
mode = "tcp" # XXX: we only manage tcp for now
transport_elt = self._buildCandidates(
session, candidates, sid, session_hash, client, mode
@ -249,7 +250,7 @@ class XEP_0260(object):
log.debug(
u"Candidates have same priority, we select the one choosed by initiator"
)
if session["initiator"] == client.jid:
if session["initiator"] == session[u"local_jid"]:
choosed_candidate = best_candidate
else:
choosed_candidate = peer_best_candidate
@ -425,12 +426,12 @@ class XEP_0260(object):
assert "peer_candidates" not in transport_data
sid = transport_data["sid"] = transport_elt["sid"]
session_hash = transport_data["session_hash"] = self._s5b.getSessionHash(
client.jid, session["peer_jid"], sid
session["local_jid"], session["peer_jid"], sid
)
peer_session_hash = transport_data[
"peer_session_hash"
] = self._s5b.getSessionHash(
session["peer_jid"], client.jid, sid
session["peer_jid"], session["local_jid"], sid
) # requester and target are inversed for peer candidates
peer_candidates = transport_data["peer_candidates"] = self._parseCandidates(
transport_elt
@ -444,7 +445,7 @@ class XEP_0260(object):
d.addCallback(
self._foundPeerCandidate, session, transport_data, content_name, client
)
candidates = yield self._s5b.getCandidates(client)
candidates = yield self._s5b.getCandidates(client, session["local_jid"])
# we remove duplicate candidates
candidates = [
candidate for candidate in candidates if candidate not in peer_candidates