From 3c22a3ce50df11355367c169e8465235f5070240 Mon Sep 17 00:00:00 2001 From: David Stainton Date: Mon, 9 Jan 2017 17:24:08 +0000 Subject: [PATCH 1/2] Set tcp = tor only if txtorcon is imported for i2p this means tcp = none as long as txtorcon is not imported --- src/allmydata/scripts/create_node.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/allmydata/scripts/create_node.py b/src/allmydata/scripts/create_node.py index 2598b013c..2db74f877 100644 --- a/src/allmydata/scripts/create_node.py +++ b/src/allmydata/scripts/create_node.py @@ -214,7 +214,10 @@ def write_node_config(c, config): if config["hide-ip"]: c.write("[connections]\n") - c.write("tcp = tor\n") + if tor_provider._import_txtorcon(): + c.write("tcp = tor\n") + else: + c.write("tcp = none\n") c.write("\n") c.write("[node]\n") From ee586378139d2a4394367cadaad3922a1931320b Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Tue, 10 Jan 2017 12:25:08 -0800 Subject: [PATCH 2/2] fix syntax (tcp=disabled, not =none), add test --- src/allmydata/scripts/create_node.py | 2 +- src/allmydata/test/cli/test_create.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/allmydata/scripts/create_node.py b/src/allmydata/scripts/create_node.py index 2db74f877..7a2aff85b 100644 --- a/src/allmydata/scripts/create_node.py +++ b/src/allmydata/scripts/create_node.py @@ -217,7 +217,7 @@ def write_node_config(c, config): if tor_provider._import_txtorcon(): c.write("tcp = tor\n") else: - c.write("tcp = none\n") + c.write("tcp = disabled\n") c.write("\n") c.write("[node]\n") diff --git a/src/allmydata/test/cli/test_create.py b/src/allmydata/test/cli/test_create.py index b1a565ea9..174a7097e 100644 --- a/src/allmydata/test/cli/test_create.py +++ b/src/allmydata/test/cli/test_create.py @@ -109,6 +109,18 @@ class Config(unittest.TestCase): self.assertEqual(cfg.getboolean("node", "reveal-IP-address"), False) self.assertEqual(cfg.get("connections", "tcp"), "tor") + @defer.inlineCallbacks + def test_client_hide_ip_no_txtorcon(self): + txtorcon = mock.patch('allmydata.util.tor_provider._import_txtorcon', + return_value=None) + with txtorcon: + basedir = self.mktemp() + rc, out, err = yield run_cli("create-client", "--hide-ip", basedir) + self.assertEqual(0, rc) + cfg = read_config(basedir) + self.assertEqual(cfg.getboolean("node", "reveal-IP-address"), False) + self.assertEqual(cfg.get("connections", "tcp"), "disabled") + @defer.inlineCallbacks def test_client_basedir_exists(self): basedir = self.mktemp()