[tor-commits] [arm/master] Replacing TorCtl descriptor calls

atagar at torproject.org atagar at torproject.org
Mon Dec 17 04:25:17 UTC 2012


commit a868f374dae40a5bfa8ae8951aee21ee0dc0bc01
Author: Damian Johnson <atagar at torproject.org>
Date:   Sun Dec 16 19:09:04 2012 -0800

    Replacing TorCtl descriptor calls
    
    Oops, missing a use of our TorCtl controller connection. This was a kinda
    screwy call - we were checking the 'down' attribute of a TorCtl Router class.
    This attribute seems to be True if...
    
    * the router lacks the Running flag
    * is hibernating
    * is Valid but lacks an observed bandwidth
    
    I'm not quite sure why I ever used this attribute. Just checking for the
    Running flag and calling it good. We can check for other criteria if it makes
    sense for the use case later.
---
 src/util/torTools.py |   14 ++++----------
 1 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/src/util/torTools.py b/src/util/torTools.py
index 056c454..5ac29ea 100644
--- a/src/util/torTools.py
+++ b/src/util/torTools.py
@@ -1748,17 +1748,11 @@ class Controller(TorCtl.PostEventListener):
     
     for entryPort, entryFingerprint in list(potentialMatches):
       try:
-        nsCall = self.conn.get_network_status("id/%s" % entryFingerprint)
-        if not nsCall: raise TorCtl.ErrorReply() # network consensus couldn't be fetched
-        nsEntry = nsCall[0]
+        nsEntry = self.controller.get_network_status(entryFingerprint)
         
-        descEntry = self.getInfo("desc/id/%s" % entryFingerprint, None)
-        if not descEntry: raise TorCtl.ErrorReply() # relay descriptor couldn't be fetched
-        descLines = descEntry.split("\n")
-        
-        isDown = TorCtl.Router.build_from_desc(descLines, nsEntry).down
-        if isDown: potentialMatches.remove((entryPort, entryFingerprint))
-      except (socket.error, TorCtl.ErrorReply, TorCtl.TorCtlClosed): pass
+        if not stem.descriptor.RUNNING in nsEntry.flags:
+          potentialMatches.remove((entryPort, entryFingerprint))
+      except stem.ControllerError: pass
     
     if len(potentialMatches) == 1:
       return potentialMatches[0][1]





More information about the tor-commits mailing list