From 589c3081bb4e3c8e6ab130892918e40054aeeff9 Mon Sep 17 00:00:00 2001 From: Jefry Lagrange Date: Fri, 21 Sep 2012 17:42:16 -0400 Subject: [PATCH] socks5 proxy supports file request. Raise OutOfOrder exception when we get a candidate and we are not expecting it --- src/common/jingle_ft.py | 15 ++++++++------- src/common/socks5.py | 6 ------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/common/jingle_ft.py b/src/common/jingle_ft.py index c6ee521a8..d2de8f246 100644 --- a/src/common/jingle_ft.py +++ b/src/common/jingle_ft.py @@ -142,7 +142,6 @@ class JingleFileTransfer(JingleContent): } self.session.connection.set_files_info(file_info) - def _calcHash(self): # Caculates the hash and returns a xep-300 hash stanza if self.file_props.algo == None: @@ -222,7 +221,12 @@ class JingleFileTransfer(JingleContent): def __on_transport_info(self, stanza, content, error, action): log.info("__on_transport_info") - if content.getTag('transport').getTag('candidate-error'): + candError = content.getTag('transport').getTag('candidate-error') + candUsed = content.getTag('transport').getTag('candidate-used') + if (candError or candUsed) and \ + self.state >= STATE_CAND_SENT_AND_RECEIVED: + raise xmpp.OutOfOrder + if candError: if not gajim.socks5queue.listener.connections: gajim.socks5queue.listener.disconnect() self.nominated_cand['peer-cand'] = False @@ -242,9 +246,8 @@ class JingleFileTransfer(JingleContent): args = {'candError' : True} self.__state_changed(STATE_CAND_RECEIVED, args) return - if content.getTag('transport').getTag('candidate-used'): - streamhost_cid = content.getTag('transport').getTag( - 'candidate-used').getAttr('cid') + if candUsed: + streamhost_cid = candUsed.getAttr('cid') streamhost_used = None for cand in self.transport.candidates: if cand['candidate_id'] == streamhost_cid: @@ -253,8 +256,6 @@ class JingleFileTransfer(JingleContent): if streamhost_used == None or streamhost_used['type'] == 'proxy': if not gajim.socks5queue.listener.connections: gajim.socks5queue.listener.disconnect() - pass - if content.getTag('transport').getTag('activated'): self.state = STATE_TRANSFERING jid = gajim.get_jid_without_resource(self.session.ourjid) diff --git a/src/common/socks5.py b/src/common/socks5.py index bd7010a77..1d35b4893 100644 --- a/src/common/socks5.py +++ b/src/common/socks5.py @@ -864,12 +864,6 @@ class Socks5: """ Get sha of sid + Initiator jid + Target jid """ - - if self.file_props.is_a_proxy: - self.file_props.is_a_proxy = None # Is this necesary? - return hashlib.sha1('%s%s%s' % (self.sid, - self.file_props.proxy_sender, - self.file_props.proxy_receiver)).hexdigest() return hashlib.sha1('%s%s%s' % (self.sid, self.initiator, self.target)).hexdigest()