[or-cvs] [torflow/master 28/92] Fixed resuming. Resume files from before the introduction of FixedTarget*Test are resumed as SearchBased*Tests

mikeperry at torproject.org mikeperry at torproject.org
Sat Aug 21 05:13:59 UTC 2010


Author: John M. Schanck <john at anomos.info>
Date: Thu, 22 Jul 2010 19:08:11 -0400
Subject: Fixed resuming. Resume files from before the introduction of FixedTarget*Test are resumed as SearchBased*Tests
Commit: acfecba492cd9af8cea5b337a8c238b2f985d7c7

---
 NetworkScanners/ExitAuthority/libsoat.py |    8 ++++++--
 NetworkScanners/ExitAuthority/soat.py    |   27 ++++++++++++++++++---------
 2 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/NetworkScanners/ExitAuthority/libsoat.py b/NetworkScanners/ExitAuthority/libsoat.py
index 5bbea11..69cec3c 100644
--- a/NetworkScanners/ExitAuthority/libsoat.py
+++ b/NetworkScanners/ExitAuthority/libsoat.py
@@ -723,10 +723,14 @@ class DataHandler:
     SnakePickler.dump(result, result.filename)
 
   def __testFilename(self, test, position=-1):
+    if hasattr(test, "save_name"):
+      name = test.save_name
+    else:
+      name = test.__class__.__name__
     if position == -1:
-      return DataHandler.uniqueFilename(self.data_dir+test.__class__.__name__+".test")
+      return DataHandler.uniqueFilename(self.data_dir+name+".test")
     else:
-      return self.data_dir+test.__class__.__name__+"."+str(position)+".test"
+      return self.data_dir+name+"."+str(position)+".test"
 
   def loadTest(self, testname, position=-1):
     filename = self.data_dir+testname
diff --git a/NetworkScanners/ExitAuthority/soat.py b/NetworkScanners/ExitAuthority/soat.py
index 16dbc58..1cd2f81 100755
--- a/NetworkScanners/ExitAuthority/soat.py
+++ b/NetworkScanners/ExitAuthority/soat.py
@@ -827,6 +827,7 @@ class BaseHTTPTest(Test):
   def __init__(self, filetypes=scan_filetypes):
     # FIXME: Handle http urls w/ non-80 ports..
     Test.__init__(self, "HTTP", 80)
+    self.save_name = "HTTPTest"
     self.fetch_targets = urls_per_filetype
     self.httpcode_fails = {}
     self.scan_filetypes = filetypes
@@ -1285,6 +1286,7 @@ class BaseHTTPTest(Test):
 class BaseHTMLTest(BaseHTTPTest):
   def __init__(self, recurse_filetypes=scan_filetypes):
     BaseHTTPTest.__init__(self, recurse_filetypes)
+    self.save_name = "HTMLTest"
     self.fetch_targets = num_html_urls
     self.proto = "HTML"
     self.recurse_filetypes = recurse_filetypes
@@ -1642,6 +1644,7 @@ class BaseHTMLTest(BaseHTTPTest):
 class BaseSSLTest(Test):
   def __init__(self):
     Test.__init__(self, "SSL", 443)
+    self.save_name = "SSLTest"
     self.test_hosts = num_ssl_hosts
 
   def run_test(self):
@@ -2050,6 +2053,8 @@ class SearchBasedHTTPTest(SearchBasedTest, BaseHTTPTest):
       self.targets_by_type[k].extend(v)
     return raw_urls
 
+HTTPTest = SearchBasedHTTPTest # For resuming from old HTTPTest.*.test files
+
 class SearchBasedHTMLTest(SearchBasedTest, BaseHTMLTest):
   def __init__(self, wordlist):
     BaseHTMLTest.__init__(self)
@@ -2062,6 +2067,8 @@ class SearchBasedHTMLTest(SearchBasedTest, BaseHTMLTest):
     self.wordlist = load_wordlist(self.wordlist_file)
     Test.rewind(self)
 
+HTMLTest = SearchBasedHTMLTest # For resuming from old HTMLTest.*.test files
+
 class SearchBasedSSLTest(SearchBasedTest, BaseSSLTest):
   def __init__(self, wordlist):
     BaseSSLTest.__init__(self)
@@ -2074,6 +2081,8 @@ class SearchBasedSSLTest(SearchBasedTest, BaseSSLTest):
     self.wordlist = load_wordlist(self.wordlist_file)
     Test.rewind(self)
 
+SSLTest = SearchBasedSSLTest # For resuming from old SSLTest.*.test files
+
 
 class POP3STest(Test):
   def __init__(self):
@@ -2896,18 +2905,18 @@ def main(argv):
 
   # Initialize tests
   #XXX: Resume currently broken. New depickling routines required
-  #if do_resume:
-  #  plog("NOTICE", "Resuming previous SoaT run #"+str(resume_run))
-  #  if do_ssl:
-  #    tests["SSL"] = datahandler.loadTest("SSLTest", resume_run)
+  if do_resume:
+    plog("NOTICE", "Resuming previous SoaT run #"+str(resume_run))
+    if do_ssl:
+      tests["SSL"] = datahandler.loadTest("SSLTest", resume_run)
 
-  #  if do_http:
-  #    tests["HTTP"] = datahandler.loadTest("HTTPTest", resume_run)
+    if do_http:
+      tests["HTTP"] = datahandler.loadTest("HTTPTest", resume_run)
 
-  #  if do_html:
-  #    tests["HTML"] = datahandler.loadTest("HTMLTest", resume_run)
+    if do_html:
+      tests["HTML"] = datahandler.loadTest("HTMLTest", resume_run)
 
-  if fixed_targets:
+  elif fixed_targets:
     if do_ssl:
       tests["SSL"] = FixedTargetSSLTest(fixed_targets)
 
-- 
1.7.1




More information about the tor-commits mailing list