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

Commit

Permalink
Merge pull request #77 from juga0/feature/tordir
Browse files Browse the repository at this point in the history
Add tor directory parameter to launch_tor
  • Loading branch information
aagbsn authored Mar 19, 2018
2 parents d935068 + cb6c636 commit 500398f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 2 additions & 3 deletions bwscanner/attacher.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def got_newconsensus(event):


@defer.inlineCallbacks
def connect_to_tor(launch_tor, circuit_build_timeout, control_port=None,
def connect_to_tor(launch_tor, circuit_build_timeout, tor_dir=None, control_port=None,
tor_overrides=None):
"""
Launch or connect to a Tor instance
Expand All @@ -160,8 +160,7 @@ def connect_to_tor(launch_tor, circuit_build_timeout, control_port=None,

if launch_tor:
log.info("Spawning a new Tor instance.")
# TODO: Pass in data_dir directory so consensus can be cached
tor = yield txtorcon.launch(reactor)
tor = yield txtorcon.launch(reactor, data_directory=tor_dir)
else:
log.info("Trying to connect to a running Tor instance.")
if control_port:
Expand Down
4 changes: 3 additions & 1 deletion bwscanner/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class ScanInstance(object):
def __init__(self, data_dir):
self.data_dir = data_dir
self.measurement_dir = os.path.join(data_dir, 'measurements')
self.tor_dir = os.path.join(data_dir, 'tor_data')

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

# Create a connection to a Tor instance
ctx.obj.tor_state = connect_to_tor(launch_tor, circuit_build_timeout)
ctx.obj.tor_state = connect_to_tor(launch_tor, circuit_build_timeout,
ctx.obj.tor_dir)

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

0 comments on commit 500398f

Please sign in to comment.