changeset 30917:564a96a56b73

zeroconf: fail nicely on IPv6 only system zeroconf only knows how to deal with IPv4; I develop on a system where the only IPv4 address is 127.0.0.1. Teach zeroconf to ignore IPv6 addresses when looking for plausible IPv4 connectivity.
author Simon Farnsworth <simonfar@fb.com>
date Wed, 08 Feb 2017 08:08:41 -0800
parents a68510b69f41
children 2aaa8bfc7bd9
files hgext/zeroconf/__init__.py
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/zeroconf/__init__.py	Mon Feb 06 17:01:06 2017 -0800
+++ b/hgext/zeroconf/__init__.py	Wed Feb 08 08:08:41 2017 -0800
@@ -64,7 +64,9 @@
     # Generic method, sometimes gives useless results
     try:
         dumbip = socket.gethostbyaddr(socket.gethostname())[2][0]
-        if not dumbip.startswith('127.') and ':' not in dumbip:
+        if ':' in dumbip:
+            dumbip = '127.0.0.1'
+        if not dumbip.startswith('127.'):
             return dumbip
     except (socket.gaierror, socket.herror):
         dumbip = '127.0.0.1'