[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] [torflow/master 18/92] FailureSlowXfer
Author: John M. Schanck <john@xxxxxxxxxxx>
Date: Sat, 10 Jul 2010 06:12:26 -0400
Subject: FailureSlowXfer
Commit: 67c29d0d646c34ee73ac7ba692a593d582baff8f
---
NetworkScanners/ExitAuthority/libsoat.py | 11 +++++++++--
NetworkScanners/ExitAuthority/soat.py | 16 ++++++++++++----
2 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/NetworkScanners/ExitAuthority/libsoat.py b/NetworkScanners/ExitAuthority/libsoat.py
index 2b3461f..5bbea11 100644
--- a/NetworkScanners/ExitAuthority/libsoat.py
+++ b/NetworkScanners/ExitAuthority/libsoat.py
@@ -50,11 +50,13 @@ __all__ = [ # Classes
"FAILURE_NOEXITCONTENT", "FAILURE_EXITTRUNCATION", "FAILURE_SOCKSERROR",
"FAILURE_HOSTUNREACH", "FAILURE_NETUNREACH", "FAILURE_EXITPOLICY",
"FAILURE_CONNREFUSED", "FAILURE_CONNERROR", "FAILURE_URLERROR", "FAILURE_CRYPTOERROR",
- "FAILURE_TIMEOUT", "FAILURE_HEADERCHANGE", "FAILURE_MISCEXCEPTION",
+ "FAILURE_TIMEOUT", "FAILURE_SLOWXFER", "FAILURE_HEADERCHANGE", "FAILURE_MISCEXCEPTION",
"FALSEPOSITIVE_HTTPERRORS", "FALSEPOSITIVE_DYNAMIC", "FALSEPOSITIVE_DYNAMIC_TOR",
"FALSEPOSITIVE_DEADSITE",
"E_SOCKS", "E_POLICY", "E_NETUNREACH", "E_HOSTUNREACH", "E_REFUSED",
- "E_TIMEOUT", "E_NOCONTENT", "E_CRYPTO", "E_URL", "E_MISC",
+ "E_TIMEOUT", "E_SLOWXFER", "E_NOCONTENT", "E_CRYPTO", "E_URL", "E_MISC",
+ # Exception classes
+ "SlowXferException",
]
@@ -105,6 +107,7 @@ FAILURE_CONNERROR = "FailureConnError"
FAILURE_URLERROR = "FailureURLError"
FAILURE_CRYPTOERROR = "FailureCryptoError"
FAILURE_TIMEOUT = "FailureTimeout"
+FAILURE_SLOWXFER = "FailureSlowXfer"
FAILURE_HEADERCHANGE = "FailureHeaderChange"
FAILURE_MISCEXCEPTION = "FailureMiscException"
@@ -121,6 +124,7 @@ E_NETUNREACH = -3.0
E_HOSTUNREACH = -4.0
E_REFUSED = -5.0
E_TIMEOUT = -6.0
+E_SLOWXFER = -7.0
E_NOCONTENT = -13.0
E_CRYPTO = -14.0
E_URL = -15.0
@@ -1134,3 +1138,6 @@ class JSSoupDiffer(JSDiffer):
ast_cnts = JSSoupDiffer._add_cnts(tag_cnts, ast_cnts)
return ast_cnts
+
+class SlowXferException(Exception):
+ pass
diff --git a/NetworkScanners/ExitAuthority/soat.py b/NetworkScanners/ExitAuthority/soat.py
index 7bacd4c..f649294 100755
--- a/NetworkScanners/ExitAuthority/soat.py
+++ b/NetworkScanners/ExitAuthority/soat.py
@@ -1210,6 +1210,13 @@ class HTTPTest(SearchBasedTest):
result = HttpTestResult(self.node_map[exit_node[1:]],
address, TEST_FAILURE, fail_reason)
return self.register_timeout_failure(result)
+ elif pcode == E_SLOWXFER: # Transfer too slow
+ # TODO: This still calls register_timeout_failure, I think that's ok
+ # but it should probably be discussed.
+ fail_reason = FAILURE_SLOWXFER
+ result = HttpTestResult(self.node_map[exit_node[1:]],
+ address, TEST_FAILURE, fail_reason)
+ return self.register_timeout_failure(result)
elif pcode == E_NOCONTENT:
fail_reason = FAILURE_NOEXITCONTENT
result = HttpTestResult(self.node_map[exit_node[1:]],
@@ -2615,10 +2622,11 @@ def decompress_response_data(response):
plog("DEBUG", "Read "+str(len_read)+"/"+str(tot_len))
# Wait 5 seconds before counting data
- rate = (float(len_read)/(now-start)) #B/s
- if (now-start) > 5 and rate < min_rate:
- plog("WARN", "Minimum xfer rate not maintained. Aborting xfer")
- raise socket.timeout("Rate: %.2f KB/s" % (rate/1024))
+ if (now-start) > 5:
+ rate = (float(len_read)/(now-start)) #B/s
+ if rate < min_rate:
+ plog("WARN", "Minimum xfer rate not maintained. Aborting xfer")
+ raise SlowXferException("Rate: %.2f KB/s" % (rate/1024))
if not data_read:
break
--
1.7.1