[Michal Vaner] add ability to send several ip when we do file transfers, and send all local IPs. fixes #2953
This commit is contained in:
parent
b22db5c331
commit
8a0c47e4a0
src/common
|
@ -161,7 +161,7 @@ class Config:
|
|||
'noconfirm_close_muc_rooms': [opt_str, '', _('Never ask before closing group chat tab/window in this space separated list of group chat jids.')],
|
||||
'notify_on_file_complete': [opt_bool, True],
|
||||
'file_transfers_port': [opt_int, 28011],
|
||||
'ft_override_host_to_send': [opt_str, '', _('Overrides the host we send for File Transfer in case of address translation/port forwarding.')],
|
||||
'ft_add_hosts_to_send': [opt_str, '', _('Comma separated list of hosts that we send, in addition of local interfaces, for File Transfer in case of address translation/port forwarding.')],
|
||||
'conversation_font': [opt_str, ''],
|
||||
'use_kib_mib': [opt_bool, False, _('IEC standard says KiB = 1024 bytes, KB = 1000 bytes.')],
|
||||
'notify_on_all_muc_messages': [opt_bool, False],
|
||||
|
|
|
@ -133,7 +133,7 @@ class ConnectionBytestream:
|
|||
if type(self.peerhost) != tuple:
|
||||
return
|
||||
port = gajim.config.get('file_transfers_port')
|
||||
ft_override_host_to_send = gajim.config.get('ft_override_host_to_send')
|
||||
ft_add_hosts_to_send = gajim.config.get('ft_add_hosts_to_send')
|
||||
cfg_proxies = gajim.config.get_per('accounts', self.name,
|
||||
'file_transfer_proxies')
|
||||
if receiver is None:
|
||||
|
@ -168,14 +168,16 @@ class ConnectionBytestream:
|
|||
sha_str = helpers.get_auth_sha(file_props['sid'], sender,
|
||||
receiver)
|
||||
file_props['sha_str'] = sha_str
|
||||
if not ft_override_host_to_send:
|
||||
ft_override_host_to_send = self.peerhost[0]
|
||||
try:
|
||||
ft_override_host_to_send = socket.gethostbyname(
|
||||
ft_override_host_to_send)
|
||||
except socket.gaierror:
|
||||
self.dispatch('ERROR', (_('Wrong host'), _('The host you configured as the ft_override_host_to_send advanced option is not valid, so ignored.')))
|
||||
ft_override_host_to_send = self.peerhost[0]
|
||||
ft_add_hosts = []
|
||||
if ft_add_hosts_to_send:
|
||||
ft_add_hosts_to_send = map(lambda e:e.strip(),
|
||||
ft_add_hosts_to_send.split(','))
|
||||
for ft_host in ft_add_hosts_to_send:
|
||||
try:
|
||||
ft_host = socket.gethostbyname(ft_host)
|
||||
ft_add_hosts.append(ft_host)
|
||||
except socket.gaierror:
|
||||
self.dispatch('ERROR', (_('Wrong host'), _('The host %s you configured as the ft_add_hosts_to_send advanced option is not valid, so ignored.') % ft_host))
|
||||
listener = gajim.socks5queue.start_listener(port,
|
||||
sha_str, self._result_socks5_sid, file_props['sid'])
|
||||
if listener == None:
|
||||
|
@ -194,10 +196,25 @@ class ConnectionBytestream:
|
|||
query.setNamespace(common.xmpp.NS_BYTESTREAM)
|
||||
query.setAttr('mode', 'tcp')
|
||||
query.setAttr('sid', file_props['sid'])
|
||||
streamhost = query.setTag('streamhost')
|
||||
streamhost.setAttr('port', unicode(port))
|
||||
streamhost.setAttr('host', ft_override_host_to_send)
|
||||
streamhost.setAttr('jid', sender)
|
||||
for ft_host in ft_add_hosts:
|
||||
# The streamhost, if set
|
||||
ostreamhost = common.xmpp.Node(tag = 'streamhost')
|
||||
query.addChild(node = ostreamhost)
|
||||
ostreamhost.setAttr('port', unicode(port))
|
||||
ostreamhost.setAttr('host', ft_host)
|
||||
ostreamhost.setAttr('jid', sender)
|
||||
for thehost in self.peerhost:
|
||||
try:
|
||||
thehost = self.peerhost[0]
|
||||
streamhost = common.xmpp.Node(tag = 'streamhost') # My IP
|
||||
query.addChild(node = streamhost)
|
||||
streamhost.setAttr('port', unicode(port))
|
||||
streamhost.setAttr('host', thehost)
|
||||
streamhost.setAttr('jid', sender)
|
||||
except socket.gaierror:
|
||||
self.dispatch('ERROR', (_('Wrong host'),
|
||||
_('Invalid local address? :-O')))
|
||||
|
||||
if fast and proxyhosts != [] and gajim.config.get_per('accounts',
|
||||
self.name, 'use_ft_proxies'):
|
||||
file_props['proxy_receiver'] = unicode(receiver)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
## - Nikos Kouremenos <nkour@jabber.org>
|
||||
## - Dimitur Kirov <dkirov@gmail.com>
|
||||
## - Travis Shirk <travis@pobox.com>
|
||||
## - Stefan Bethge <stefan@lanpartei.de>
|
||||
## - Stefan Bethge <stefan@lanpartei.de>
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published
|
||||
|
@ -215,7 +215,7 @@ class ConnectionBytestream:
|
|||
if type(self.peerhost) != tuple:
|
||||
return
|
||||
port = gajim.config.get('file_transfers_port')
|
||||
ft_override_host_to_send = gajim.config.get('ft_override_host_to_send')
|
||||
ft_add_hosts_to_send = gajim.config.get('ft_add_hosts_to_send')
|
||||
if receiver is None:
|
||||
receiver = file_props['receiver']
|
||||
if sender is None:
|
||||
|
@ -224,14 +224,16 @@ class ConnectionBytestream:
|
|||
sha_str = helpers.get_auth_sha(file_props['sid'], sender,
|
||||
receiver)
|
||||
file_props['sha_str'] = sha_str
|
||||
if not ft_override_host_to_send:
|
||||
ft_override_host_to_send = self.peerhost[0]
|
||||
try:
|
||||
ft_override_host_to_send = socket.gethostbyname(
|
||||
ft_override_host_to_send)
|
||||
except socket.gaierror:
|
||||
self.dispatch('ERROR', (_('Wrong host'), _('The host you configured as the ft_override_host_to_send advanced option is not valid, so ignored.')))
|
||||
ft_override_host_to_send = self.peerhost[0]
|
||||
ft_add_hosts = []
|
||||
if ft_add_hosts_to_send:
|
||||
ft_add_hosts_to_send = map(lambda e:e.strip(),
|
||||
ft_add_hosts_to_send.split(','))
|
||||
for ft_host in ft_add_hosts_to_send:
|
||||
try:
|
||||
ft_host = socket.gethostbyname(ft_host)
|
||||
ft_add_hosts.append(ft_host)
|
||||
except socket.gaierror:
|
||||
self.dispatch('ERROR', (_('Wrong host'), _('The host %s you configured as the ft_add_hosts_to_send advanced option is not valid, so ignored.') % ft_host))
|
||||
listener = gajim.socks5queue.start_listener(port,
|
||||
sha_str, self._result_socks5_sid, file_props['sid'])
|
||||
if listener == None:
|
||||
|
@ -250,10 +252,20 @@ class ConnectionBytestream:
|
|||
query.setNamespace(common.xmpp.NS_BYTESTREAM)
|
||||
query.setAttr('mode', 'tcp')
|
||||
query.setAttr('sid', file_props['sid'])
|
||||
streamhost = query.setTag('streamhost')
|
||||
streamhost.setAttr('port', unicode(port))
|
||||
streamhost.setAttr('host', ft_override_host_to_send)
|
||||
streamhost.setAttr('jid', sender)
|
||||
for ft_host in ft_add_hosts:
|
||||
# The streamhost, if set
|
||||
ostreamhost = common.xmpp.Node(tag = 'streamhost')
|
||||
query.addChild(node = ostreamhost)
|
||||
ostreamhost.setAttr('port', unicode(port))
|
||||
ostreamhost.setAttr('host', ft_host)
|
||||
ostreamhost.setAttr('jid', sender)
|
||||
for thehost in self.peerhost:
|
||||
thehost = self.peerhost[0]
|
||||
streamhost = common.xmpp.Node(tag = 'streamhost') # My IP
|
||||
query.addChild(node = streamhost)
|
||||
streamhost.setAttr('port', unicode(port))
|
||||
streamhost.setAttr('host', thehost)
|
||||
streamhost.setAttr('jid', sender)
|
||||
self.connection.send(iq)
|
||||
|
||||
def send_file_rejection(self, file_props):
|
||||
|
|
Loading…
Reference in New Issue