fix sending file over XTLS encrypted socket
This commit is contained in:
parent
565d44a5b7
commit
c903b9d5d1
|
@ -128,6 +128,7 @@ class JingleFileTransfer(JingleContent):
|
||||||
self.state = nextstate
|
self.state = nextstate
|
||||||
|
|
||||||
def __on_session_initiate(self, stanza, content, error, action):
|
def __on_session_initiate(self, stanza, content, error, action):
|
||||||
|
log.debug("Jingle FT request received")
|
||||||
gajim.nec.push_incoming_event(FileRequestReceivedEvent(None,
|
gajim.nec.push_incoming_event(FileRequestReceivedEvent(None,
|
||||||
conn=self.session.connection, stanza=stanza, jingle_content=content,
|
conn=self.session.connection, stanza=stanza, jingle_content=content,
|
||||||
FT_content=self))
|
FT_content=self))
|
||||||
|
|
|
@ -82,6 +82,7 @@ class SocksQueue:
|
||||||
Start waiting for incomming connections on (host, port) and do a socks5
|
Start waiting for incomming connections on (host, port) and do a socks5
|
||||||
authentication using sid for generated SHA
|
authentication using sid for generated SHA
|
||||||
"""
|
"""
|
||||||
|
log.debug('Start listening for socks5 connection')
|
||||||
sid = file_props.sid
|
sid = file_props.sid
|
||||||
self.sha_handlers[sha_str] = (sha_handler, sid)
|
self.sha_handlers[sha_str] = (sha_handler, sid)
|
||||||
if self.listener is None or self.listener.connections == []:
|
if self.listener is None or self.listener.connections == []:
|
||||||
|
@ -131,11 +132,13 @@ class SocksQueue:
|
||||||
else:
|
else:
|
||||||
fp = fingerprint
|
fp = fingerprint
|
||||||
if receiving:
|
if receiving:
|
||||||
|
log.debug('Trying to connect as receiver to cid ' + streamhost['cid'])
|
||||||
file_props.type_ = 'r'
|
file_props.type_ = 'r'
|
||||||
socks5obj = Socks5ReceiverClient(self.idlequeue, streamhost,
|
socks5obj = Socks5ReceiverClient(self.idlequeue, streamhost,
|
||||||
sid, file_props, fingerprint=fp)
|
sid, file_props, fingerprint=fp)
|
||||||
self.add_sockobj(account, socks5obj)
|
self.add_sockobj(account, socks5obj)
|
||||||
else:
|
else:
|
||||||
|
log.debug('Trying to connect as sender to cid' + streamhost['cid'])
|
||||||
if file_props.sha_str:
|
if file_props.sha_str:
|
||||||
idx = file_props.sha_str
|
idx = file_props.sha_str
|
||||||
else:
|
else:
|
||||||
|
@ -162,6 +165,7 @@ class SocksQueue:
|
||||||
Called when there is a host connected to one of the senders's
|
Called when there is a host connected to one of the senders's
|
||||||
streamhosts. Stop other attempts for connections
|
streamhosts. Stop other attempts for connections
|
||||||
"""
|
"""
|
||||||
|
log.debug('Connected to cid ' + streamhost['cid'])
|
||||||
for host in file_props.streamhosts:
|
for host in file_props.streamhosts:
|
||||||
if host != streamhost and 'idx' in host:
|
if host != streamhost and 'idx' in host:
|
||||||
if host['state'] == 1:
|
if host['state'] == 1:
|
||||||
|
@ -223,6 +227,7 @@ class SocksQueue:
|
||||||
"""
|
"""
|
||||||
Called when we loose connection during transfer
|
Called when we loose connection during transfer
|
||||||
"""
|
"""
|
||||||
|
log.debug('Connection refused to cid ' + streamhost['cid'])
|
||||||
if file_props is None:
|
if file_props is None:
|
||||||
return
|
return
|
||||||
streamhost['state'] = -1
|
streamhost['state'] = -1
|
||||||
|
@ -540,6 +545,7 @@ class Socks5(object):
|
||||||
return 1 # we are connected
|
return 1 # we are connected
|
||||||
|
|
||||||
def read_timeout(self):
|
def read_timeout(self):
|
||||||
|
print('read_timeout')
|
||||||
self.idlequeue.remove_timeout(self.fd)
|
self.idlequeue.remove_timeout(self.fd)
|
||||||
if self.state > 5:
|
if self.state > 5:
|
||||||
# no activity for foo seconds
|
# no activity for foo seconds
|
||||||
|
@ -649,7 +655,6 @@ class Socks5(object):
|
||||||
def write_next(self):
|
def write_next(self):
|
||||||
if self.remaining_buff != b'':
|
if self.remaining_buff != b'':
|
||||||
buff = self.remaining_buff
|
buff = self.remaining_buff
|
||||||
self.remaining_buff = b''
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
self.open_file_for_reading()
|
self.open_file_for_reading()
|
||||||
|
@ -743,6 +748,7 @@ class Socks5(object):
|
||||||
raise e
|
raise e
|
||||||
except Exception:
|
except Exception:
|
||||||
buff = b''
|
buff = b''
|
||||||
|
print('received ' + str(len(buff)))
|
||||||
current_time = self.idlequeue.current_time()
|
current_time = self.idlequeue.current_time()
|
||||||
self.file_props.elapsed_time += current_time - \
|
self.file_props.elapsed_time += current_time - \
|
||||||
self.file_props.last_time
|
self.file_props.last_time
|
||||||
|
|
Loading…
Reference in New Issue