From 998af5c26ee92cdf8c9b67546c85c296c418685c Mon Sep 17 00:00:00 2001 From: str4d Date: Wed, 11 Jan 2017 07:01:36 +1300 Subject: [PATCH 1/3] Pass I2P keyfile to foolscap If no session management is performed, txi2p starts a process-wide session the first time a connection (client or server) is opened; all subsequent connections use that session and its configuration properties. This commit ensures that the same properties are passed to both client and server endpoints, so that the correct I2P Destination is started regardless of whether the first connection made by Tahoe-LAFS is for a client or server. Closes #2858. --- src/allmydata/util/i2p_provider.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/allmydata/util/i2p_provider.py b/src/allmydata/util/i2p_provider.py index 91391e24c..10777e16a 100644 --- a/src/allmydata/util/i2p_provider.py +++ b/src/allmydata/util/i2p_provider.py @@ -147,13 +147,14 @@ class Provider(service.MultiService): sam_port = self._get_i2p_config("sam.port", None) launch = self._get_i2p_config("launch", False, boolean=True) configdir = self._get_i2p_config("i2p.configdir", None) + keyfile = self._get_i2p_config("dest.private_key_file", None) if sam_port: if launch: raise ValueError("tahoe.cfg [i2p] must not set both " "sam.port and launch") ep = clientFromString(self._reactor, sam_port) - return self._i2p.sam_endpoint(ep) + return self._i2p.sam_endpoint(ep, keyfile=keyfile) if launch: executable = self._get_i2p_config("i2p.executable", None) @@ -162,7 +163,7 @@ class Provider(service.MultiService): if configdir: return self._i2p.local_i2p(configdir) - return self._i2p.default(self._reactor) + return self._i2p.default(self._reactor, keyfile=keyfile) def check_dest_config(self): if self._get_i2p_config("dest", False, boolean=True): From 6db7686a8fff21cf1b04b438d46d1e4bc0042f50 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Tue, 17 Jan 2017 11:47:47 -0500 Subject: [PATCH 2/3] update tests to match --- src/allmydata/test/test_connections.py | 2 +- src/allmydata/test/test_i2p_provider.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/allmydata/test/test_connections.py b/src/allmydata/test/test_connections.py index c336a5c3c..fff0e55ea 100644 --- a/src/allmydata/test/test_connections.py +++ b/src/allmydata/test/test_connections.py @@ -158,7 +158,7 @@ class I2P(unittest.TestCase): with mock.patch("foolscap.connections.i2p.default", return_value=h1) as f: h = n._make_i2p_handler() - self.assertEqual(f.mock_calls, [mock.call(reactor)]) + self.assertEqual(f.mock_calls, [mock.call(reactor, keyfile=None)]) self.assertIdentical(h, h1) def test_samport(self): diff --git a/src/allmydata/test/test_i2p_provider.py b/src/allmydata/test/test_i2p_provider.py index 50fb7995f..242c7c444 100644 --- a/src/allmydata/test/test_i2p_provider.py +++ b/src/allmydata/test/test_i2p_provider.py @@ -221,7 +221,7 @@ class Provider(unittest.TestCase): h = p.get_i2p_handler() cfs.assert_called_with(reactor, "ep_desc") self.assertIs(h, handler) - i2p.sam_endpoint.assert_called_with(ep) + i2p.sam_endpoint.assert_called_with(ep, keyfile=None) def test_handler_launch(self): i2p = mock.Mock() @@ -292,7 +292,7 @@ class Provider(unittest.TestCase): p = i2p_provider.Provider("basedir", FakeConfig(), reactor) h = p.get_i2p_handler() self.assertIs(h, handler) - i2p.default.assert_called_with(reactor) + i2p.default.assert_called_with(reactor, keyfile=None) class Provider_CheckI2PConfig(unittest.TestCase): def test_default(self): From be6e0a9c29d14859dbe4e33e7fda275580ca87df Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Tue, 17 Jan 2017 16:05:23 -0500 Subject: [PATCH 3/3] deps: we need foolscap-0.12.6 for the new I2P API --- src/allmydata/_auto_deps.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/allmydata/_auto_deps.py b/src/allmydata/_auto_deps.py index 8a37bd34b..a4b165572 100644 --- a/src/allmydata/_auto_deps.py +++ b/src/allmydata/_auto_deps.py @@ -42,7 +42,8 @@ install_requires = [ # * foolscap >= 0.12.3 provides tcp/tor/i2p connection handlers we need, # and allocate_tcp_port # * foolscap >= 0.12.5 has ConnectionInfo and ReconnectionInfo - "foolscap >= 0.12.5", + # * foolscap >= 0.12.6 has an i2p.sam_endpoint() that takes kwargs + "foolscap >= 0.12.6", # Needed for SFTP. # pycrypto 2.2 doesn't work due to