mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-09 03:44:23 +00:00
tor_provider.get_listener(): return a real endpoint, instead of a descriptor
get_listener() is allowed to return either, and the Tor provider is currently simple enough to not really need more than a basic descriptor, but have it return a full Endpoint for use as an example of what I2P can do later.
This commit is contained in:
parent
d713e0e57d
commit
1f1afe65ec
@ -408,8 +408,13 @@ class ProviderListener(unittest.TestCase):
|
||||
p = tor_provider.Provider("basedir",
|
||||
FakeConfig(**{"onion.local_port": "321"}),
|
||||
reactor)
|
||||
fake_ep = object()
|
||||
with mock.patch("allmydata.util.tor_provider.TCP4ServerEndpoint",
|
||||
return_value=fake_ep) as e:
|
||||
endpoint_or_description = p.get_listener()
|
||||
self.assertEqual(endpoint_or_description, "tcp:321:interface=127.0.0.1")
|
||||
self.assertIs(endpoint_or_description, fake_ep)
|
||||
self.assertEqual(e.mock_calls, [mock.call(reactor, 321,
|
||||
interface="127.0.0.1")])
|
||||
|
||||
class Provider_CheckOnionConfig(unittest.TestCase):
|
||||
def test_default(self):
|
||||
|
@ -3,7 +3,7 @@ from __future__ import absolute_import, print_function, with_statement
|
||||
import os
|
||||
|
||||
from twisted.internet.defer import inlineCallbacks, returnValue
|
||||
from twisted.internet.endpoints import clientFromString
|
||||
from twisted.internet.endpoints import clientFromString, TCP4ServerEndpoint
|
||||
from twisted.internet.error import ConnectionRefusedError, ConnectError
|
||||
from twisted.application import service
|
||||
|
||||
@ -217,9 +217,9 @@ class Provider(service.MultiService):
|
||||
return self._node_for_config.get_config("tor", *args, **kwargs)
|
||||
|
||||
def get_listener(self):
|
||||
local_port = self._get_tor_config("onion.local_port")
|
||||
tor_port = "tcp:%s:interface=127.0.0.1" % local_port
|
||||
return tor_port
|
||||
local_port = int(self._get_tor_config("onion.local_port"))
|
||||
ep = TCP4ServerEndpoint(self._reactor, local_port, interface="127.0.0.1")
|
||||
return ep
|
||||
|
||||
def get_tor_handler(self):
|
||||
enabled = self._get_tor_config("enabled", True, boolean=True)
|
||||
|
Loading…
x
Reference in New Issue
Block a user