[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [ooni-probe/master] Also add obfsproxy version to the bridge reachability test report.



commit b67df141e2d7cff6a7a318407cd779801a82c7c8
Author: Arturo Filastò <art@xxxxxxxxx>
Date:   Tue Aug 19 13:48:06 2014 +0200

    Also add obfsproxy version to the bridge reachability test report.
    
    Raise exception if obfsproxy is older than 0.2
---
 ooni/nettests/blocking/bridge_reachability.py |    9 ++++++-
 ooni/oonicli.py                               |    2 ++
 ooni/utils/onion.py                           |   31 +++++++++++++++++++++----
 3 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/ooni/nettests/blocking/bridge_reachability.py b/ooni/nettests/blocking/bridge_reachability.py
index 7f10f0c..f4d5bf1 100644
--- a/ooni/nettests/blocking/bridge_reachability.py
+++ b/ooni/nettests/blocking/bridge_reachability.py
@@ -64,12 +64,13 @@ class BridgeReachability(nettest.NetTestCase):
         self.report['tor_progress_tag'] = None
         self.report['tor_progress_summary'] = None
         self.report['tor_log'] = None
+        self.report['obfsproxy_version'] = str(onion.obfsproxy_details['version'])
         self.report['bridge_address'] = None
 
         self.bridge = self.input
         if self.input.startswith('Bridge'):
             self.bridge = self.input.replace('Bridge ', '')
-        self.pyobfsproxy_bin = find_executable('obfsproxy')
+        self.pyobfsproxy_bin = onion.obfsproxy_details['binary']
         self.fteproxy_bin = find_executable('fteproxy')
 
     def postProcessor(self, measurements):
@@ -143,6 +144,12 @@ class BridgeReachability(nettest.NetTestCase):
         elif transport_name and self.pyobfsproxy_bin:
             config.ClientTransportPlugin = "%s exec %s managed" % (
                 transport_name, self.pyobfsproxy_bin)
+            if onion.OBFSProxyVersion('0.2') > onion.obfsproxy_details['version']:
+                log.err(
+                    "The obfsproxy version you are using appears to be outdated."
+                )
+                self.report['error'] = 'old-obfsproxy'
+                return
             log.debug("Using pyobfsproxy from %s" % self.pyobfsproxy_bin)
             self.report['transport_name'] = transport_name
             self.report['bridge_address'] = self.bridge.split(' ')[1]
diff --git a/ooni/oonicli.py b/ooni/oonicli.py
index f8cf849..6505584 100644
--- a/ooni/oonicli.py
+++ b/ooni/oonicli.py
@@ -201,6 +201,8 @@ def runWithDirector(logging=True, start_tor=True, check_incoherences=True):
         print e.net_test_loader.usageOptions().getUsage()
         sys.exit(4)
     except Exception as e:
+        if config.advanced.debug:
+            log.exception(e)
         log.err(e)
         sys.exit(5)
 
diff --git a/ooni/utils/onion.py b/ooni/utils/onion.py
index cb490b3..09e104c 100644
--- a/ooni/utils/onion.py
+++ b/ooni/utils/onion.py
@@ -1,5 +1,6 @@
 import string
 import subprocess
+from distutils.spawn import find_executable
 from distutils.version import LooseVersion
 
 from txtorcon.util import find_tor_binary as tx_find_tor_binary
@@ -11,28 +12,43 @@ class TorVersion(LooseVersion):
     pass
 
 
+class OBFSProxyVersion(LooseVersion):
+    pass
+
+
 def find_tor_binary():
     if config.advanced.tor_binary:
         return config.advanced.tor_binary
     return tx_find_tor_binary()
 
 
-def tor_version():
-    tor_binary = find_tor_binary()
-    if not tor_binary:
+def executable_version(binary, strip=lambda x: x):
+    if not binary:
         return None
     try:
-        proc = subprocess.Popen((tor_binary, '--version'),
+        proc = subprocess.Popen((binary, '--version'),
                                 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     except OSError:
         pass
     else:
         stdout, _ = proc.communicate()
         if proc.poll() == 0 and stdout != '':
-            return TorVersion(stdout.strip().split(' ')[2])
+            version = stdout.strip()
+            return LooseVersion(strip(version))
     return None
 
 
+def tor_version():
+    version = executable_version(find_tor_binary(),
+                                 lambda x: x.split(' ')[2])
+    return TorVersion(str(version))
+
+
+def obfsproxy_version():
+    version = executable_version(find_executable('obfsproxy'))
+    return OBFSProxyVersion(str(version))
+
+
 def transport_name(address):
     """
     If the address of the bridge starts with a valid c identifier then
@@ -53,3 +69,8 @@ tor_details = {
     'binary': find_tor_binary(),
     'version': tor_version()
 }
+
+obfsproxy_details = {
+    'binary': find_executable('obfsproxy'),
+    'version': obfsproxy_version()
+}



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits