[or-cvs] r18559: {torflow} Update TorFlow utilities to use the NEWCONSENSUS event. This (in torflow/trunk: . CircuitAnalysis/BuildTimes NetworkScanners)
mikeperry at seul.org
mikeperry at seul.org
Mon Feb 16 09:18:49 UTC 2009
Author: mikeperry
Date: 2009-02-16 04:18:49 -0500 (Mon, 16 Feb 2009)
New Revision: 18559
Modified:
torflow/trunk/CircuitAnalysis/BuildTimes/buildtimes.py
torflow/trunk/NetworkScanners/README.ExitScanning
torflow/trunk/NetworkScanners/soat.py
torflow/trunk/README
torflow/trunk/metatroller.py
torflow/trunk/torrc
Log:
Update TorFlow utilities to use the NEWCONSENSUS event. This
means they too require Tor r18556 or newer.
Modified: torflow/trunk/CircuitAnalysis/BuildTimes/buildtimes.py
===================================================================
--- torflow/trunk/CircuitAnalysis/BuildTimes/buildtimes.py 2009-02-16 09:17:22 UTC (rev 18558)
+++ torflow/trunk/CircuitAnalysis/BuildTimes/buildtimes.py 2009-02-16 09:18:49 UTC (rev 18559)
@@ -114,17 +114,8 @@
self.failfile.flush()
StatsHandler.circ_status_event(self,circ_event)
- def new_desc_event(self, d):
- for idhex in d.idlist:
- if not idhex in self.routers:
- continue
- r = self.routers[idhex]
- r.bw_history.append(r.bw)
- for r in self.sorted_r:
- r.rank_history.append(r.list_rank)
- StatsHandler.new_desc_event(self, d)
-
- def ns_event(self, n):
+ def newconsensus_event(self, n):
+ # Record previous rank and history.
for ns in n.nslist:
if not ns.idhex in self.routers:
continue
@@ -132,7 +123,7 @@
r.bw_history.append(r.bw)
for r in self.sorted_r:
r.rank_history.append(r.list_rank)
- StatsHandler.ns_event(self, n)
+ StatsHandler.newconsensus_event(self, n)
def cleanup():
@@ -162,10 +153,10 @@
c.set_events([TorCtl.EVENT_TYPE.STREAM,
TorCtl.EVENT_TYPE.BW,
- TorCtl.EVENT_TYPE.NS,
+ TorCtl.EVENT_TYPE.NEWCONSENSUS,
+ #TorCtl.EVENT_TYPE.NEWDESC,
TorCtl.EVENT_TYPE.CIRC,
- TorCtl.EVENT_TYPE.STREAM_BW,
- TorCtl.EVENT_TYPE.NEWDESC], True)
+ TorCtl.EVENT_TYPE.STREAM_BW], True)
return c
def getargs():
Modified: torflow/trunk/NetworkScanners/README.ExitScanning
===================================================================
--- torflow/trunk/NetworkScanners/README.ExitScanning 2009-02-16 09:17:22 UTC (rev 18558)
+++ torflow/trunk/NetworkScanners/README.ExitScanning 2009-02-16 09:18:49 UTC (rev 18559)
@@ -15,7 +15,7 @@
II. Prerequisites
Python 2.4+
-Tor 0.2.1.13 (r18516 or later)
+Tor 0.2.1.13 (r18556 or later)
Super Secret SoaT Sauce
py-openssl/pyOpenSSL
Bonus: 500M of disk space
Modified: torflow/trunk/NetworkScanners/soat.py
===================================================================
--- torflow/trunk/NetworkScanners/soat.py 2009-02-16 09:17:22 UTC (rev 18558)
+++ torflow/trunk/NetworkScanners/soat.py 2009-02-16 09:18:49 UTC (rev 18559)
@@ -263,18 +263,14 @@
return random.choice(list(self.nodes))
def update_nodes(self):
- all_old_nodes = sets.Set(self.node_map.keys())
nodes = metacon.node_manager.get_nodes_for_port(self.port)
self.node_map = {}
for n in nodes:
self.node_map[n.idhex] = n
self.total_nodes = len(nodes)
- all_new_nodes = sets.Set(map(lambda n: n.idhex, nodes))
+ self.nodes = sets.Set(map(lambda n: n.idhex, nodes))
marked_nodes = sets.Set(self.node_results.keys())
- new_nodes = all_new_nodes - all_old_nodes
- new_nodes -= marked_nodes
- self.nodes &= all_new_nodes # Clear down nodes
- self.nodes = self.nodes | new_nodes # add new ones
+ self.nodes -= marked_nodes # Remove marked nodes
# Only scan the stuff loaded from the rescan
if self.rescan_nodes: self.nodes &= self.rescan_nodes
if not self.nodes:
@@ -2072,7 +2068,7 @@
self._read_routers(self.c.get_network_status())
self.new_nodes=True
c.set_event_handler(self)
- c.set_events([TorCtl.EVENT_TYPE.NEWDESC, TorCtl.EVENT_TYPE.NS], True)
+ c.set_events([TorCtl.EVENT_TYPE.NEWCONSENSUS], True)
def has_new_nodes(self):
ret = False
@@ -2101,44 +2097,27 @@
def _read_routers(self, nslist):
routers = self.c.read_routers(nslist)
- new_routers = []
+ self.sorted_r = []
+ self.routers = {}
for r in routers:
- if r.idhex in self.routers:
- if self.routers[r.idhex].nickname != r.nickname:
- plog("NOTICE", "Router "+r.idhex+" changed names from "
- +self.routers[r.idhex].nickname+" to "+r.nickname)
- self.sorted_r.remove(self.routers[r.idhex])
self.routers[r.idhex] = r
- new_routers.append(r)
+ self.sorted_r.append(r)
- self.sorted_r.extend(new_routers)
self.sorted_r.sort(lambda x, y: cmp(y.bw, x.bw))
# This is an OK update because of the GIL (also we don't touch it)
for i in xrange(len(self.sorted_r)): self.sorted_r[i].list_rank = i
- def ns_event(self, n):
- plog("DEBUG", "ns_event begin")
+ def newconsensus_event(self, n):
+ plog("DEBUG", "newconsensus_event begin")
try:
self.rlock.acquire()
self._read_routers(n.nslist)
self.new_nodes = True
finally:
self.rlock.release()
- plog("DEBUG", "Read " + str(len(n.nslist))+" NS => "
+ plog("DEBUG", "Read " + str(len(n.nslist))+" NC => "
+ str(len(self.sorted_r)) + " routers")
-
- def new_desc_event(self, d):
- plog("DEBUG", "new_desc_event begin")
- try:
- self.rlock.acquire()
- for i in d.idlist: # Is this too slow?
- self._read_routers(self.c.get_network_status("id/"+i))
- self.new_nodes = True
- finally:
- self.rlock.release()
- plog("DEBUG", "Read " + str(len(d.idlist))+" Desc => "
- + str(len(self.sorted_r)) + " routers")
-
+
class DNSRebindScanner(EventHandler):
'''
Modified: torflow/trunk/README
===================================================================
--- torflow/trunk/README 2009-02-16 09:17:22 UTC (rev 18558)
+++ torflow/trunk/README 2009-02-16 09:18:49 UTC (rev 18559)
@@ -63,7 +63,7 @@
or get it from http://pyopenssl.sourceforge.net/
-3b. NetworkScanners/speedracer.pl
+3b. NetworkScanners/speedracer.py
SpeedRacer fetches a file repeatedly through circuits built by
metatroller. It divides the Tor network into tiers based on percentiles
Modified: torflow/trunk/metatroller.py
===================================================================
--- torflow/trunk/metatroller.py 2009-02-16 09:17:22 UTC (rev 18558)
+++ torflow/trunk/metatroller.py 2009-02-16 09:18:49 UTC (rev 18559)
@@ -253,10 +253,10 @@
c.set_events([TorCtl.EVENT_TYPE.STREAM,
TorCtl.EVENT_TYPE.BW,
- TorCtl.EVENT_TYPE.NS,
+ TorCtl.EVENT_TYPE.NEWCONSENSUS,
+ #TorCtl.EVENT_TYPE.NEWDESC,
TorCtl.EVENT_TYPE.CIRC,
- TorCtl.EVENT_TYPE.STREAM_BW,
- TorCtl.EVENT_TYPE.NEWDESC], True)
+ TorCtl.EVENT_TYPE.STREAM_BW], True)
c.set_option("__LeaveStreamsUnattached", "1")
f = c.get_option("FetchUselessDescriptors")[0][1]
c.set_option("FetchUselessDescriptors", "1")
Modified: torflow/trunk/torrc
===================================================================
--- torflow/trunk/torrc 2009-02-16 09:17:22 UTC (rev 18558)
+++ torflow/trunk/torrc 2009-02-16 09:18:49 UTC (rev 18559)
@@ -2,5 +2,9 @@
SocksPort 9060 # what port to advertise for application connections
ControlPort 9061
SafeLogging 0
-Log info stderr
+Log debug stderr
FetchUselessDescriptors 1
+
+# XXX: This should be for test scans only. Our timeout values must match the
+# normal Tor clients.
+SocksTimeout 45
More information about the tor-commits
mailing list