From fbcef2d1ae7f0893e4e4dc55066baa0b01feff4e Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Mon, 27 Mar 2023 13:32:40 -0400 Subject: [PATCH] Safely customize the Tor introducer's configuration Previously we clobbered the whole generated configuration and potentially wiped out additional important fields. Now we modify the configuration by just changing the fields we need to change. --- integration/conftest.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/integration/conftest.py b/integration/conftest.py index 33e7998c1..54632be26 100644 --- a/integration/conftest.py +++ b/integration/conftest.py @@ -43,7 +43,7 @@ from .util import ( generate_ssh_key, block_with_timeout, ) - +from allmydata.node import read_config # pytest customization hooks @@ -275,13 +275,6 @@ def introducer_furl(introducer, temp_dir): include_result=False, ) def tor_introducer(reactor, temp_dir, flog_gatherer, request): - config = ''' -[node] -nickname = introducer_tor -web.port = 4561 -log_gatherer.furl = {log_furl} -'''.format(log_furl=flog_gatherer) - intro_dir = join(temp_dir, 'introducer_tor') print("making introducer", intro_dir) @@ -301,9 +294,11 @@ log_gatherer.furl = {log_furl} ) pytest_twisted.blockon(done_proto.done) - # over-write the config file with our stuff - with open(join(intro_dir, 'tahoe.cfg'), 'w') as f: - f.write(config) + # adjust a few settings + config = read_config(intro_dir, "tub.port") + config.set_config("node", "nickname", "introducer-tor") + config.set_config("node", "web.port", "4561") + config.set_config("node", "log_gatherer.furl", flog_gatherer) # "tahoe run" is consistent across Linux/macOS/Windows, unlike the old # "start" command.