Merge branch 'pr36'

Closes #36
This commit is contained in:
Brian Warner 2016-06-03 18:24:24 -07:00
commit 3f05cd3007
2 changed files with 18 additions and 1 deletions

View File

@ -163,6 +163,17 @@ class Basic(unittest.TestCase):
self.assertEqual(c._their_direct_hints, [])
self.assertEqual(c._their_relay_hints, [])
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"")

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