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

[tor-commits] [stem/master] Dropping unknown_flags attribute



commit 0752e699fcfb657eb27ed97e0b188376cd9368a1
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sun Aug 19 21:47:06 2012 -0700

    Dropping unknown_flags attribute
    
    I suggested an unknown_flags attribute that would have flags which stem didn't
    recognize but, on reflection, this wasn't a very good idea. Splitting the
    attributes mean that users have multiple places to look for the relay's flags.
    
    We were also failing validation if there were any unknown flags and that is
    definitely wrong. New flags are perfectly valid and will happen in the future -
    those new flags should not break stem's parser. This was probably confusion
    from when I asked for the cached-consensus test to check for new flags. This is
    something separate and added it with this change.
---
 stem/descriptor/networkstatus.py       |   11 -----------
 test/integ/descriptor/networkstatus.py |    7 +++++++
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/stem/descriptor/networkstatus.py b/stem/descriptor/networkstatus.py
index b48c0df..b7a1b2f 100644
--- a/stem/descriptor/networkstatus.py
+++ b/stem/descriptor/networkstatus.py
@@ -447,7 +447,6 @@ class RouterStatusEntry(stem.descriptor.Descriptor):
   :var int dirport: **\*** router's DirPort
   
   :var list flags: **\*** list of status flags
-  :var list unknown_flags: **\*** list of unidentified status flags
   
   :var :class:`stem.version.Version`,str version: Version of the Tor protocol this router is running
   
@@ -487,7 +486,6 @@ class RouterStatusEntry(stem.descriptor.Descriptor):
     self.dirport = None
     
     self.flags = []
-    self.unknown_flags = []
     
     self.version = None
     
@@ -534,10 +532,6 @@ class RouterStatusEntry(stem.descriptor.Descriptor):
         # s Named Running Stable Valid
         #A series of space-separated status flags, in *lexical order*
         self.flags = line.split(" ")
-        
-        self.unknown_flags = filter(lambda f: not f in Flag, self.flags)
-        if validate and self.unknown_flags:
-          raise ValueError("Router contained unknown flags: %s", " ".join(self.unknown_flags))
       
       elif peek_check_kw("v"):
         if "v" in seen_keywords: raise ValueError("Invalid router descriptor: 'v' line appears twice")
@@ -647,7 +641,6 @@ class RouterMicrodescriptor(RouterStatusEntry):
   :var int dirport: **\*** router's DirPort
   
   :var list flags: **\*** list of status flags
-  :var list unknown_flags: **\*** list of unidentified status flags
   
   :var :class:`stem.version.Version`,str version: Version of the Tor protocol this router is running
   
@@ -708,10 +701,6 @@ class RouterMicrodescriptor(RouterStatusEntry):
         # s Named Running Stable Valid
         #A series of space-separated status flags, in *lexical order*
         self.flags = line.split(" ")
-        
-        self.unknown_flags = filter(lambda f: not f in Flag, self.flags)
-        if validate and self.unknown_flags:
-          raise ValueError("Router contained unknown flags: %s", " ".join(self.unknown_flags))
       
       elif peek_check_kw("v"):
         if "v" in seen_keywords: raise ValueError("Invalid router descriptor: 'v' line appears twice")
diff --git a/test/integ/descriptor/networkstatus.py b/test/integ/descriptor/networkstatus.py
index 621bb14..040a710 100644
--- a/test/integ/descriptor/networkstatus.py
+++ b/test/integ/descriptor/networkstatus.py
@@ -44,6 +44,13 @@ class TestNetworkStatus(unittest.TestCase):
           self.fail()
         assert desc.nickname # check that the router has a nickname
         count += 1
+        
+        # check if there's any unknown flags
+        for flag in desc.flags:
+          if not flag in stem.descriptor.networkstatus.Flag:
+            # TODO: this should be a special 'new capability' check later
+            # rather than failing the tests
+            raise ValueError("Unrecognized flag type: %s, found on relay %s (%s)" % (flag, desc.fingerprint, desc.nickname))
     
     assert count > 100 # sanity check - assuming atleast 100 relays in the Tor network
   



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