diff --git a/bwscanner/attacher.py b/bwscanner/attacher.py index b6f3580..a7541f6 100644 --- a/bwscanner/attacher.py +++ b/bwscanner/attacher.py @@ -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. @@ -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)