mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-29 17:28:53 +00:00
Make the Tor/I2P "provider" interfaces explicit
This commit is contained in:
parent
733223c8d7
commit
0cdf66a991
@ -3173,3 +3173,21 @@ class IAnnounceableStorageServer(Interface):
|
||||
:type: ``IReferenceable`` provider
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
class IAddressFamily(Interface):
|
||||
"""
|
||||
Support for one specific address family.
|
||||
|
||||
This stretches the definition of address family to include things like Tor
|
||||
and I2P.
|
||||
"""
|
||||
def get_listener():
|
||||
"""
|
||||
Return a string endpoint description or an ``IStreamServerEndpoint``.
|
||||
"""
|
||||
|
||||
def get_client_endpoint():
|
||||
"""
|
||||
Return an ``IStreamClientEndpoint``.
|
||||
"""
|
||||
|
@ -2,11 +2,18 @@
|
||||
from __future__ import absolute_import, print_function, with_statement
|
||||
import os
|
||||
|
||||
from zope.interface import (
|
||||
implementer,
|
||||
)
|
||||
|
||||
from twisted.internet.defer import inlineCallbacks, returnValue
|
||||
from twisted.internet.endpoints import clientFromString
|
||||
from twisted.internet.error import ConnectionRefusedError, ConnectError
|
||||
from twisted.application import service
|
||||
|
||||
from ..interfaces import (
|
||||
IAddressFamily,
|
||||
)
|
||||
|
||||
def create(reactor, config):
|
||||
"""
|
||||
@ -135,6 +142,7 @@ def create_config(reactor, cli_config):
|
||||
returnValue((tahoe_config_i2p, i2p_port, i2p_location))
|
||||
|
||||
|
||||
@implementer(IAddressFamily)
|
||||
class _Provider(service.MultiService):
|
||||
def __init__(self, config, reactor):
|
||||
service.MultiService.__init__(self)
|
||||
@ -160,7 +168,7 @@ class _Provider(service.MultiService):
|
||||
(privkeyfile, external_port, escaped_sam_port)
|
||||
return i2p_port
|
||||
|
||||
def get_i2p_handler(self):
|
||||
def get_client_endpoint(self):
|
||||
enabled = self._get_i2p_config("enabled", True, boolean=True)
|
||||
if not enabled:
|
||||
return None
|
||||
@ -188,6 +196,9 @@ class _Provider(service.MultiService):
|
||||
|
||||
return self._i2p.default(self._reactor, keyfile=keyfile)
|
||||
|
||||
# Backwards compatibility alias
|
||||
get_i2p_handler = get_client_endpoint
|
||||
|
||||
def check_dest_config(self):
|
||||
if self._get_i2p_config("dest", False, boolean=True):
|
||||
if not self._txi2p:
|
||||
|
@ -2,6 +2,10 @@
|
||||
from __future__ import absolute_import, print_function, with_statement
|
||||
import os
|
||||
|
||||
from zope.interface import (
|
||||
implementer,
|
||||
)
|
||||
|
||||
from twisted.internet.defer import inlineCallbacks, returnValue
|
||||
from twisted.internet.endpoints import clientFromString, TCP4ServerEndpoint
|
||||
from twisted.internet.error import ConnectionRefusedError, ConnectError
|
||||
@ -9,7 +13,9 @@ from twisted.application import service
|
||||
|
||||
from .observer import OneShotObserverList
|
||||
from .iputil import allocate_tcp_port
|
||||
|
||||
from ..interfaces import (
|
||||
IAddressFamily,
|
||||
)
|
||||
|
||||
def create(reactor, config):
|
||||
"""
|
||||
@ -209,6 +215,7 @@ def create_config(reactor, cli_config):
|
||||
returnValue((tahoe_config_tor, tor_port, tor_location))
|
||||
|
||||
|
||||
@implementer(IAddressFamily)
|
||||
class _Provider(service.MultiService):
|
||||
def __init__(self, config, reactor):
|
||||
service.MultiService.__init__(self)
|
||||
@ -228,7 +235,7 @@ class _Provider(service.MultiService):
|
||||
ep = TCP4ServerEndpoint(self._reactor, local_port, interface="127.0.0.1")
|
||||
return ep
|
||||
|
||||
def get_tor_handler(self):
|
||||
def get_client_endpoint(self):
|
||||
enabled = self._get_tor_config("enabled", True, boolean=True)
|
||||
if not enabled:
|
||||
return None
|
||||
@ -253,6 +260,9 @@ class _Provider(service.MultiService):
|
||||
|
||||
return self._tor.default_socks()
|
||||
|
||||
# Backwards compatibility alias
|
||||
get_tor_handler = get_client_endpoint
|
||||
|
||||
@inlineCallbacks
|
||||
def _make_control_endpoint(self, reactor, update_status):
|
||||
# this will only be called when tahoe.cfg has "[tor] launch = true"
|
||||
|
Loading…
Reference in New Issue
Block a user