From 08a5e6043a79098df8a008c74e146142aaf266fc Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Thu, 3 Mar 2016 12:24:58 -0800 Subject: [PATCH] twisted.transit: tolerate the lack of a listener In Tor mode, there is no local listener. Eventually we'll add an Onion Service listener, but it's not guaranteed that we can run one. --- src/wormhole/twisted/transit.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/wormhole/twisted/transit.py b/src/wormhole/twisted/transit.py index 83b1ca3..1f71a5d 100644 --- a/src/wormhole/twisted/transit.py +++ b/src/wormhole/twisted/transit.py @@ -504,6 +504,10 @@ class Common: # listener will win. self._my_direct_hints, self._listener = self._build_listener() + if self._listener is None: # don't listen + self._listener_d = None + return defer.succeed(self._my_direct_hints) # empty + # Start the server, so it will be running by the time anyone tries to # connect to the direct hints we return. f = InboundConnectionFactory(self) @@ -617,7 +621,8 @@ class Common: # have any viable direct hints, then they're either going to succeed # quickly or hang for a long time. contenders = [] - contenders.append(self._listener_d) + if self._listener_d: + contenders.append(self._listener_d) relay_delay = 0 for hint in self._their_direct_hints: