Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions zeroconf/dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,12 @@ def __eq__(self, other):
def __repr__(self):
"""String representation"""
try:
return socket.inet_ntoa(self.address)
return self.toString(socket.inet_ntoa(self.address))
except:
return self.address
try:
return self.toString(socket.inet_ntop(socket.AF_INET6, self.address))
except:
return self.address

class DNSHinfo(DNSRecord):
"""A DNS host information record"""
Expand Down
9 changes: 8 additions & 1 deletion zeroconf/mdns.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,14 @@ def __init__(self, bindaddress=None):
multicast communications, listening and reaping threads."""
globals()['_GLOBAL_DONE'] = 0
if bindaddress is None:
self.intf = socket.gethostbyname(socket.gethostname())
try:
"""Try to find the internet-routing interface so we don't get 127.0.0.1"""
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(('www.google.com',80))
self.intf = s.getsockname()[0]
s.close()
except:
self.intf = socket.gethostbyname(socket.gethostname())
bindaddress = self.intf
else:
self.intf = bindaddress
Expand Down