mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-06-18 23:38:18 +00:00
Add a multi-introducer implementation
this is based the previous work of warner, killyourtv and leif fixes ticket #68
This commit is contained in:
@ -185,7 +185,7 @@ class Client(node.Node, pollmixin.PollMixin):
|
||||
self.started_timestamp = time.time()
|
||||
self.logSource="Client"
|
||||
self.encoding_params = self.DEFAULT_ENCODING_PARAMETERS.copy()
|
||||
self.init_introducer_client()
|
||||
self.init_introducer_clients()
|
||||
self.init_stats_provider()
|
||||
self.init_secrets()
|
||||
self.init_node_key()
|
||||
@ -234,17 +234,40 @@ class Client(node.Node, pollmixin.PollMixin):
|
||||
nonce = _make_secret().strip()
|
||||
return seqnum, nonce
|
||||
|
||||
def init_introducer_client(self):
|
||||
self.introducer_furl = self.get_config("client", "introducer.furl")
|
||||
introducer_cache_filepath = FilePath(os.path.join(self.basedir, "private", "introducer_cache.yaml"))
|
||||
ic = IntroducerClient(self.tub, self.introducer_furl,
|
||||
self.nickname,
|
||||
str(allmydata.__full_version__),
|
||||
str(self.OLDEST_SUPPORTED_VERSION),
|
||||
self.get_app_versions(),
|
||||
self._sequencer, introducer_cache_filepath)
|
||||
self.introducer_client = ic
|
||||
ic.setServiceParent(self)
|
||||
def init_introducer_clients(self):
|
||||
self.introducer_clients = []
|
||||
self.introducer_furls = []
|
||||
|
||||
introducers_yaml_filename = os.path.join(self.basedir, "private", "introducers.yaml")
|
||||
introducers_filepath = FilePath(introducers_yaml_filename)
|
||||
|
||||
try:
|
||||
with introducers_filepath.open() as f:
|
||||
introducers_yaml = yamlutil.safe_load(f)
|
||||
introducers = introducers_yaml.get("introducers", {})
|
||||
log.msg("found %d introducers in private/introducers.yaml" %
|
||||
len(introducers))
|
||||
except EnvironmentError:
|
||||
introducers = {}
|
||||
|
||||
if "default" in introducers.keys():
|
||||
raise ValueError("'default' introducer furl cannot be specified in introducers.yaml; please fix impossible configuration.")
|
||||
|
||||
# read furl from tahoe.cfg
|
||||
tahoe_cfg_introducer_furl = self.get_config("client", "introducer.furl", None)
|
||||
if tahoe_cfg_introducer_furl:
|
||||
introducers[u'default'] = {'furl':tahoe_cfg_introducer_furl}
|
||||
|
||||
for petname, introducer in introducers.items():
|
||||
introducer_cache_filepath = FilePath(os.path.join(self.basedir, "private", "introducer_{}_cache.yaml".format(petname)))
|
||||
ic = IntroducerClient(self.tub, introducer['furl'],
|
||||
self.nickname,
|
||||
str(allmydata.__full_version__),
|
||||
str(self.OLDEST_SUPPORTED_VERSION),
|
||||
self.get_app_versions(), self._sequencer, introducer_cache_filepath)
|
||||
self.introducer_clients.append(ic)
|
||||
self.introducer_furls.append(introducer['furl'])
|
||||
ic.setServiceParent(self)
|
||||
|
||||
def init_stats_provider(self):
|
||||
gatherer_furl = self.get_config("client", "stats_gatherer.furl", None)
|
||||
@ -365,7 +388,8 @@ class Client(node.Node, pollmixin.PollMixin):
|
||||
ann = {"anonymous-storage-FURL": furl,
|
||||
"permutation-seed-base32": self._init_permutation_seed(ss),
|
||||
}
|
||||
self.introducer_client.publish("storage", ann, self._node_key)
|
||||
for ic in self.introducer_clients:
|
||||
ic.publish("storage", ann, self._node_key)
|
||||
|
||||
def init_client(self):
|
||||
helper_furl = self.get_config("client", "helper.furl", None)
|
||||
@ -422,8 +446,8 @@ class Client(node.Node, pollmixin.PollMixin):
|
||||
)
|
||||
self.storage_broker = sb
|
||||
sb.setServiceParent(self)
|
||||
|
||||
sb.use_introducer(self.introducer_client)
|
||||
for ic in self.introducer_clients:
|
||||
sb.use_introducer(ic)
|
||||
|
||||
def get_storage_broker(self):
|
||||
return self.storage_broker
|
||||
@ -574,10 +598,11 @@ class Client(node.Node, pollmixin.PollMixin):
|
||||
def get_encoding_parameters(self):
|
||||
return self.encoding_params
|
||||
|
||||
def introducer_connection_statuses(self):
|
||||
return [ic.connected_to_introducer() for ic in self.introducer_clients]
|
||||
|
||||
def connected_to_introducer(self):
|
||||
if self.introducer_client:
|
||||
return self.introducer_client.connected_to_introducer()
|
||||
return False
|
||||
return any([ic.connected_to_introducer() for ic in self.introducer_clients])
|
||||
|
||||
def get_renewal_secret(self): # this will go away
|
||||
return self._secret_holder.get_renewal_secret()
|
||||
|
Reference in New Issue
Block a user