From 08590b1f6a880d51751fdcacea6a007ebc568f2e Mon Sep 17 00:00:00 2001 From: Daira Hopwood Date: Tue, 25 Jun 2013 19:51:27 +0100 Subject: [PATCH] iputil.py: simplify address finding code on cygwin. Signed-off-by: Daira Hopwood --- src/allmydata/util/iputil.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/allmydata/util/iputil.py b/src/allmydata/util/iputil.py index c1239f0e..bd1d82f7 100644 --- a/src/allmydata/util/iputil.py +++ b/src/allmydata/util/iputil.py @@ -81,11 +81,11 @@ def get_local_addresses_async(target="198.41.0.4"): # A.ROOT-SERVERS.NET """ addresses = [] local_ip = get_local_ip_for(target) - if local_ip: + if local_ip is not None: addresses.append(local_ip) if sys.platform == "cygwin": - d = _cygwin_hack_find_addresses(target) + d = _cygwin_hack_find_addresses() else: d = _find_addresses_via_config() @@ -211,14 +211,11 @@ def _query(path, args, regex): return addresses -def _cygwin_hack_find_addresses(target): +def _cygwin_hack_find_addresses(): addresses = [] - for h in [target, "localhost", "127.0.0.1",]: - try: - addr = get_local_ip_for(h) - if addr not in addresses: - addresses.append(addr) - except socket.gaierror: - pass + for h in ["localhost", "127.0.0.1",]: + addr = get_local_ip_for(h) + if addr is not None and addr not in addresses: + addresses.append(addr) return defer.succeed(addresses) -- 2.45.2