Commit 8c066599 authored by Joe Landers's avatar Joe Landers
Browse files

set our own datadir so we can grab obfs4 logs

parent bc4e167f
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
import os
import random
import tempfile
import shutil

from twisted.python import usage
from twisted.internet import reactor, error
@@ -53,6 +54,7 @@ class BridgeReachability(nettest.NetTestCase):
        os.close(fd)
        fd, self.obfsproxy_logfile = tempfile.mkstemp()
        os.close(fd)
        self.tor_datadir = tempfile.mkdtemp()

        self.report['error'] = None
        self.report['success'] = None
@@ -123,6 +125,7 @@ class BridgeReachability(nettest.NetTestCase):
        config = txtorcon.TorConfig()
        config.ControlPort = random.randint(2**14, 2**16)
        config.SocksPort = random.randint(2**14, 2**16)
        config.DataDirectory = self.tor_datadir
        log.msg(
            "Connecting to %s with tor %s" %
            (self.bridge, onion.tor_details['version']))
@@ -208,5 +211,13 @@ class BridgeReachability(nettest.NetTestCase):
            with open(self.obfsproxy_logfile) as f:
                self.report['obfsproxy_log'] = f.read()
            os.remove(self.obfsproxy_logfile)
            try:
                with open(os.path.join(self.tor_datadir,
                        'pt_state', 'obfs4proxy.log')) as f:
                    self.report['obfsproxy_log'] = f.read()
            except:
                pass
            finally:
                shutil.rmtree(self.tor_datadir)

        return d
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ sample_transport_lines = {
    'scramblesuit': 'scramblesuit exec /fakebin --log-min-severity info --log-file /log.txt managed',
    'obfs2': 'obfs2 exec /fakebin --log-min-severity info --log-file /log.txt managed',
    'obfs3': 'obfs3 exec /fakebin --log-min-severity info --log-file /log.txt managed',
    'obfs4': 'obfs4 exec /fakebin' }
    'obfs4': 'obfs4 exec /fakebin --enableLogging=true --logLevel=INFO' }


class TestOnion(unittest.TestCase):
+1 −1
Original line number Diff line number Diff line
@@ -99,7 +99,7 @@ _transport_line_templates = {
        _pyobfsproxy_line('obfs3', bin_loc, log_file),

    'obfs4': lambda bin_loc, log_file: \
        "obfs4 exec %s" % bin_loc }
        "obfs4 exec %s --enableLogging=true --logLevel=INFO" % bin_loc }

class UnrecognizedTransport(Exception):
    pass