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

Commit cb6c636

Browse files
committed
Add tor directory parameter to launch_tor
1 parent 943e003 commit cb6c636

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
@@ -158,8 +158,7 @@ def connect_to_tor(launch_tor, circuit_build_timeout, control_port=None,
158158

159159
if launch_tor:
160160
log.info("Spawning a new Tor instance.")
161-
# TODO: Pass in data_dir directory so consensus can be cached
162-
tor = yield txtorcon.launch(reactor)
161+
tor = yield txtorcon.launch(reactor, data_directory=tor_dir)
163162
else:
164163
log.info("Trying to connect to a running Tor instance.")
165164
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)