[or-cvs] r20517: {torflow} Rework BwAuthority to only require 1 tor. (in torflow/trunk/NetworkScanners/BwAuthority: . data data/scanner.1 data/scanner.2 data/scanner.3 data/scanner.4 data/tor)

mikeperry at seul.org mikeperry at seul.org
Wed Sep 9 20:38:15 UTC 2009


Author: mikeperry
Date: 2009-09-09 16:38:14 -0400 (Wed, 09 Sep 2009)
New Revision: 20517

Added:
   torflow/trunk/NetworkScanners/BwAuthority/data/tor/
   torflow/trunk/NetworkScanners/BwAuthority/data/tor/torrc
Removed:
   torflow/trunk/NetworkScanners/BwAuthority/data/scanner.1/tor-data/
   torflow/trunk/NetworkScanners/BwAuthority/data/scanner.1/torrc
   torflow/trunk/NetworkScanners/BwAuthority/data/scanner.2/tor-data/
   torflow/trunk/NetworkScanners/BwAuthority/data/scanner.2/torrc
   torflow/trunk/NetworkScanners/BwAuthority/data/scanner.3/tor-data/
   torflow/trunk/NetworkScanners/BwAuthority/data/scanner.3/torrc
   torflow/trunk/NetworkScanners/BwAuthority/data/scanner.4/tor-data/
   torflow/trunk/NetworkScanners/BwAuthority/data/scanner.4/torrc
Modified:
   torflow/trunk/NetworkScanners/BwAuthority/bwauthority.py
   torflow/trunk/NetworkScanners/BwAuthority/run_scan.sh
Log:

Rework BwAuthority to only require 1 tor.



Modified: torflow/trunk/NetworkScanners/BwAuthority/bwauthority.py
===================================================================
--- torflow/trunk/NetworkScanners/BwAuthority/bwauthority.py	2009-09-09 20:04:36 UTC (rev 20516)
+++ torflow/trunk/NetworkScanners/BwAuthority/bwauthority.py	2009-09-09 20:38:14 UTC (rev 20517)
@@ -34,7 +34,11 @@
 from TorCtl import ScanSupport,PathSupport,SQLSupport,TorCtl,TorUtil
 
 sys.path.append("../libs")
+# Make our SocksiPy use our socket
+__origsocket = socket.socket
+socket.socket = PathSupport.SmartSocket
 from SocksiPy import socks
+socket.socket = __origsocket
 
 user_agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)"
 
@@ -153,6 +157,8 @@
             plog("DEBUG", "Exit router "+r.idhex+"="+r.nickname+" not done: "+str(r._generated[position])+", down: "+str(r.down)+", OK: "+str(this.selmgr.path_selector.exit_gen.rstr_list.r_is_ok(r))+", sorted_r: "+str(r in this.sorted_r))
             # XXX:
             #break
+        # Also run for at least 2*circs_per_node*nodes/3 successful fetches to
+        # ensure we don't skip slices in the case of temporary network failure
         if cond._finished:
            num_routers = len(
                  sets.Set(this.selmgr.path_selector.entry_gen.rstr_routers
@@ -178,8 +184,6 @@
 
   attempt = 0
   successful = 0
-  # XXX: Also run for at least 2*circs_per_node*nodes/3 successful fetches
-  # to ensure we don't skip slices in the case of temporary network failure
   while True:
     if hdlr.is_count_met(circs_per_node, successful): break
     hdlr.wait_for_consensus()
@@ -196,7 +200,7 @@
 
     hdlr.new_exit()
     attempt += 1
-    
+
     # FIXME: This noise is due to a difficult to find Tor bug that
     # causes some exits to hang forever on streams :(
     timer = threading.Timer(max_fetch_time, lambda: hdlr.close_streams(7))
@@ -205,6 +209,7 @@
     plog("DEBUG", "Launching stream request for url "+url+" in "+str(start_pct)+'-'+str(stop_pct) + '%')
     ret = http_request(url)
     timer.cancel()
+    PathSupport.SmartSocket.clear_port_table()
 
     delta_build = time.time() - t0
     if delta_build >= max_fetch_time:
@@ -298,6 +303,7 @@
 def cleanup(c, f):
   plog("INFO", "Resetting __LeaveStreamsUnattached=0 and FetchUselessDescriptors="+f)
   try:
+    # XXX: Remember __LeaveStreamsUnattached and use saved value!
     c.set_option("__LeaveStreamsUnattached", "0")
     c.set_option("FetchUselessDescriptors", f)
   except TorCtl.TorCtlClosed:
@@ -311,7 +317,8 @@
   c.debug(file(out_dir+"/control.log", "w", buffering=0))
   c.authenticate_cookie(file(cookie_file, "r"))
   #f = c.get_option("__LeaveStreamsUnattached")[0]
-  h = BwScanHandler(c, __selmgr)
+  h = BwScanHandler(c, __selmgr,
+                    strm_selector=PathSupport.SmartSocket.StreamSelector)
 
   c.set_event_handler(h)
   #c.set_periodic_timer(2.0, "PULSE")

Deleted: torflow/trunk/NetworkScanners/BwAuthority/data/scanner.1/torrc
===================================================================
--- torflow/trunk/NetworkScanners/BwAuthority/data/scanner.1/torrc	2009-09-09 20:04:36 UTC (rev 20516)
+++ torflow/trunk/NetworkScanners/BwAuthority/data/scanner.1/torrc	2009-09-09 20:38:14 UTC (rev 20517)
@@ -1,9 +0,0 @@
-## Configuration file for metatroller on alternate prot
-SocksPort 9110 # what port to advertise for application connections
-ControlPort 9111
-SafeLogging 0
-Log notice file ./data/scanner.1/tor.log
-DataDirectory ./data/scanner.1/tor-data
-PidFile ./data/scanner.1/tor.pid
-CookieAuthentication 1
-FetchUselessDescriptors 1

Deleted: torflow/trunk/NetworkScanners/BwAuthority/data/scanner.2/torrc
===================================================================
--- torflow/trunk/NetworkScanners/BwAuthority/data/scanner.2/torrc	2009-09-09 20:04:36 UTC (rev 20516)
+++ torflow/trunk/NetworkScanners/BwAuthority/data/scanner.2/torrc	2009-09-09 20:38:14 UTC (rev 20517)
@@ -1,9 +0,0 @@
-## Configuration file for metatroller on alternate prot
-SocksPort 9120 # what port to advertise for application connections
-ControlPort 9121
-SafeLogging 0
-Log notice file ./data/scanner.2/tor.log
-DataDirectory ./data/scanner.2/tor-data
-PidFile ./data/scanner.2/tor.pid
-CookieAuthentication 1
-FetchUselessDescriptors 1

Deleted: torflow/trunk/NetworkScanners/BwAuthority/data/scanner.3/torrc
===================================================================
--- torflow/trunk/NetworkScanners/BwAuthority/data/scanner.3/torrc	2009-09-09 20:04:36 UTC (rev 20516)
+++ torflow/trunk/NetworkScanners/BwAuthority/data/scanner.3/torrc	2009-09-09 20:38:14 UTC (rev 20517)
@@ -1,9 +0,0 @@
-## Configuration file for metatroller on alternate prot
-SocksPort 9130 # what port to advertise for application connections
-ControlPort 9131
-SafeLogging 0
-Log notice file ./data/scanner.3/tor.log
-DataDirectory ./data/scanner.3/tor-data
-PidFile ./data/scanner.3/tor.pid
-CookieAuthentication 1
-FetchUselessDescriptors 1

Deleted: torflow/trunk/NetworkScanners/BwAuthority/data/scanner.4/torrc
===================================================================
--- torflow/trunk/NetworkScanners/BwAuthority/data/scanner.4/torrc	2009-09-09 20:04:36 UTC (rev 20516)
+++ torflow/trunk/NetworkScanners/BwAuthority/data/scanner.4/torrc	2009-09-09 20:38:14 UTC (rev 20517)
@@ -1,9 +0,0 @@
-## Configuration file for metatroller on alternate prot
-SocksPort 9140 # what port to advertise for application connections
-ControlPort 9141
-SafeLogging 0
-Log notice file ./data/scanner.4/tor.log
-DataDirectory ./data/scanner.4/tor-data
-PidFile ./data/scanner.4/tor.pid
-CookieAuthentication 1
-FetchUselessDescriptors 1

Copied: torflow/trunk/NetworkScanners/BwAuthority/data/tor/torrc (from rev 20515, torflow/trunk/NetworkScanners/BwAuthority/data/scanner.1/torrc)
===================================================================
--- torflow/trunk/NetworkScanners/BwAuthority/data/tor/torrc	                        (rev 0)
+++ torflow/trunk/NetworkScanners/BwAuthority/data/tor/torrc	2009-09-09 20:38:14 UTC (rev 20517)
@@ -0,0 +1,10 @@
+## Configuration file for metatroller on alternate prot
+SocksPort 9110 # what port to advertise for application connections
+ControlPort 9111
+SafeLogging 0
+Log notice file ./data/tor/tor.log
+DataDirectory ./data/tor
+PidFile ./data/tor/tor.pid
+CookieAuthentication 1
+FetchUselessDescriptors 1
+__LeaveStreamsUnattached 1

Modified: torflow/trunk/NetworkScanners/BwAuthority/run_scan.sh
===================================================================
--- torflow/trunk/NetworkScanners/BwAuthority/run_scan.sh	2009-09-09 20:04:36 UTC (rev 20516)
+++ torflow/trunk/NetworkScanners/BwAuthority/run_scan.sh	2009-09-09 20:38:14 UTC (rev 20517)
@@ -9,16 +9,13 @@
 
 KILLED_TOR=false
 
-for i in data/scanner.*
-do
-  if [ -f "$i/tor.pid" ]; then
-    PID=`cat $i/tor.pid`
-    kill $PID
-    if [ $? -eq 0 ]; then
-      KILLED_TOR=true
-    fi
+if [ -f "./data/tor/tor.pid" ]; then
+  PID=`cat ./data/tor/tor.pid`
+  kill $PID
+  if [ $? -eq 0 ]; then
+    KILLED_TOR=true
   fi
-done
+fi
 
 sleep 5
 
@@ -30,11 +27,10 @@
   #rm $i/scan-data/*
 done
 
-$TOR_EXE -f ./data/scanner.1/torrc & 
-$TOR_EXE -f ./data/scanner.2/torrc & 
-$TOR_EXE -f ./data/scanner.3/torrc & 
-$TOR_EXE -f ./data/scanner.4/torrc & 
+rm -f ./data/tor/tor.log
 
+$TOR_EXE -f ./data/tor/torrc &
+
 # If this is a fresh start, we should allow the tors time to download
 # new descriptors.
 if [ $KILLED_TOR ]; then



More information about the tor-commits mailing list