From: Brian Warner Date: Thu, 8 Mar 2007 01:21:42 +0000 (-0700) Subject: util.iputil: try to survive not having a global network connection at all X-Git-Url: https://git.rkrishnan.org/vdrive/%22file:/frontends/%22doc.html/reliability?a=commitdiff_plain;h=f2956c257b7f0066f43946e30f246e642e75fd6b;p=tahoe-lafs%2Ftahoe-lafs.git util.iputil: try to survive not having a global network connection at all --- diff --git a/src/allmydata/util/iputil.py b/src/allmydata/util/iputil.py index 9b87b1c0..bfa5b5f9 100644 --- a/src/allmydata/util/iputil.py +++ b/src/allmydata/util/iputil.py @@ -11,7 +11,10 @@ def get_local_ip_for(target='A.ROOT-SERVERS.NET'): Returns a string that holds the IP address which could be used by 'target' to connect to us. It might work for them, it might not. """ - target_ipaddr = socket.gethostbyname(target) + try: + target_ipaddr = socket.gethostbyname(target) + except socket.gaierror: + return "127.0.0.1" udpprot = DatagramProtocol() port = reactor.listenUDP(0, udpprot) udpprot.transport.connect(target_ipaddr, 7)