[tor-commits] r24542: {arm} Fetching the exit policy from the consensus if available, an (arm/trunk/src/interface/connections)
Damian Johnson
atagar1 at gmail.com
Sun Apr 3 05:04:10 UTC 2011
Author: atagar
Date: 2011-04-03 05:04:10 +0000 (Sun, 03 Apr 2011)
New Revision: 24542
Modified:
arm/trunk/src/interface/connections/connEntry.py
Log:
Fetching the exit policy from the consensus if available, and otherwise falls back to the descriptor. Without this arm was encountering a parsing error with older Tor versions (encountered on 0.2.1.29).
Modified: arm/trunk/src/interface/connections/connEntry.py
===================================================================
--- arm/trunk/src/interface/connections/connEntry.py 2011-04-03 04:16:00 UTC (rev 24541)
+++ arm/trunk/src/interface/connections/connEntry.py 2011-04-03 05:04:10 UTC (rev 24542)
@@ -702,14 +702,32 @@
_, nickname, _, _, pubDate, pubTime, _, orPort, dirPort = firstLineComp[:9]
else: nickname, pubDate, pubTime, orPort, dirPort = "", "", "", "", ""
- flags = nsLines[1][2:]
- microExit = nsLines[3][2:]
+ flags = "unknown"
+ 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 unavailble we'll need the full exit policy which is on the
+ # descriptor (if that's available).
+
+ 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)
+
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" % microExit.replace(",", ", ")
+ lines[5] = "exit policy: %s" % exitPolicy
if descEntry:
torVersion, platform, contact = "", "", ""
More information about the tor-commits
mailing list