From 938593952d5601216d424825ecfaa906504dba8d Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Thu, 16 Jul 2009 15:29:07 +0200 Subject: [PATCH] detect and send all our local IPs from local DNS. Fixes #4249 --- src/common/connection_handlers.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index ad0003d48..4a0ab8f54 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -227,12 +227,18 @@ class ConnectionBytestream: ostreamhost.setAttr('host', ft_host) ostreamhost.setAttr('jid', sender) 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) + # The ip we're connected to server with + my_ips = [self.peerhost[0]] + # all IPs from local DNS + for addr in socket.getaddrinfo(socket.gethostname(), None): + if not addr[4][0] in my_ips: + my_ips.append(addr[4][0]) + for ip in my_ips: + streamhost = common.xmpp.Node(tag = 'streamhost') + query.addChild(node = streamhost) + streamhost.setAttr('port', unicode(port)) + streamhost.setAttr('host', ip) + streamhost.setAttr('jid', sender) except socket.gaierror: self.dispatch('ERROR', (_('Wrong host'), _('Invalid local address? :-O')))