projects
/
tahoe-lafs
/
tahoe-lafs.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
6176004
)
util.iputil: try to survive not having a global network connection at all
author
Brian Warner
<warner@lothar.com>
Thu, 8 Mar 2007 01:21:42 +0000
(18:21 -0700)
committer
Brian Warner
<warner@lothar.com>
Thu, 8 Mar 2007 01:21:42 +0000
(18:21 -0700)
src/allmydata/util/iputil.py
patch
|
blob
|
history
diff --git
a/src/allmydata/util/iputil.py
b/src/allmydata/util/iputil.py
index 9b87b1c00012e486cd46145a9de774f5811de0d5..bfa5b5f986f30fd9c28fe6a833449c045fa8ecde 100644
(file)
--- 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)