[or-cvs] r11114: Added an option to specify the middle node's country and red (in torflow/trunk: . TorCtl)

renner at seul.org renner at seul.org
Wed Aug 15 09:27:13 UTC 2007


Author: renner
Date: 2007-08-15 05:27:12 -0400 (Wed, 15 Aug 2007)
New Revision: 11114

Modified:
   torflow/trunk/TorCtl/GeoIPSupport.py
   torflow/trunk/TorCtl/PathSupport.py
   torflow/trunk/op-addon.py
   torflow/trunk/pathrc.example
Log:

  Added an option to specify the middle node's country and reduced all lines in
  GeoIPSupport.py to 80 columns.



Modified: torflow/trunk/TorCtl/GeoIPSupport.py
===================================================================
--- torflow/trunk/TorCtl/GeoIPSupport.py	2007-08-15 08:54:40 UTC (rev 11113)
+++ torflow/trunk/TorCtl/GeoIPSupport.py	2007-08-15 09:27:12 UTC (rev 11114)
@@ -22,36 +22,36 @@
 
 # Setup the continents
 africa = Continent("AF")
-africa.countries = ["AO","BF","BI","BJ","BV","BW","CD","CF","CG","CI","CM","CV","DJ","DZ",
-                    "EG","EH","ER","ET","GA","GH","GM","GN","GQ","GW","HM","KE","KM","LR",
-		    "LS","LY","MA","MG","ML","MR","MU","MW","MZ","NA","NE","NG","RE","RW",
-		    "SC","SD","SH","SL","SN","SO","ST","SZ","TD","TF","TG","TN","TZ","UG",
-		    "YT","ZA","ZM","ZR","ZW"]
+africa.countries = ["AO","BF","BI","BJ","BV","BW","CD","CF","CG","CI","CM",
+   "CV","DJ","DZ","EG","EH","ER","ET","GA","GH","GM","GN","GQ","GW","HM","KE",
+   "KM","LR","LS","LY","MA","MG","ML","MR","MU","MW","MZ","NA","NE","NG","RE",
+   "RW","SC","SD","SH","SL","SN","SO","ST","SZ","TD","TF","TG","TN","TZ","UG",
+   "YT","ZA","ZM","ZR","ZW"]
 
 asia = Continent("AS")
-asia.countries = ["AP","AE","AF","AM","AZ","BD","BH","BN","BT","CC","CN","CX","CY","GE",
-                  "HK","ID","IL","IN","IO","IQ","IR","JO","JP","KG","KH","KP","KR","KW",
-		  "KZ","LA","LB","LK","MM","MN","MO","MV","MY","NP","OM","PH","PK","PS",
-		  "QA","RU","SA","SG","SY","TH","TJ","TM","TP","TR","TW","UZ","VN","YE"]
+asia.countries = ["AP","AE","AF","AM","AZ","BD","BH","BN","BT","CC","CN","CX",
+   "CY","GE","HK","ID","IL","IN","IO","IQ","IR","JO","JP","KG","KH","KP","KR",
+   "KW","KZ","LA","LB","LK","MM","MN","MO","MV","MY","NP","OM","PH","PK","PS",
+   "QA","RU","SA","SG","SY","TH","TJ","TM","TP","TR","TW","UZ","VN","YE"]
 
 europe = Continent("EU")
-europe.countries = ["EU","AD","AL","AT","BA","BE","BG","BY","CH","CZ","DE","DK","EE","ES",
-                    "FI","FO","FR","FX","GB","GI","GR","HR","HU","IE","IS","IT","LI","LT",
-		    "LU","LV","MC","MD","MK","MT","NL","NO","PL","PT","RO","SE","SI","SJ",
-		    "SK","SM","UA","VA","YU"]
+europe.countries = ["EU","AD","AL","AT","BA","BE","BG","BY","CH","CZ","DE",
+   "DK","EE","ES","FI","FO","FR","FX","GB","GI","GR","HR","HU","IE","IS","IT",
+   "LI","LT","LU","LV","MC","MD","MK","MT","NL","NO","PL","PT","RO","SE","SI",
+   "SJ","SK","SM","UA","VA","YU"]
 
 oceania = Continent("OC")
-oceania.countries = ["AS","AU","CK","FJ","FM","GU","KI","MH","MP","NC","NF","NR","NU","NZ",
-                     "PF","PG","PN","PW","SB","TK","TO","TV","UM","VU","WF","WS"]
+oceania.countries = ["AS","AU","CK","FJ","FM","GU","KI","MH","MP","NC","NF",
+   "NR","NU","NZ","PF","PG","PN","PW","SB","TK","TO","TV","UM","VU","WF","WS"]
 
 north_america = Continent("NA")
 north_america.countries = ["CA","MX","US"]
 
 south_america = Continent("SA")
-south_america.countries = ["AG","AI","AN","AR","AW","BB","BM","BO","BR","BS","BZ","CL","CO",
-                            "CR","CU","DM","DO","EC","FK","GD","GF","GL","GP","GS","GT","GY",
-			    "HN","HT","JM","KN","KY","LC","MQ","MS","NI","PA","PE","PM","PR",
-			    "PY","SA","SR","SV","TC","TT","UY","VC","VE","VG","VI"]
+south_america.countries = ["AG","AI","AN","AR","AW","BB","BM","BO","BR","BS",
+   "BZ","CL","CO","CR","CU","DM","DO","EC","FK","GD","GF","GL","GP","GS","GT",
+   "GY","HN","HT","JM","KN","KY","LC","MQ","MS","NI","PA","PE","PM","PR","PY",
+   "SA","SR","SV","TC","TT","UY","VC","VE","VG","VI"]
 
 # List of continents
 continents = [africa, asia, europe, north_america, oceania, south_america]
@@ -91,8 +91,8 @@
 class GeoIPConfig:
   """ Class to configure GeoIP-based path building """		    
   def __init__(self, unique_countries, max_crossings, entry_country, 
-     exit_country, excludes): 
-    # TODO: Somehow ensure validity of the configuration
+     middle_country, exit_country, excludes): 
+    # TODO: Somehow ensure validity of a configuration
     
     # Do not use a country twice in a route 
     # [True --> unique, False --> same or None --> pass] 
@@ -102,9 +102,9 @@
     # [integer number 0-n or None --> ContinentJumper/UniqueContinent]
     self.max_crossings = max_crossings
 
-    # entry in entry_country [single country code or None]
+    # Specify countries for positions [single country code or None]
     self.entry_country = entry_country
-    # exit in exit_country [single country code or None]
+    self.middle_country = middle_country
     self.exit_country = exit_country
         
     # List of countries not to use in routes 

Modified: torflow/trunk/TorCtl/PathSupport.py
===================================================================
--- torflow/trunk/TorCtl/PathSupport.py	2007-08-15 08:54:40 UTC (rev 11113)
+++ torflow/trunk/TorCtl/PathSupport.py	2007-08-15 09:27:12 UTC (rev 11114)
@@ -591,10 +591,11 @@
       mid_rstr.add_restriction(CountryCodeRestriction())
       self.exit_rstr.add_restriction(CountryCodeRestriction())
       
-      # First hop in a specified country?
+      # Specified countries for different positions
       if self.geoip_config.entry_country:  
         entry_rstr.add_restriction(CountryRestriction(self.geoip_config.entry_country))
-      # Last hop in a specified country?
+      if self.geoip_config.middle_country:
+        mid_rstr.add_restriction(CountryRestriction(self.geoip_config.middle_country))
       if self.geoip_config.exit_country:
         self.exit_rstr.add_restriction(CountryRestriction(self.geoip_config.exit_country))
 
@@ -993,7 +994,7 @@
     # not miss any circuit events on startup
     c.set_event_handler(self)
     self.num_circuits = num_circuits    # Size of the circuit pool
-    self.check_circuit_pool()	        # Bring up the pool of circs
+    self.check_circuit_pool()           # Bring up the pool of circs
     
   def check_circuit_pool(self):
     """ Init or check the status of the circuit-pool """

Modified: torflow/trunk/op-addon.py
===================================================================
--- torflow/trunk/op-addon.py	2007-08-15 08:54:40 UTC (rev 11113)
+++ torflow/trunk/op-addon.py	2007-08-15 09:27:12 UTC (rev 11114)
@@ -40,7 +40,8 @@
   sys.exit(0)
 
 # Set some defaults for string-variables that can be None
-string_defaults = {"use_exit":None, "entry_country":None, "exit_country":None}
+string_defaults = {"use_exit":None, "entry_country":None, 
+   "middle_country":None, "exit_country":None}
 config = ConfigParser.SafeConfigParser(string_defaults)
 if os.path.exists(CONFIG_FILE):
   plog("INFO", "Loading configuration from '" + CONFIG_FILE + "'")
@@ -111,6 +112,7 @@
        unique_countries,
        max_crossings,
        entry_country = config.get(GEOIP, "entry_country"),
+       middle_country = config.get(GEOIP, "middle_country"),
        exit_country = config.get(GEOIP, "exit_country"),
        excludes = None)
   else: path_config = None

Modified: torflow/trunk/pathrc.example
===================================================================
--- torflow/trunk/pathrc.example	2007-08-15 08:54:40 UTC (rev 11113)
+++ torflow/trunk/pathrc.example	2007-08-15 09:27:12 UTC (rev 11114)
@@ -48,7 +48,7 @@
 
 # Set country codes for single positions
 #entry_country = DE
-# TODO: middle_country
+#middle_country = RU
 #exit_country = US
 
 # Maximum number of continent-crossings 



More information about the tor-commits mailing list