From eaed2f0a1261d67e18854a5cfee445f6f13bf04d Mon Sep 17 00:00:00 2001 From: higs4281 Date: Thu, 2 Jun 2016 19:53:33 -0400 Subject: [PATCH 1/3] Prevent transmit from suggesting `127.0.0.1` The test runs the listener locally, which can turn up 127.0.0.1. The added code in transmit stops the hint. --- src/wormhole/test/test_transit.py | 12 ++++++++++++ src/wormhole/transit.py | 9 +++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/wormhole/test/test_transit.py b/src/wormhole/test/test_transit.py index d8bf7e3..e87136e 100644 --- a/src/wormhole/test/test_transit.py +++ b/src/wormhole/test/test_transit.py @@ -163,6 +163,18 @@ class Basic(unittest.TestCase): self.assertEqual(c._their_direct_hints, []) self.assertEqual(c._their_relay_hints, []) + # @inlineCallbacks + def test_ignore_localhost_hint(self): + # this actually starts the listener + c = transit.TransitSender(u"") + results = [] + d = c.get_connection_hints() + d.addBoth(results.append) + hints = results[0] + c._stop_listening() + for hint in hints: + self.assertFalse(hint[u'hostname'] == u'127.0.0.1') + def test_transit_key_wait(self): KEY = b"123" c = transit.Common(u"") diff --git a/src/wormhole/transit.py b/src/wormhole/transit.py index 9e268e8..3b95d3c 100644 --- a/src/wormhole/transit.py +++ b/src/wormhole/transit.py @@ -612,10 +612,11 @@ class Common: hints = [] direct_hints = yield self._get_direct_hints() for dh in direct_hints: - hints.append({u"type": u"direct-tcp-v1", - u"hostname": dh.hostname, - u"port": dh.port, # integer - }) + if dh.hostname != '127.0.0.1': + 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: From 55f2fcc3a73b8ddd5435d9460c4384a375e7ceeb Mon Sep 17 00:00:00 2001 From: higs4281 Date: Thu, 2 Jun 2016 20:55:50 -0400 Subject: [PATCH 2/3] remove commented line --- src/wormhole/test/test_transit.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/wormhole/test/test_transit.py b/src/wormhole/test/test_transit.py index e87136e..8b17dad 100644 --- a/src/wormhole/test/test_transit.py +++ b/src/wormhole/test/test_transit.py @@ -163,7 +163,6 @@ class Basic(unittest.TestCase): self.assertEqual(c._their_direct_hints, []) self.assertEqual(c._their_relay_hints, []) - # @inlineCallbacks def test_ignore_localhost_hint(self): # this actually starts the listener c = transit.TransitSender(u"") From 682fe0ae2c53151cfb5be909bce57fd48c48efd1 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Fri, 3 Jun 2016 18:22:53 -0700 Subject: [PATCH 3/3] 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: