Merge PR394: pass I2P keyfile to foolscap

closes tahoe-lafs/tahoe-lafs#394
This commit is contained in:
Brian Warner 2017-01-17 20:13:29 -05:00
commit 7453bdae84
4 changed files with 8 additions and 6 deletions

View File

@ -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 <https://bugs.launchpad.net/pycrypto/+bug/620253>

View File

@ -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):

View File

@ -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):

View File

@ -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):