[tor-commits] [stem/master] Referencing a single reject-all policy

atagar at torproject.org atagar at torproject.org
Tue Oct 8 07:50:17 UTC 2013


commit dbee38d1b95d943435cbb6bc989a9a5024b4e8e8
Author: Damian Johnson <atagar at torproject.org>
Date:   Mon Oct 7 23:09:04 2013 -0700

    Referencing a single reject-all policy
    
    Oddly, the only exit policy I can find with greater than five occurances is the
    reject-all policy. Maybe a scripting bug. Reguardless, referencing a single
    reject-all instance saves us a little memory (1.3 MB with the present
    consensus, which is 1.6%).
---
 stem/descriptor/server_descriptor.py |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/stem/descriptor/server_descriptor.py b/stem/descriptor/server_descriptor.py
index 79af0cc..521d07a 100644
--- a/stem/descriptor/server_descriptor.py
+++ b/stem/descriptor/server_descriptor.py
@@ -82,6 +82,7 @@ SINGLE_FIELDS = (
 )
 
 DEFAULT_IPV6_EXIT_POLICY = stem.exit_policy.MicroExitPolicy("reject 1-65535")
+REJECT_ALL_POLICY = stem.exit_policy.ExitPolicy("reject *:*")
 
 
 def _parse_file(descriptor_file, is_bridge = False, validate = True, **kwargs):
@@ -284,7 +285,11 @@ class ServerDescriptor(Descriptor):
 
     entries, policy = _get_descriptor_components(raw_contents, validate, ("accept", "reject"))
 
-    self.exit_policy = stem.exit_policy.ExitPolicy(*policy)
+    if policy == [u'reject *:*']:
+      self.exit_policy = REJECT_ALL_POLICY
+    else:
+      self.exit_policy = stem.exit_policy.ExitPolicy(*policy)
+
     self._parse(entries, validate)
 
     if validate:





More information about the tor-commits mailing list