[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
3 changed files with 57 additions and 28 deletions
|
@ -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.')],
|
'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],
|
'notify_on_file_complete': [opt_bool, True],
|
||||||
'file_transfers_port': [opt_int, 28011],
|
'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, ''],
|
'conversation_font': [opt_str, ''],
|
||||||
'use_kib_mib': [opt_bool, False, _('IEC standard says KiB = 1024 bytes, KB = 1000 bytes.')],
|
'use_kib_mib': [opt_bool, False, _('IEC standard says KiB = 1024 bytes, KB = 1000 bytes.')],
|
||||||
'notify_on_all_muc_messages': [opt_bool, False],
|
'notify_on_all_muc_messages': [opt_bool, False],
|
||||||
|
|
|
@ -133,7 +133,7 @@ class ConnectionBytestream:
|
||||||
if type(self.peerhost) != tuple:
|
if type(self.peerhost) != tuple:
|
||||||
return
|
return
|
||||||
port = gajim.config.get('file_transfers_port')
|
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,
|
cfg_proxies = gajim.config.get_per('accounts', self.name,
|
||||||
'file_transfer_proxies')
|
'file_transfer_proxies')
|
||||||
if receiver is None:
|
if receiver is None:
|
||||||
|
@ -168,14 +168,16 @@ class ConnectionBytestream:
|
||||||
sha_str = helpers.get_auth_sha(file_props['sid'], sender,
|
sha_str = helpers.get_auth_sha(file_props['sid'], sender,
|
||||||
receiver)
|
receiver)
|
||||||
file_props['sha_str'] = sha_str
|
file_props['sha_str'] = sha_str
|
||||||
if not ft_override_host_to_send:
|
ft_add_hosts = []
|
||||||
ft_override_host_to_send = self.peerhost[0]
|
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:
|
try:
|
||||||
ft_override_host_to_send = socket.gethostbyname(
|
ft_host = socket.gethostbyname(ft_host)
|
||||||
ft_override_host_to_send)
|
ft_add_hosts.append(ft_host)
|
||||||
except socket.gaierror:
|
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.')))
|
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))
|
||||||
ft_override_host_to_send = self.peerhost[0]
|
|
||||||
listener = gajim.socks5queue.start_listener(port,
|
listener = gajim.socks5queue.start_listener(port,
|
||||||
sha_str, self._result_socks5_sid, file_props['sid'])
|
sha_str, self._result_socks5_sid, file_props['sid'])
|
||||||
if listener == None:
|
if listener == None:
|
||||||
|
@ -194,10 +196,25 @@ class ConnectionBytestream:
|
||||||
query.setNamespace(common.xmpp.NS_BYTESTREAM)
|
query.setNamespace(common.xmpp.NS_BYTESTREAM)
|
||||||
query.setAttr('mode', 'tcp')
|
query.setAttr('mode', 'tcp')
|
||||||
query.setAttr('sid', file_props['sid'])
|
query.setAttr('sid', file_props['sid'])
|
||||||
streamhost = query.setTag('streamhost')
|
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('port', unicode(port))
|
||||||
streamhost.setAttr('host', ft_override_host_to_send)
|
streamhost.setAttr('host', thehost)
|
||||||
streamhost.setAttr('jid', sender)
|
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',
|
if fast and proxyhosts != [] and gajim.config.get_per('accounts',
|
||||||
self.name, 'use_ft_proxies'):
|
self.name, 'use_ft_proxies'):
|
||||||
file_props['proxy_receiver'] = unicode(receiver)
|
file_props['proxy_receiver'] = unicode(receiver)
|
||||||
|
|
|
@ -215,7 +215,7 @@ class ConnectionBytestream:
|
||||||
if type(self.peerhost) != tuple:
|
if type(self.peerhost) != tuple:
|
||||||
return
|
return
|
||||||
port = gajim.config.get('file_transfers_port')
|
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:
|
if receiver is None:
|
||||||
receiver = file_props['receiver']
|
receiver = file_props['receiver']
|
||||||
if sender is None:
|
if sender is None:
|
||||||
|
@ -224,14 +224,16 @@ class ConnectionBytestream:
|
||||||
sha_str = helpers.get_auth_sha(file_props['sid'], sender,
|
sha_str = helpers.get_auth_sha(file_props['sid'], sender,
|
||||||
receiver)
|
receiver)
|
||||||
file_props['sha_str'] = sha_str
|
file_props['sha_str'] = sha_str
|
||||||
if not ft_override_host_to_send:
|
ft_add_hosts = []
|
||||||
ft_override_host_to_send = self.peerhost[0]
|
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:
|
try:
|
||||||
ft_override_host_to_send = socket.gethostbyname(
|
ft_host = socket.gethostbyname(ft_host)
|
||||||
ft_override_host_to_send)
|
ft_add_hosts.append(ft_host)
|
||||||
except socket.gaierror:
|
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.')))
|
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))
|
||||||
ft_override_host_to_send = self.peerhost[0]
|
|
||||||
listener = gajim.socks5queue.start_listener(port,
|
listener = gajim.socks5queue.start_listener(port,
|
||||||
sha_str, self._result_socks5_sid, file_props['sid'])
|
sha_str, self._result_socks5_sid, file_props['sid'])
|
||||||
if listener == None:
|
if listener == None:
|
||||||
|
@ -250,9 +252,19 @@ class ConnectionBytestream:
|
||||||
query.setNamespace(common.xmpp.NS_BYTESTREAM)
|
query.setNamespace(common.xmpp.NS_BYTESTREAM)
|
||||||
query.setAttr('mode', 'tcp')
|
query.setAttr('mode', 'tcp')
|
||||||
query.setAttr('sid', file_props['sid'])
|
query.setAttr('sid', file_props['sid'])
|
||||||
streamhost = query.setTag('streamhost')
|
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('port', unicode(port))
|
||||||
streamhost.setAttr('host', ft_override_host_to_send)
|
streamhost.setAttr('host', thehost)
|
||||||
streamhost.setAttr('jid', sender)
|
streamhost.setAttr('jid', sender)
|
||||||
self.connection.send(iq)
|
self.connection.send(iq)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue