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

Commit 3c845df

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

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

bwscanner/attacher.py

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

137137
@defer.inlineCallbacks
138138
def connect_to_tor(launch_tor, circuit_build_timeout, control_port=None,
139-
tor_overrides=None):
139+
tor_overrides=None, tor_dir=None):
140140
"""
141141
Launch or connect to a Tor instance
142142
@@ -159,7 +159,7 @@ def connect_to_tor(launch_tor, circuit_build_timeout, control_port=None,
159159
if launch_tor:
160160
log.info("Spawning a new Tor instance.")
161161
# TODO: Pass in data_dir directory so consensus can be cached
162-
tor = yield txtorcon.launch(reactor)
162+
tor = yield txtorcon.launch(reactor, data_directory=tor_dir)
163163
else:
164164
log.info("Trying to connect to a running Tor instance.")
165165
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, 'tordata')
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)