detect and send all our local IPs from local DNS. Fixes #4249

This commit is contained in:
Yann Leboulanger 2009-07-16 15:29:07 +02:00
parent 50cf012b75
commit 938593952d
1 changed files with 12 additions and 6 deletions

View File

@ -227,12 +227,18 @@ class ConnectionBytestream:
ostreamhost.setAttr('host', ft_host) ostreamhost.setAttr('host', ft_host)
ostreamhost.setAttr('jid', sender) ostreamhost.setAttr('jid', sender)
try: try:
thehost = self.peerhost[0] # The ip we're connected to server with
streamhost = common.xmpp.Node(tag = 'streamhost') # My IP my_ips = [self.peerhost[0]]
query.addChild(node = streamhost) # all IPs from local DNS
streamhost.setAttr('port', unicode(port)) for addr in socket.getaddrinfo(socket.gethostname(), None):
streamhost.setAttr('host', thehost) if not addr[4][0] in my_ips:
streamhost.setAttr('jid', sender) 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: except socket.gaierror:
self.dispatch('ERROR', (_('Wrong host'), self.dispatch('ERROR', (_('Wrong host'),
_('Invalid local address? :-O'))) _('Invalid local address? :-O')))