[tor-commits] [ooni-probe/master] clean up checking for outdated versions
art at torproject.org
art at torproject.org
Fri Mar 27 10:32:29 UTC 2015
commit 9ffbbc32975ed5b60ddcbdb5928b7af1813a24d7
Author: Joe Landers <joe at joelanders.net>
Date: Fri Feb 27 19:52:32 2015 +0100
clean up checking for outdated versions
---
ooni/nettests/blocking/bridge_reachability.py | 13 ++-----------
ooni/tests/test_onion.py | 20 +++++++++++++++++++-
ooni/utils/onion.py | 15 +++++++++++++++
3 files changed, 36 insertions(+), 12 deletions(-)
diff --git a/ooni/nettests/blocking/bridge_reachability.py b/ooni/nettests/blocking/bridge_reachability.py
index 8ec1bf9..5d9dc96 100644
--- a/ooni/nettests/blocking/bridge_reachability.py
+++ b/ooni/nettests/blocking/bridge_reachability.py
@@ -151,21 +151,12 @@ class BridgeReachability(nettest.NetTestCase):
bin_name)
self.report['error'] = "missing-%s" % bin_name
return
-
- if onion.OBFSProxyVersion('0.2') > \
- onion.obfsproxy_details['version']:
+ except onion.OutdatedObfsproxy:
log.err("The obfsproxy version you are using " \
"appears to be outdated.")
self.report['error'] = 'old-obfsproxy'
return
-
- if transport_name == 'scramblesuit' and \
- onion.TorVersion('0.2.5.1') > onion.tor_details['version']:
- log.err("Unsupported Tor version.")
- self.report['error'] = 'unsupported-tor-version'
- return
-
- if onion.TorVersion('0.2.4.1') > onion.tor_details['version']:
+ except onion.OutdatedTor:
log.err("Unsupported Tor version.")
self.report['error'] = 'unsupported-tor-version'
return
diff --git a/ooni/tests/test_onion.py b/ooni/tests/test_onion.py
index 6dce5fc..30fd26d 100644
--- a/ooni/tests/test_onion.py
+++ b/ooni/tests/test_onion.py
@@ -1,6 +1,6 @@
from twisted.trial import unittest
from ooni.utils import onion
-from mock import Mock
+from mock import Mock, patch
sample_transport_lines = {
'fte': 'fte exec /fakebin --managed',
@@ -30,3 +30,21 @@ class TestOnion(unittest.TestCase):
for transport, exp_line in sample_transport_lines.iteritems():
self.assertEqual(onion.bridge_line(transport, '/log.txt'),
exp_line)
+
+ with patch.dict(onion.obfsproxy_details,
+ {'version': onion.OBFSProxyVersion('0.1.12')}):
+ self.assertRaises(onion.OutdatedObfsproxy,
+ onion.bridge_line, 'obfs2', '/log.txt')
+
+ with patch.dict(onion.tor_details,
+ {'version': onion.TorVersion('0.2.4.20')}):
+ onion.bridge_line('fte', '/log.txt')
+ self.assertRaises(onion.OutdatedTor,
+ onion.bridge_line, 'scramblesuit', '/log.txt')
+ self.assertRaises(onion.OutdatedTor,
+ onion.bridge_line, 'obfs4', '/log.txt')
+
+ with patch.dict(onion.tor_details,
+ {'version': onion.TorVersion('0.2.3.20')}):
+ self.assertRaises(onion.OutdatedTor,
+ onion.bridge_line, 'fte', '/log.txt')
diff --git a/ooni/utils/onion.py b/ooni/utils/onion.py
index 6476636..ec0a8b4 100644
--- a/ooni/utils/onion.py
+++ b/ooni/utils/onion.py
@@ -105,6 +105,10 @@ class UnrecognizedTransport(Exception):
pass
class UninstalledTransport(Exception):
pass
+class OutdatedObfsproxy(Exception):
+ pass
+class OutdatedTor(Exception):
+ pass
def bridge_line(transport, log_file):
bin_name = transport_bin_name.get(transport)
@@ -115,4 +119,15 @@ def bridge_line(transport, log_file):
if not bin_loc:
raise UninstalledTransport
+ if OBFSProxyVersion('0.2') > obfsproxy_details['version']:
+ raise OutdatedObfsproxy
+
+ if (transport == 'scramblesuit' or \
+ bin_name == 'obfs4proxy') and \
+ TorVersion('0.2.5.1') > tor_details['version']:
+ raise OutdatedTor
+
+ if TorVersion('0.2.4.1') > tor_details['version']:
+ raise OutdatedTor
+
return _transport_line_templates[transport](bin_loc, log_file)
More information about the tor-commits
mailing list