[or-cvs] Cut off after 100 circuits; print which servers were in suc...

Nick Mathewson nickm at seul.org
Thu Mar 31 06:21:46 UTC 2005


Update of /home/or/cvsroot/tor/contrib
In directory moria.mit.edu:/tmp/cvs-serv29363/contrib

Modified Files:
	ExerciseServer.py 
Log Message:
Cut off after 100 circuits; print which servers were in successful/failed circuits when done.

Index: ExerciseServer.py
===================================================================
RCS file: /home/or/cvsroot/tor/contrib/ExerciseServer.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- ExerciseServer.py	31 Mar 2005 06:08:48 -0000	1.3
+++ ExerciseServer.py	31 Mar 2005 06:21:43 -0000	1.4
@@ -35,15 +35,22 @@
 EXITS_TO_TEST = [ "pvt", ]
 TARGETS = [ ("belegost.mit.edu", "/"),
             ("seul.org", "/")]
-
+N_CIRCS_TO_TRY = 100
 CIRCS_AT_A_TIME = 3
 CIRC_LEN = 3
 
+
+HOST_STATUS = {}
+N_CIRCS_DONE = 0
 def launchCirc(s):
     htt = HOSTS_TO_TEST[:]
     random.shuffle(htt)
     path = htt[:CIRC_LEN-1]+[random.choice(EXITS_TO_TEST)]
     circid = TorControl.extend_circuit(s, 0, path)
+
+    for name in path:
+        lst = HOST_STATUS.setdefault(name,[0,0])
+        lst[0] += 1
     return circid, path
 
 def runControl(s):
@@ -56,7 +63,8 @@
                           [TorControl.EVENT_TYPE.CIRCSTATUS,
                            TorControl.EVENT_TYPE.STREAMSTATUS])
     TorControl.set_option(s,"__LeaveStreamsUnattached 1")
-    while 1:
+    global N_CIRCS_DONE
+    while N_CIRCS_DONE < N_CIRCS_TO_TRY:
         while len(circs) < CIRCS_AT_A_TIME:
             c,p = launchCirc(s)
             print "launching circuit %s to %s"%(c,p)
@@ -64,8 +72,13 @@
         _, tp, body = TorControl.receive_message(s)
         if tp == TorControl.MSG_TYPE.EVENT:
             handleEvent(s, body, circs, s1,s2)
+    i = HOST_STATUS.items()
+    i.sort()
+    for n,(all,good) in i:
+        print "%s in %s circuits; %s/%s ok"%(n,all,good,all)
 
 def handleEvent(s, body, circs, streamsByNonce, streamsByIdent):
+    global N_CIRCS_DONE
     event, args = TorControl.unpack_event(body)
     if event == TorControl.EVENT_TYPE.STREAMSTATUS:
         status, ident, target = args
@@ -87,7 +100,11 @@
                         TorControl.STREAM_STATUS.FAILED):
             circid, (host,url) = streamsByIdent[ident]
             if circs.has_key(circid):
+                for name in circs[circid]:
+                    HOST_STATUS[name][1] += 1
                 del circs[circid]
+                N_CIRCS_DONE += 1
+                print N_CIRCS_DONE, "circuit attempts done"
             del streamsByIdent[ident]
     elif event == TorControl.EVENT_TYPE.CIRCSTATUS:
         status, ident, path = args
@@ -98,6 +115,8 @@
             if circs.has_key(ident):
                 print "Circuit failed."
                 del circs[ident]
+                N_CIRCS_DONE += 1
+                print N_CIRCS_DONE, "circuit attempts done"
         elif status == TorControl.CIRC_STATUS.BUILT:
             nonce = random.randint(1,100000000)
             nonce = "%s.exnonce" % nonce



More information about the tor-commits mailing list