From 682fe0ae2c53151cfb5be909bce57fd48c48efd1 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Fri, 3 Jun 2016 18:22:53 -0700 Subject: [PATCH] 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. --- src/wormhole/transit.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/wormhole/transit.py b/src/wormhole/transit.py index 3b95d3c..a904be4 100644 --- a/src/wormhole/transit.py +++ b/src/wormhole/transit.py @@ -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: