mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-23 23:02:25 +00:00
get rid of is_tub_listening
This commit is contained in:
parent
a82aa4ba2c
commit
edc50f655b
@ -229,7 +229,7 @@ def create_client_from_config(config, _client_factory=None):
|
||||
default_connection_handlers, foolscap_connection_handlers = handlers
|
||||
tub_options = node.create_tub_options(config)
|
||||
|
||||
main_tub, is_listening = node.create_main_tub(
|
||||
main_tub = node.create_main_tub(
|
||||
config, tub_options, default_connection_handlers,
|
||||
foolscap_connection_handlers, i2p_provider, tor_provider,
|
||||
)
|
||||
@ -249,7 +249,6 @@ def create_client_from_config(config, _client_factory=None):
|
||||
tor_provider,
|
||||
introducer_clients,
|
||||
storage_broker,
|
||||
tub_is_listening=is_listening,
|
||||
)
|
||||
i2p_provider.setServiceParent(client)
|
||||
tor_provider.setServiceParent(client)
|
||||
@ -376,11 +375,11 @@ class _Client(node.Node, pollmixin.PollMixin):
|
||||
}
|
||||
|
||||
def __init__(self, config, main_tub, control_tub, i2p_provider, tor_provider, introducer_clients,
|
||||
storage_farm_broker, tub_is_listening):
|
||||
storage_farm_broker):
|
||||
"""
|
||||
Use create_client() to instantiate one of these.
|
||||
"""
|
||||
node.Node.__init__(self, config, main_tub, control_tub, i2p_provider, tor_provider, tub_is_listening)
|
||||
node.Node.__init__(self, config, main_tub, control_tub, i2p_provider, tor_provider)
|
||||
|
||||
self._magic_folders = dict()
|
||||
self.started_timestamp = time.time()
|
||||
@ -403,7 +402,7 @@ class _Client(node.Node, pollmixin.PollMixin):
|
||||
self.load_static_servers()
|
||||
self.helper = None
|
||||
if config.get_config("helper", "enabled", False, boolean=True):
|
||||
if not self._tub_is_listening:
|
||||
if not self._is_tub_listening():
|
||||
raise ValueError("config error: helper is enabled, but tub "
|
||||
"is not listening ('tub.port=' is empty)")
|
||||
self.init_helper()
|
||||
@ -488,7 +487,7 @@ class _Client(node.Node, pollmixin.PollMixin):
|
||||
# should we run a storage server (and publish it for others to use)?
|
||||
if not self.config.get_config("storage", "enabled", True, boolean=True):
|
||||
return
|
||||
if not self._tub_is_listening:
|
||||
if not self._is_tub_listening():
|
||||
raise ValueError("config error: storage is enabled, but tub "
|
||||
"is not listening ('tub.port=' is empty)")
|
||||
readonly = self.config.get_config("storage", "readonly", False, boolean=True)
|
||||
|
@ -62,7 +62,7 @@ def create_introducer(basedir=u"."):
|
||||
# outbound connections.
|
||||
i2p_provider = None
|
||||
tor_provider = None
|
||||
main_tub, is_listening = create_main_tub(
|
||||
main_tub = create_main_tub(
|
||||
config, tub_options, default_connection_handlers,
|
||||
foolscap_connection_handlers, i2p_provider, tor_provider,
|
||||
)
|
||||
@ -74,7 +74,6 @@ def create_introducer(basedir=u"."):
|
||||
control_tub,
|
||||
i2p_provider,
|
||||
tor_provider,
|
||||
tub_is_listening=is_listening,
|
||||
)
|
||||
return defer.succeed(node)
|
||||
|
||||
@ -82,15 +81,15 @@ def create_introducer(basedir=u"."):
|
||||
class _IntroducerNode(node.Node):
|
||||
NODETYPE = "introducer"
|
||||
|
||||
def __init__(self, config, main_tub, control_tub, i2p_provider, tor_provider, tub_is_listening):
|
||||
node.Node.__init__(self, config, main_tub, control_tub, i2p_provider, tor_provider, tub_is_listening)
|
||||
def __init__(self, config, main_tub, control_tub, i2p_provider, tor_provider):
|
||||
node.Node.__init__(self, config, main_tub, control_tub, i2p_provider, tor_provider)
|
||||
self.init_introducer()
|
||||
webport = self.get_config("node", "web.port", None)
|
||||
if webport:
|
||||
self.init_web(webport) # strports string
|
||||
|
||||
def init_introducer(self):
|
||||
if not self._tub_is_listening:
|
||||
if not self._is_tub_listening():
|
||||
raise ValueError("config error: we are Introducer, but tub "
|
||||
"is not listening ('tub.port=' is empty)")
|
||||
introducerservice = IntroducerService()
|
||||
|
@ -624,15 +624,12 @@ def create_main_tub(config, tub_options,
|
||||
port_or_endpoint = port
|
||||
tub.listenOn(port_or_endpoint)
|
||||
tub.setLocation(location)
|
||||
tub_is_listening = True
|
||||
log.msg("Tub location set to %s" % (location,))
|
||||
# the Tub is now ready for tub.registerReference()
|
||||
else:
|
||||
tub_is_listening = False
|
||||
log.msg("Tub is not listening")
|
||||
|
||||
# XXX can we get rid of the tub_is_listening part?
|
||||
return tub, tub_is_listening
|
||||
return tub
|
||||
|
||||
|
||||
def create_control_tub():
|
||||
@ -657,14 +654,13 @@ class Node(service.MultiService):
|
||||
CERTFILE = "node.pem"
|
||||
GENERATED_FILES = []
|
||||
|
||||
def __init__(self, config, main_tub, control_tub, i2p_provider, tor_provider, tub_is_listening):
|
||||
def __init__(self, config, main_tub, control_tub, i2p_provider, tor_provider):
|
||||
"""
|
||||
Initialize the node with the given configuration. Its base directory
|
||||
is the current directory by default.
|
||||
"""
|
||||
service.MultiService.__init__(self)
|
||||
|
||||
self._tub_is_listening = tub_is_listening # holdover; do we really need this?
|
||||
self.config = config
|
||||
self.get_config = config.get_config # XXX stopgap
|
||||
self.nickname = config.nickname # XXX stopgap
|
||||
@ -696,6 +692,12 @@ class Node(service.MultiService):
|
||||
self.log("Node constructed. " + get_package_versions_string())
|
||||
iputil.increase_rlimits()
|
||||
|
||||
def _is_tub_listening(self):
|
||||
"""
|
||||
:returns: True if the main tub is listening
|
||||
"""
|
||||
return len(self.tub.getListeners()) > 0
|
||||
|
||||
def init_tempdir(self):
|
||||
"""
|
||||
Initialize/create a directory for temporary files.
|
||||
|
@ -201,7 +201,6 @@ def create_no_network_client(basedir):
|
||||
tor_provider=None,
|
||||
introducer_clients=[],
|
||||
storage_farm_broker=storage_broker,
|
||||
tub_is_listening=True,
|
||||
)
|
||||
storage_broker.client = client
|
||||
return defer.succeed(client)
|
||||
@ -216,6 +215,9 @@ def create_no_network_client(basedir):
|
||||
|
||||
class _NoNetworkClient(_Client):
|
||||
|
||||
def _is_tub_listening(self):
|
||||
return True
|
||||
|
||||
def init_connections(self):
|
||||
pass
|
||||
def create_main_tub(self):
|
||||
|
@ -52,7 +52,7 @@ def testing_tub(config_data=''):
|
||||
default_connection_handlers, foolscap_connection_handlers = handlers
|
||||
tub_options = create_tub_options(config)
|
||||
|
||||
main_tub, is_listening = create_main_tub(
|
||||
main_tub = create_main_tub(
|
||||
config, tub_options, default_connection_handlers,
|
||||
foolscap_connection_handlers, i2p_provider, tor_provider,
|
||||
cert_filename='DEFAULT_CERTFILE_BLANK'
|
||||
|
Loading…
Reference in New Issue
Block a user