Philipp Hörist pushed to branch master at gajim / gajim
Commits:
55e82cc6 by lovetox at 2020-05-30T21:49:23+02:00
Fix discovering local address for file transfer
Fixes #10016
- - - - -
3 changed files:
- gajim/common/client.py
- gajim/common/jingle_transport.py
- gajim/common/modules/bytestream.py
Changes:
=====================================
gajim/common/client.py
=====================================
@@ -129,6 +129,13 @@ class Client(ConnectionHandlers):
def features(self):
return self._client.features
+ @property
+ def local_address(self):
+ address = self._client.local_address
+ if address is not None:
+ return address.to_string().split(':')[0]
+ return None
+
def set_remove_account(self, value):
# Used by the RemoveAccount Assistant to make the Client
# not react to any stream errors that happen while the
=====================================
gajim/common/jingle_transport.py
=====================================
@@ -198,16 +198,21 @@ class JingleTransportSocks5(JingleTransport):
hosts = set()
local_ip_cand = []
- candidate = {
- 'host': self.connection.peerhost[0],
- 'candidate_id': generate_id(),
- 'port': port,
- 'type': 'direct',
- 'jid': self.ourjid,
- 'priority': priority
- }
- hosts.add(self.connection.peerhost[0])
- local_ip_cand.append(candidate)
+ my_ip = self.connection.local_address
+ if my_ip is None:
+ log.warning('No local address available')
+
+ else:
+ candidate = {
+ 'host': my_ip,
+ 'candidate_id': generate_id(),
+ 'port': port,
+ 'type': 'direct',
+ 'jid': self.ourjid,
+ 'priority': priority
+ }
+ hosts.add(my_ip)
+ local_ip_cand.append(candidate)
try:
for addrinfo in socket.getaddrinfo(socket.gethostname(), None):
=====================================
gajim/common/modules/bytestream.py
=====================================
@@ -303,9 +303,15 @@ class Bytestream(BaseModule):
self._account,
'ft_send_local_ips'):
return
+
+ my_ip = self._con.local_address
+ if my_ip is None:
+ log.warning('No local address available')
+ return
+
try:
# The ip we're connected to server with
- my_ips = [self._con.peerhost[0]]
+ my_ips = [my_ip]
# all IPs from local DNS
for addr in socket.getaddrinfo(socket.gethostname(), None):
if (not addr[4][0] in my_ips and
@@ -333,12 +339,12 @@ class Bytestream(BaseModule):
self._add_streamhosts_to_query(query, sender, port, add_hosts)
def _add_upnp_igd_as_streamhost_to_query(self, query, file_props, iq):
- if not app.is_installed('UPNP'):
+ my_ip = self._con.local_address
+ if my_ip is None or not app.is_installed('UPNP'):
+ log.warning('No local address available')
self._con.connection.send(iq)
return
- my_ip = self._con.peerhost[0]
-
# check if we are connected with an IPv4 address
try:
socket.inet_aton(my_ip)
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/55e82cc6e5b0b0ba820f7834862c52d8cf17d5f7
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/55e82cc6e5b0b0ba820f7834862c52d8cf17d5f7
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits