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

[or-cvs] r10496: Added ContinentJumperRestriction(PathRestriction) that enfor (torflow/trunk/TorCtl)



Author: renner
Date: 2007-06-04 21:21:28 -0400 (Mon, 04 Jun 2007)
New Revision: 10496

Modified:
   torflow/trunk/TorCtl/PathSupport.py
Log:
  
  Added ContinentJumperRestriction(PathRestriction) that enforces continent crossings 
  between all hops of a path to test if this is bad for performance.
  


Modified: torflow/trunk/TorCtl/PathSupport.py
===================================================================
--- torflow/trunk/TorCtl/PathSupport.py	2007-06-05 01:09:09 UTC (rev 10495)
+++ torflow/trunk/TorCtl/PathSupport.py	2007-06-05 01:21:28 UTC (rev 10496)
@@ -352,6 +352,13 @@
     if crossings > self.n: return False
     else: return True
 
+# Continent crossings between all hops
+class ContinentJumperRestriction(PathRestriction):
+  def r_is_ok(self, path, router):
+    if len(path) > 0 and path[len(path)-1].continent == router.continent:
+      return False
+    else: return True
+
 #################### Node Generators ######################
 
 class UniformGenerator(NodeGenerator):
@@ -509,9 +516,11 @@
       # Unique countries?
       if self.geoip_config.unique_countries:
         self.path_rstr.add_restriction(UniqueCountryRestriction())
-      # Specify max number of crossings here
+      # Specify max number of crossings here, None means ContinentJumper
       n = self.geoip_config.max_cont_crossings
-      self.path_rstr.add_restriction(ContinentRestriction(n))
+      if n == None:
+        self.path_rstr.add_restriction(ContinentJumperRestriction())
+      else: self.path_rstr.add_restriction(ContinentRestriction(n))
 
     # This is kind of hokey..
     if self.order_exits: