From c7f4f36c8af02156505b4c15856da8f542ea7a5f Mon Sep 17 00:00:00 2001 From: meejah Date: Fri, 13 Nov 2020 21:30:23 -0700 Subject: [PATCH] merge config --- src/allmydata/client.py | 12 ------------ src/allmydata/storage_client.py | 21 ++++++++++++++++++--- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/allmydata/client.py b/src/allmydata/client.py index 006b0eed3..b2b819916 100644 --- a/src/allmydata/client.py +++ b/src/allmydata/client.py @@ -92,9 +92,6 @@ _client_config = configutil.ValidConfiguration( ), "grid_managers": None, # means "any options valid" "grid_manager_certificates": None, - "drop_upload": ( # deprecated already? - "enabled", - ), "ftpd": ( "accounts.file", "accounts.url", @@ -560,14 +557,6 @@ def create_storage_farm_broker(config, default_connection_handlers, foolscap_con **kwargs ) - # grid manager setup - - grid_manager_keys = [] - for name, gm_key in config.enumerate_section('grid_managers').items(): - grid_manager_keys.append( - ed25519.verifying_key_from_string(gm_key.encode("ascii")) - ) - # we don't actually use this keypair for anything (yet) as far # as I can see. # my_pubkey = keyutil.parse_pubkey( @@ -581,7 +570,6 @@ def create_storage_farm_broker(config, default_connection_handlers, foolscap_con tub_maker=tub_creator, node_config=config, storage_client_config=storage_client_config, - grid_manager_keys=grid_manager_keys, # XXX maybe roll into above storage_client_config? ) for ic in introducer_clients: sb.use_introducer(ic) diff --git a/src/allmydata/storage_client.py b/src/allmydata/storage_client.py index bb5039f46..aa8431e05 100644 --- a/src/allmydata/storage_client.py +++ b/src/allmydata/storage_client.py @@ -74,6 +74,9 @@ from allmydata.interfaces import ( from allmydata.grid_manager import ( create_grid_manager_verifier, ) +from allmydata.crypto import ( + ed25519, +) from allmydata.util import log, base32, connection_status from allmydata.util.assertutil import precondition from allmydata.util.observer import ObserverList @@ -111,9 +114,15 @@ class StorageClientConfig(object): :ivar dict[unicode, dict[unicode, unicode]] storage_plugins: A mapping from names of ``IFoolscapStoragePlugin`` configured in *tahoe.cfg* to the respective configuration. + + :ivar list[ed25519.VerifyKey] grid_manager_keys: with no keys in + this list, we'll upload to any storage server. Otherwise, we will + only upload to a storage-server that has a valid certificate + signed by at least one of these keys. """ preferred_peers = attr.ib(default=()) storage_plugins = attr.ib(default=attr.Factory(dict)) + grid_manager_keys = attr.ib(default=attr.Factory(list)) @classmethod def from_node_config(cls, config): @@ -145,9 +154,17 @@ class StorageClientConfig(object): plugin_config = [] storage_plugins[plugin_name] = dict(plugin_config) + grid_manager_keys = [] + for name, gm_key in config.enumerate_section('grid_managers').items(): + grid_manager_keys.append( + ed25519.verifying_key_from_string(gm_key.encode("ascii")) + ) + + return cls( preferred_peers, storage_plugins, + grid_manager_keys, ) @@ -173,13 +190,11 @@ class StorageFarmBroker(service.MultiService): tub_maker, node_config, storage_client_config=None, - grid_manager_keys=None, ): service.MultiService.__init__(self) assert permute_peers # False not implemented yet self.permute_peers = permute_peers self._tub_maker = tub_maker - self._grid_manager_keys = grid_manager_keys if grid_manager_keys else list() self.node_config = node_config @@ -268,7 +283,7 @@ class StorageFarmBroker(service.MultiService): assert isinstance(server_id, bytes) handler_overrides = server.get("connections", {}) gm_verifier = create_grid_manager_verifier( - self._grid_manager_keys, + self.storage_client_config.grid_manager_keys, server["ann"].get("grid-manager-certificates", []), )