summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2005-03-31 06:21:43 +0000
committerNick Mathewson <nickm@torproject.org>2005-03-31 06:21:43 +0000
commitd90b02d318ade2c3fb128399e0854622ac7bd7f1 (patch)
tree483616dcb3632de138bf85d4f88f337196fea42d
parent85c6d25e5ba735654da0df0f04cb0dc723a7d9d2 (diff)
downloadtor-d90b02d318ade2c3fb128399e0854622ac7bd7f1.tar.gz
tor-d90b02d318ade2c3fb128399e0854622ac7bd7f1.zip
Cut off after 100 circuits; print which servers were in successful/failed circuits when done.
svn:r3928
-rw-r--r--contrib/ExerciseServer.py23
1 files changed, 21 insertions, 2 deletions
diff --git a/contrib/ExerciseServer.py b/contrib/ExerciseServer.py
index 8d3e2f2249..8ec3c8f8d5 100644
--- a/contrib/ExerciseServer.py
+++ b/contrib/ExerciseServer.py
@@ -35,15 +35,22 @@ HOSTS_TO_TEST = [ "moria1", "ned", "tor26"]
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 @@ def runControl(s):
[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 @@ def runControl(s):
_, 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 @@ def handleEvent(s, body, circs, streamsByNonce, streamsByIdent):
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 @@ def handleEvent(s, body, circs, streamsByNonce, streamsByIdent):
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