[tor-commits] [sbws/master] fix: scanner: Return from measure if no helper

juga at torproject.org juga at torproject.org
Tue Mar 2 11:24:06 UTC 2021


commit 9d7ee9785a6363e125ce1b0aa26e22fbe191dc7e
Author: juga0 <juga at riseup.net>
Date:   Sat Feb 27 11:00:02 2021 +0000

    fix: scanner: Return from measure if no helper
    
    After refactoring in #40041, it was forgotten to return the error in
    the case a helper was not found, what can happen in test networks.
    
    Closes #40065.
---
 sbws/core/scanner.py | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/sbws/core/scanner.py b/sbws/core/scanner.py
index 5fd917a..f9ab1ce 100644
--- a/sbws/core/scanner.py
+++ b/sbws/core/scanner.py
@@ -346,11 +346,15 @@ def measure_relay(args, conf, destinations, cb, rl, relay):
     # Instead of ensuring that the relay can exit to all IPs, try first with
     # the relay as an exit, if it can exit to some IPs.
     if relay.is_exit_not_bad_allowing_port(dest.port):
-        circ_fps, nicknames, exit_policy = \
-            create_path_relay(relay, dest, rl, cb, relay_as_entry=False)
+        r = create_path_relay(relay, dest, rl, cb, relay_as_entry=False)
     else:
-        circ_fps, nicknames, exit_policy = \
-            create_path_relay(relay, dest, rl, cb)
+        r = create_path_relay(relay, dest, rl, cb)
+    # When `error_no_helper` is triggered because a helper is not found, what
+    # can happen in test networks with very few relays, it returns a list with
+    # the error.
+    if len(r) == 1:
+        return r
+    circ_fps, nicknames, exit_policy = r
 
     # Build the circuit
     circ_id, reason = cb.build_circuit(circ_fps)
@@ -378,8 +382,10 @@ def measure_relay(args, conf, destinations, cb, rl, relay):
             " to connect to %s via circuit %s (%s). Reason: %s. Trying again "
             "with it as entry.", relay.fingerprint, relay.nickname,
             exit_policy, dest.url, circ_fps, nicknames, usable_data)
-        circ_fps, nicknames, exit_policy = \
-            create_path_relay(relay, dest, rl, cb)
+        r = create_path_relay(relay, dest, rl, cb)
+        if len(r) == 1:
+            return r
+        circ_fps, nicknames, exit_policy = r
         circ_id, reason = cb.build_circuit(circ_fps)
         if not circ_id:
             log.warning(





More information about the tor-commits mailing list