diff --git a/src/common/protocol/bytestream.py b/src/common/protocol/bytestream.py index 13dddaa20..0b3300e37 100644 --- a/src/common/protocol/bytestream.py +++ b/src/common/protocol/bytestream.py @@ -41,7 +41,7 @@ from common import dataforms from common import ged from common import jingle_xtls from common.file_props import FilesProp -from common.socks5 import Socks5ReceiverClient +from common.socks5 import Socks5SenderClient import logging log = logging.getLogger('gajim.c.p.bytestream') @@ -581,8 +581,8 @@ class ConnectionSocks5Bytestream(ConnectionBytestream): """ if not self.connection or self.connected < 2: return - file_props = FilesProp.getFileProp(self.connection, proxy['sid']) - iq = xmpp.Iq(to=proxy['initiator'], typ='set') + file_props = FilesProp.getFileProp(self.name, proxy['sid']) + iq = xmpp.Iq(to=proxy['initiator'], typ='set') auth_id = "au_" + proxy['sid'] iq.setID(auth_id) query = iq.setTag('query', namespace=xmpp.NS_BYTESTREAM) @@ -721,10 +721,15 @@ class ConnectionSocks5Bytestream(ConnectionBytestream): file_props.streamhost_used = True file_props.streamhosts.append(proxy) file_props.is_a_proxy = True - receiver = Socks5ReceiverClient(gajim.idlequeue, proxy, - file_props.sid, file_props) - proxy['idx'] = receiver.queue_idx - gajim.socks5queue.on_success = self._proxy_auth_ok + idx = gajim.socks5queue.idx + sender = Socks5SenderClient(gajim.idlequeue, idx, + gajim.socks5queue, _sock=None, host=str(proxy['host']), + port=int(proxy['port']), fingerprint=None, + connected=False, file_props=file_props) + sender.streamhost = proxy + gajim.socks5queue.add_sockobj(self.name, sender, 'sender') + proxy['idx'] = sender.queue_idx + gajim.socks5queue.on_success[file_props.sid] = self._proxy_auth_ok raise xmpp.NodeProcessed else: diff --git a/src/common/socks5.py b/src/common/socks5.py index 93c64bf94..5ae658313 100644 --- a/src/common/socks5.py +++ b/src/common/socks5.py @@ -263,32 +263,30 @@ class SocksQueue: props[0](props[1], idx) def activate_proxy(self, idx): - if not self.isHashInSockObjs(self.readers, idx): + if not self.isHashInSockObjs(self.senders, idx): return - for key in self.readers.keys(): + for key in self.senders.keys(): if idx in key: - reader = self.readers[key] - if reader.file_props.type_ != 's': + sender = self.senders[key] + if sender.file_props.type_ != 's': return - if reader.state != 5: - return - reader.state = 6 - if reader.connected: - reader.file_props.error = 0 - reader.file_props.disconnect_cb = reader.disconnect - reader.file_props.started = True - reader.file_props.completed = False - reader.file_props.paused = False - reader.file_props.stalled = False - reader.file_props.elapsed_time = 0 - reader.file_props.last_time = self.idlequeue.current_time() - reader.file_props.received_len = 0 - reader.pauses = 0 + sender.state = 6 + if sender.connected: + sender.file_props.error = 0 + sender.file_props.disconnect_cb = sender.disconnect + sender.file_props.started = True + sender.file_props.completed = False + sender.file_props.paused = False + sender.file_props.stalled = False + sender.file_props.elapsed_time = 0 + sender.file_props.last_time = self.idlequeue.current_time() + sender.file_props.received_len = 0 + sender.pauses = 0 # start sending file to proxy - self.idlequeue.set_read_timeout(reader.fd, STALLED_TIMEOUT) - self.idlequeue.plug_idle(reader, True, False) - result = reader.write_next() - self.process_result(result, reader) + self.idlequeue.set_read_timeout(sender.fd, STALLED_TIMEOUT) + self.idlequeue.plug_idle(sender, True, False) + result = sender.write_next() + self.process_result(result, sender) def send_file(self, file_props, account, mode): for key in self.senders.keys():