Fri Jul 9 18:33:59 BST 2010 writefaruq@gmail.com * enable_client_with_multi_introducer.dpatch Using this patch client can read a config file basedir/intoducers that contains the furls of introducers one per line. Client uses these furls along with the furl from tahoe.cfg to connect to the introducers. Statuses of these connections are listed in client's welcome page. New patches: [enable_client_with_multi_introducer.dpatch writefaruq@gmail.com**20100709173359 Ignore-this: 2b4c9553b2c150ee8ba3c5d86cf148fd Using this patch client can read a config file basedir/intoducers that contains the furls of introducers one per line. Client uses these furls along with the furl from tahoe.cfg to connect to the introducers. Statuses of these connections are listed in client's welcome page. ] { hunk ./src/allmydata/client.py 34 TiB=1024*GiB PiB=1024*TiB +MULTI_INTRODUCERS_CFG = "introducers" + class StubClient(Referenceable): implements(RIStubClient) hunk ./src/allmydata/client.py 128 self.started_timestamp = time.time() self.logSource="Client" self.DEFAULT_ENCODING_PARAMETERS = self.DEFAULT_ENCODING_PARAMETERS.copy() - self.init_introducer_client() + self.init_introducer_clients() self.init_stats_provider() self.init_secrets() self.init_storage() hunk ./src/allmydata/client.py 175 if os.path.exists(os.path.join(self.basedir, "run_helper")): self.set_config("helper", "enabled", "true") - def init_introducer_client(self): - self.introducer_furl = self.get_config("client", "introducer.furl") - ic = IntroducerClient(self.tub, self.introducer_furl, + def init_introducer_clients(self): + # read first furl from tahoe.cfg + introducer_furl1 = self.get_config("client", "introducer.furl", None) + self.introducer_furls = [] + if introducer_furl1: + self.introducer_furls.append(introducer_furl1) + # read from ""BASEDIR/introducers" cfg file + cfg = os.path.join(self.basedir, MULTI_INTRODUCERS_CFG) + if os.path.exists(cfg): + f = open(cfg, 'r') + for introducer_furl in f.read().split('\n'): + if not introducer_furl.strip(): + continue + self.introducer_furls.append(introducer_furl) + f.close() + # create a pool of introducer_clients + self.introducer_clients = [] + for introducer_furl in self.introducer_furls: + ic = IntroducerClient(self.tub, introducer_furl, self.nickname, str(allmydata.__full_version__), str(self.OLDEST_SUPPORTED_VERSION)) hunk ./src/allmydata/client.py 197 - self.introducer_client = ic + self.introducer_clients.append(ic) + # init introducer_clients as usual + for ic in self.introducer_clients: + self.init_introducer_client(ic) + + def init_introducer_client(self, ic): # hold off on starting the IntroducerClient until our tub has been # started, so we'll have a useful address on our RemoteReference, so # that the introducer's status page will show us. hunk ./src/allmydata/client.py 290 furl_file = os.path.join(self.basedir, "private", "storage.furl") furl = self.tub.registerReference(ss, furlFile=furl_file) ri_name = RIStorageServer.__remote_name__ - self.introducer_client.publish(furl, "storage", ri_name) + # Now, publish our multi-introducers + for ic in self.introducer_clients: + ic.publish(furl, "storage", ri_name) d.addCallback(_publish) d.addErrback(log.err, facility="tahoe.init", level=log.BAD, umid="aLGBKw") hunk ./src/allmydata/client.py 346 # check to see if we're supposed to use the introducer too if self.get_config("client-server-selection", "use_introducer", default=True, boolean=True): - sb.use_introducer(self.introducer_client) + + # Now, use our multi-introducers + for ic in self.introducer_clients: + sb.use_introducer(ic) def get_storage_broker(self): return self.storage_broker hunk ./src/allmydata/client.py 362 sc = StubClient() furl = self.tub.registerReference(sc) ri_name = RIStubClient.__remote_name__ - self.introducer_client.publish(furl, "stub_client", ri_name) + # Now publish our multiple introducers + for ic in self.introducer_clients: + ic.publish(furl, "stub_client", ri_name) d = self.when_tub_ready() d.addCallback(_publish) d.addErrback(log.err, facility="tahoe.init", hunk ./src/allmydata/client.py 476 def get_encoding_parameters(self): return self.DEFAULT_ENCODING_PARAMETERS - + + # In case we configure multiple introducers def connected_to_introducer(self): hunk ./src/allmydata/client.py 479 - if self.introducer_client: - return self.introducer_client.connected_to_introducer() - return False - + status = [] + if self.introducer_clients: + s = False + for ic in self.introducer_clients: + s = ic.connected_to_introducer() + status.append(s) + return status + def get_renewal_secret(self): # this will go away return self._secret_holder.get_renewal_secret() hunk ./src/allmydata/web/root.py 220 return ctx.tag[ul] - def data_introducer_furl(self, ctx, data): - return self.client.introducer_furl - def data_connected_to_introducer(self, ctx, data): - if self.client.connected_to_introducer(): - return "yes" - return "no" + # In case we configure multiple introducers + def data_introducers(self, ctx, data): + connection_status = self.client.connected_to_introducer() + s = [] + furls = self.client.introducer_furls + for furl in furls: + i = furls.index(furl) + if connection_status[i]: + s.append( (furl, "Yes") ) + else: + s.append( (furl, "No") ) + s.sort() + return s + + def render_introducers_row(self, ctx, s): + (furl, connected) = s + #connected = + ctx.fillSlots("introducer_furl", "%s" % (furl)) + ctx.fillSlots("connected", "%s" % (connected)) + return ctx.tag def data_helper_furl(self, ctx, data): try: hunk ./src/allmydata/web/welcome.xhtml 25
Introducer FURL | +Connected? | +
no introducers! |