[or-cvs] r18679: {torflow} Update documentation and individual scripts to use new Selec (in torflow/trunk: . CircuitAnalysis/BuildTimes CircuitAnalysis/OPAddon NetworkScanners)

mikeperry at seul.org mikeperry at seul.org
Mon Feb 23 11:01:22 UTC 2009


Author: mikeperry
Date: 2009-02-23 06:01:21 -0500 (Mon, 23 Feb 2009)
New Revision: 18679

Modified:
   torflow/trunk/CircuitAnalysis/BuildTimes/buildtimes.py
   torflow/trunk/CircuitAnalysis/OPAddon/op-addon.py
   torflow/trunk/NetworkScanners/libsoat.py
   torflow/trunk/NetworkScanners/soat.py
   torflow/trunk/metatroller.py
Log:

Update documentation and individual scripts to use new
SelectionManager interface.



Modified: torflow/trunk/CircuitAnalysis/BuildTimes/buildtimes.py
===================================================================
--- torflow/trunk/CircuitAnalysis/BuildTimes/buildtimes.py	2009-02-23 11:00:22 UTC (rev 18678)
+++ torflow/trunk/CircuitAnalysis/BuildTimes/buildtimes.py	2009-02-23 11:01:21 UTC (rev 18679)
@@ -56,7 +56,7 @@
     self.uptime = 0
  
 # TODO: Make this passive, or make PathBuild have a passive option
-class StatsGatherer(StatsHandler):
+class CircStatsGatherer(StatsHandler):
   def __init__(self,c, selmgr,basefile_name,nstats):
     StatsHandler.__init__(self,c, selmgr, BTRouter)
     self.nodesfile = open(basefile_name + '.nodes','w')
@@ -83,6 +83,11 @@
     # Prevent PathBuilder code from attaching streams
     # TODO: Passively gather stream stats without building
     pass
+
+  def stream_bw_event(self, strm_bw_event):
+    # Prevent PathBuilder code from counting streams
+    # TODO: Passively gather stream stats without building
+    pass
     
   def circ_status_event(self, circ_event):
     """ handles circuit status event """
@@ -143,7 +148,7 @@
   c = PathSupport.Connection(s)
   c.authenticate(control_pass)  # also launches thread...
   c.debug(file(filename+".log", "w"))
-  h = StatsGatherer(c,__selmgr,filename,ncircuits)
+  h = CircStatsGatherer(c,__selmgr,filename,ncircuits)
   c.set_event_handler(h)
   global FUDValue
   if not FUDValue:
@@ -256,7 +261,7 @@
           plog("DEBUG", "Too many circuits: "+str(h.circ_count-h.circ_succeeded-h.circ_failed)+", delaying build")
           h.schedule_low_prio(circuit_builder)
           return
-        circ = h.c.build_circuit(h.selmgr.pathlen, h.selmgr.path_selector)   
+        circ = h.c.build_circuit(h.selmgr.select_path())   
         h.circuits[circ.circ_id] = circ
       c._handler.schedule_low_prio(circuit_builder)
     except TorCtl.ErrorReply,e:

Modified: torflow/trunk/CircuitAnalysis/OPAddon/op-addon.py
===================================================================
--- torflow/trunk/CircuitAnalysis/OPAddon/op-addon.py	2009-02-23 11:00:22 UTC (rev 18678)
+++ torflow/trunk/CircuitAnalysis/OPAddon/op-addon.py	2009-02-23 11:01:21 UTC (rev 18679)
@@ -149,27 +149,6 @@
       use_guards = config.getboolean(NODE_SELECTION, "use_guards"),
       geoip_config = get_geoip_config())
 
-## Connection #################################################################
-
-class Connection(PathSupport.Connection):
-  """ Connection-class that uses the RTTCircuit-class 
-      TODO: add the circuit class to be used """
-  def build_circuit(self, pathlen, path_sel):
-    circ = Circuit()
-    circ.path = path_sel.build_path(pathlen)
-    circ.exit = circ.path[pathlen-1]
-    circ.circ_id = self.extend_circuit(0, circ.id_path())
-    return circ
-
-  def build_circuit_from_path(self, path):
-    """ Build circuit using a given path (= router-objects), 
-        used to build circuits from a NetworkModel """
-    circ = Circuit()
-    circ.path = path
-    circ.exit = path[len(path)-1]
-    circ.circ_id = self.extend_circuit(0, circ.id_path())
-    return circ
-
 ## Stats ######################################################################
 
 class Stats:
@@ -1035,7 +1014,7 @@
         if r_path and self.path_is_ok(r_path):
           plog("INFO", "Chosen proposal: " + choice.to_string())
           try:
-            circ = self.c.build_circuit_from_path(r_path)
+            circ = self.c.build_circuit(r_path)
             circ.rtt_created = True
             self.circuits[circ.circ_id] = circ
             plog("INFO", "Created circ from model: " + str(circ.circ_id))
@@ -1145,7 +1124,7 @@
     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     sock.connect((config.get(GENERAL, "control_host"), 
        config.getint(GENERAL, "control_port")))
-    conn = Connection(sock)
+    conn = PathSupport.Connection(sock)
     conn.authenticate()
     #conn.debug(file("control.log", "w"))  
   except socket.error, e:

Modified: torflow/trunk/NetworkScanners/libsoat.py
===================================================================
--- torflow/trunk/NetworkScanners/libsoat.py	2009-02-23 11:00:22 UTC (rev 18678)
+++ torflow/trunk/NetworkScanners/libsoat.py	2009-02-23 11:01:21 UTC (rev 18679)
@@ -386,6 +386,10 @@
         tor_soup = FullyStrainedSoup(content_exit)
 
       if self.verbose > 1:
+        ret += " Content: "+str(self.content)+"\n"
+        ret += " Content old: "+str(self.content_old)+"\n"
+        ret += " Exit: "+str(self.content_exit)+"\n"
+
         if self.content and self.content_old:
           tags = map(str, soup.findAll())
           old_tags = map(str, old_soup.findAll())

Modified: torflow/trunk/NetworkScanners/soat.py
===================================================================
--- torflow/trunk/NetworkScanners/soat.py	2009-02-23 11:00:22 UTC (rev 18678)
+++ torflow/trunk/NetworkScanners/soat.py	2009-02-23 11:01:21 UTC (rev 18679)
@@ -276,6 +276,7 @@
     if not self.nodes:
       plog("ERROR", "No nodes remain after rescan load!")
     self.scan_nodes = len(self.nodes)
+    # XXX: Wrong:
     self.nodes_to_mark = self.scan_nodes*self.tests_per_node
 
   def mark_chosen(self, node, result):

Modified: torflow/trunk/metatroller.py
===================================================================
--- torflow/trunk/metatroller.py	2009-02-23 11:00:22 UTC (rev 18678)
+++ torflow/trunk/metatroller.py	2009-02-23 11:01:21 UTC (rev 18679)
@@ -10,6 +10,12 @@
 rates, stream bandwidths, probabilities of bandwidth ratios, and much
 much more.
 
+It is also a good place to start for hacking in your own custom
+path selection policy. You can remove the SelectionManager it uses
+and replace it with your own BaseSelectionManager implementation, 
+potentially removing the command loop/meta control port code as
+needed.
+
 """
 
 import atexit
@@ -37,6 +43,8 @@
 # Do NOT modify this object directly after it is handed to PathBuilder
 # Use PathBuilder.schedule_selmgr instead.
 # (Modifying the arguments here is OK)
+# NOTE: Custom implementations may wish to replace this with their
+# own PathSupport.BaseSelectionManager implementation
 __selmgr = PathSupport.SelectionManager(
       pathlen=3,
       order_exits=True,
@@ -190,7 +198,7 @@
         plog("DEBUG", "Got Setexit: "+exit_name)
         def notlambda(sm): 
           plog("DEBUG", "Job for setexit: "+exit_name)
-          sm.exit_name=exit_name
+          sm.set_exit(exit_name)
         h.schedule_selmgr(notlambda)
         s.write("250 OK\r\n")
       else:
@@ -248,7 +256,7 @@
   s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
   s.connect((control_host,control_port))
   c = PathSupport.Connection(s)
-  c.debug(file("control.log", "w"))
+  c.debug(file("control.log", "w", buffering=0))
   c.authenticate(control_pass)
   h = StatsHandler(c, __selmgr)
 



More information about the tor-commits mailing list