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

Commit

Permalink
Set tor.config attrs instead of setting the object,
Browse files Browse the repository at this point in the history
when connecting to tor.
Move tor_config initialization inside of if launch_tor to make it
less confussing when we are using TorConfig
  • Loading branch information
juga0 committed Mar 22, 2018
1 parent 416555a commit 353ebac
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions bwscanner/attacher.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,12 @@ def connect_to_tor(launch_tor, circuit_build_timeout, control_port=None,
if tor_overrides:
tor_options.update(tor_overrides)

tor_config = txtorcon.TorConfig()

# Update Tor config options from dictionary
for key, value in tor_options.items():
setattr(tor_config, key, value)

if launch_tor:
log.info("Spawning a new Tor instance.")
tor_config = txtorcon.TorConfig()
# Update tor config options from dictionary
for key, value in tor_options.items():
setattr(tor_config, key, value)
# TODO: Pass in data_dir directory so consensus can be cached
# Launch tor with config, in order to don't get CONF_CHANGED when
# updating options that can't be changed while tor is running.
Expand All @@ -179,7 +177,8 @@ def connect_to_tor(launch_tor, circuit_build_timeout, control_port=None,
tor = yield txtorcon.connect(reactor, endpoint)
# TODO: check whether CONF_CHANGED will happen here or not because
# we get the state later
tor.config = tor_config
for key, value in tor_options.items():
setattr(tor.config, key, value)
tor.config.save()

wait_for_consensus = options_need_new_consensus(tor_config, tor_options)
Expand Down

0 comments on commit 353ebac

Please sign in to comment.