transit: allow 127.0.0.1 if that's all we've got

The appveyor tests were failing because their VMs only have 127.0.0.1,
and stripping it out resulted in an empty hint list, which meant Transit
couldn't work at all.
This commit is contained in:
Brian Warner 2016-06-03 18:22:53 -07:00
parent 55f2fcc3a7
commit 682fe0ae2c

View File

@ -597,8 +597,14 @@ class Common:
if self._no_listen or self._tor_manager:
return ([], None)
portnum = allocate_tcp_port()
addresses = ipaddrs.find_addresses()
non_loopback_addresses = [a for a in addresses if a != "127.0.0.1"]
if non_loopback_addresses:
# some test hosts, including the appveyor VMs, *only* have
# 127.0.0.1, and the tests will hang badly if we remove it.
addresses = non_loopback_addresses
direct_hints = [DirectTCPV1Hint(six.u(addr), portnum)
for addr in ipaddrs.find_addresses()]
for addr in addresses]
ep = endpoints.serverFromString(reactor, "tcp:%d" % portnum)
return direct_hints, ep
@ -612,11 +618,10 @@ class Common:
hints = []
direct_hints = yield self._get_direct_hints()
for dh in direct_hints:
if dh.hostname != '127.0.0.1':
hints.append({u"type": u"direct-tcp-v1",
u"hostname": dh.hostname,
u"port": dh.port, # integer
})
hints.append({u"type": u"direct-tcp-v1",
u"hostname": dh.hostname,
u"port": dh.port, # integer
})
for relay in self._transit_relays:
rhint = {u"type": u"relay-v1", u"hints": []}
for rh in relay.hints: