[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [sbws/master] fix: scanner: extract method on circuit error



commit 53141148f4b82df8e34e2757172e7403791a0c86
Author: juga0 <juga@xxxxxxxxxx>
Date:   Tue Feb 2 12:13:42 2021 +0000

    fix: scanner: extract method on circuit error
    
    At some point all possible errors should be exceptions.
---
 sbws/core/scanner.py | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/sbws/core/scanner.py b/sbws/core/scanner.py
index e18bddb..aa17452 100644
--- a/sbws/core/scanner.py
+++ b/sbws/core/scanner.py
@@ -275,6 +275,15 @@ def create_path_relay_as_exit(relay, dest, rl, cb):
     return circ_fps, nicknames
 
 
+def error_no_circuit(circ_fps, nicknames, reason, relay, dest, our_nick):
+    log.debug('Could not build circuit with path %s (%s): %s ',
+              circ_fps, nicknames, reason)
+    return [
+        ResultErrorCircuit(relay, circ_fps, dest.url, our_nick,
+                           msg=reason),
+    ]
+
+
 def measure_relay(args, conf, destinations, cb, rl, relay):
     """
     Select a Web server, a relay to build the circuit,
@@ -338,12 +347,8 @@ def measure_relay(args, conf, destinations, cb, rl, relay):
         create_path_relay_as_exit(relay, dest, rl, cb)
         circ_id, reason = cb.build_circuit(circ_fps)
     if not circ_id:
-        log.debug('Could not build circuit with path %s (%s): %s ',
-                  circ_fps, nicknames, reason)
-        return [
-            ResultErrorCircuit(relay, circ_fps, dest.url, our_nick,
-                               msg=reason),
-        ]
+        return error_no_circuit(circ_fps, nicknames, reason, relay, dest,
+                                our_nick)
     log.debug('Built circuit with path %s (%s) to measure %s (%s)',
               circ_fps, nicknames, relay.fingerprint, relay.nickname)
     # Make a connection to the destination



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits