Skip to content
This repository was archived by the owner on Mar 2, 2022. It is now read-only.

Commit 500398f

Browse files
authored
Merge pull request #77 from juga0/feature/tordir
Add tor directory parameter to launch_tor
2 parents d935068 + cb6c636 commit 500398f

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

bwscanner/attacher.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def got_newconsensus(event):
135135

136136

137137
@defer.inlineCallbacks
138-
def connect_to_tor(launch_tor, circuit_build_timeout, control_port=None,
138+
def connect_to_tor(launch_tor, circuit_build_timeout, tor_dir=None, control_port=None,
139139
tor_overrides=None):
140140
"""
141141
Launch or connect to a Tor instance
@@ -160,8 +160,7 @@ def connect_to_tor(launch_tor, circuit_build_timeout, control_port=None,
160160

161161
if launch_tor:
162162
log.info("Spawning a new Tor instance.")
163-
# TODO: Pass in data_dir directory so consensus can be cached
164-
tor = yield txtorcon.launch(reactor)
163+
tor = yield txtorcon.launch(reactor, data_directory=tor_dir)
165164
else:
166165
log.info("Trying to connect to a running Tor instance.")
167166
if control_port:

bwscanner/scanner.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class ScanInstance(object):
2121
def __init__(self, data_dir):
2222
self.data_dir = data_dir
2323
self.measurement_dir = os.path.join(data_dir, 'measurements')
24+
self.tor_dir = os.path.join(data_dir, 'tor_data')
2425

2526
def __repr__(self):
2627
return '<BWScan %r>' % self.data_dir
@@ -58,7 +59,8 @@ def cli(ctx, data_dir, loglevel, logfile, launch_tor, circuit_build_timeout):
5859
os.makedirs(ctx.obj.measurement_dir)
5960

6061
# Create a connection to a Tor instance
61-
ctx.obj.tor_state = connect_to_tor(launch_tor, circuit_build_timeout)
62+
ctx.obj.tor_state = connect_to_tor(launch_tor, circuit_build_timeout,
63+
ctx.obj.tor_dir)
6264

6365
# Set up the logger to only output log lines of level `loglevel` and above.
6466
setup_logging(log_level=loglevel, log_name=logfile)

0 commit comments

Comments
 (0)