mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-20 05:28:04 +00:00
util.iputil: try to survive not having a global network connection at all
This commit is contained in:
parent
61760047cf
commit
f2956c257b
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user