create-node: avoid introducer.furl=None

Previously, "tahoe create-node" without an --introducer= argument would
result in the literal string "None" being written into tahoe.cfg:

 [client]
 introducer.furl = None

We were using config.get("introducer",""), but that didn't suffice because
the key was actually present: it just had a value of None, which then got
stringified into "None" when writing out tahoe.cfg.

This briefly caused test/cli/test_create to fail, as the startup code tried
to parse "None" as a FURL. This only happened against a development version
of Foolscap which accidentally became sensitive to unparseable FURLs in
started Reconnectors. I fixed that in the final foolscap-0.12.5 release, so
we shouldn't hit this bug, but I wanted to fix it properly in the tahoe-side
source.
This commit is contained in:
Brian Warner 2016-12-07 17:51:07 -08:00
parent d5f3d47483
commit 6879622894
2 changed files with 6 additions and 1 deletions

View File

@ -256,6 +256,10 @@ class Client(node.Node, pollmixin.PollMixin):
# read furl from tahoe.cfg # read furl from tahoe.cfg
tahoe_cfg_introducer_furl = self.get_config("client", "introducer.furl", None) tahoe_cfg_introducer_furl = self.get_config("client", "introducer.furl", None)
if tahoe_cfg_introducer_furl == "None":
raise ValueError("tahoe.cfg has invalid 'introducer.furl = None':"
" to disable it, use 'introducer.furl ='"
" or omit the key entirely")
if tahoe_cfg_introducer_furl: if tahoe_cfg_introducer_furl:
introducers[u'default'] = {'furl':tahoe_cfg_introducer_furl} introducers[u'default'] = {'furl':tahoe_cfg_introducer_furl}

View File

@ -279,7 +279,8 @@ def write_node_config(c, config):
def write_client_config(c, config): def write_client_config(c, config):
c.write("[client]\n") c.write("[client]\n")
c.write("# Which services should this client connect to?\n") c.write("# Which services should this client connect to?\n")
c.write("introducer.furl = %s\n" % config.get("introducer", "")) introducer = config.get("introducer", None) or ""
c.write("introducer.furl = %s\n" % introducer)
c.write("helper.furl =\n") c.write("helper.furl =\n")
c.write("#stats_gatherer.furl =\n") c.write("#stats_gatherer.furl =\n")
c.write("\n") c.write("\n")