[tor-commits] [arm/release] Replacing displayed consensus policy with util

atagar at torproject.org atagar at torproject.org
Sun Sep 25 21:38:28 UTC 2011


commit aa3e3ee7a397edb18595d86dc2652d63053b3584
Author: Damian Johnson <atagar at torproject.org>
Date:   Mon Sep 12 19:44:58 2011 -0700

    Replacing displayed consensus policy with util
    
    Using the ExitPolicy class' summary rather than the string from the consensus.
    Unless I'm misunderstanding how the consensus policy is derived, these should
    be equivilant. However, since this doesn't rely on the policy being in the
    consensus this will be rendered the same for both new and old versions of tor.
---
 src/cli/connections/connEntry.py |   20 ++++----------------
 1 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/src/cli/connections/connEntry.py b/src/cli/connections/connEntry.py
index 075dfb2..de3fb01 100644
--- a/src/cli/connections/connEntry.py
+++ b/src/cli/connections/connEntry.py
@@ -711,28 +711,16 @@ class ConnectionLine(entries.ConnectionPanelLine):
         if len(nsLines) >= 2 and nsLines[1].startswith("s "):
           flags = nsLines[1][2:]
         
-        # The network status exit policy doesn't exist for older tor versions.
-        # If unavailable we'll need the full exit policy which is on the
-        # descriptor (if that's available).
+        exitPolicy = conn.getRelayExitPolicy(fingerprint)
         
-        exitPolicy = "unknown"
-        if len(nsLines) >= 4 and nsLines[3].startswith("p "):
-          exitPolicy = nsLines[3][2:].replace(",", ", ")
-        elif descEntry:
-          # the descriptor has an individual line for each entry in the exit policy
-          exitPolicyEntries = []
-          
-          for line in descEntry.split("\n"):
-            if line.startswith("accept") or line.startswith("reject"):
-              exitPolicyEntries.append(line.strip())
-          
-          exitPolicy = ", ".join(exitPolicyEntries)
+        if exitPolicy: policyLabel = exitPolicy.getSummary()
+        else: policyLabel = "unknown"
         
         dirPortLabel = "" if dirPort == "0" else "dirport: %s" % dirPort
         lines[2] = "nickname: %-25s orport: %-10s %s" % (nickname, orPort, dirPortLabel)
         lines[3] = "published: %s %s" % (pubDate, pubTime)
         lines[4] = "flags: %s" % flags.replace(" ", ", ")
-        lines[5] = "exit policy: %s" % exitPolicy
+        lines[5] = "exit policy: %s" % policyLabel
       
       if descEntry:
         torVersion, platform, contact = "", "", ""





More information about the tor-commits mailing list