]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
move convergence secret into SecretHolder, next to lease secret
authorBrian Warner <warner@lothar.com>
Wed, 18 Nov 2009 01:54:44 +0000 (17:54 -0800)
committerBrian Warner <warner@lothar.com>
Wed, 18 Nov 2009 01:54:44 +0000 (17:54 -0800)
src/allmydata/client.py
src/allmydata/test/test_filenode.py
src/allmydata/test/test_helper.py
src/allmydata/test/test_mutable.py
src/allmydata/test/test_upload.py
src/allmydata/test/test_web.py

index 93e1eb4ee89f034b848c9ff3b1017625e5c90bca..1cf1af577da28448678d4eb0adaac3e1db4ba5ac 100644 (file)
@@ -38,8 +38,9 @@ def _make_secret():
     return base32.b2a(os.urandom(hashutil.CRYPTO_VAL_SIZE)) + "\n"
 
 class SecretHolder:
-    def __init__(self, lease_secret):
+    def __init__(self, lease_secret, convergence_secret):
         self._lease_secret = lease_secret
+        self._convergence_secret = convergence_secret
 
     def get_renewal_secret(self):
         return hashutil.my_renewal_secret_hash(self._lease_secret)
@@ -47,6 +48,9 @@ class SecretHolder:
     def get_cancel_secret(self):
         return hashutil.my_cancel_secret_hash(self._lease_secret)
 
+    def get_convergence_secret(self):
+        return self._convergence_secret
+
 class KeyGenerator:
     def __init__(self):
         self._remote = None
@@ -108,7 +112,7 @@ class Client(node.Node, pollmixin.PollMixin):
         self.DEFAULT_ENCODING_PARAMETERS = self.DEFAULT_ENCODING_PARAMETERS.copy()
         self.init_introducer_client()
         self.init_stats_provider()
-        self.init_lease_secret()
+        self.init_secrets()
         self.init_storage()
         self.init_control()
         self.helper = None
@@ -179,10 +183,13 @@ class Client(node.Node, pollmixin.PollMixin):
     def get_stats(self):
         return { 'node.uptime': time.time() - self.started_timestamp }
 
-    def init_lease_secret(self):
-        secret_s = self.get_or_create_private_config("secret", _make_secret)
-        lease_secret = base32.a2b(secret_s)
-        self._secret_holder = SecretHolder(lease_secret)
+    def init_secrets(self):
+        lease_s = self.get_or_create_private_config("secret", _make_secret)
+        lease_secret = base32.a2b(lease_s)
+        convergence_s = self.get_or_create_private_config('convergence',
+                                                          _make_secret)
+        self.convergence = base32.a2b(convergence_s)
+        self._secret_holder = SecretHolder(lease_secret, self.convergence)
 
     def init_storage(self):
         # should we run a storage server (and publish it for others to use)?
@@ -255,8 +262,6 @@ class Client(node.Node, pollmixin.PollMixin):
         DEP["k"] = int(self.get_config("client", "shares.needed", DEP["k"]))
         DEP["n"] = int(self.get_config("client", "shares.total", DEP["n"]))
         DEP["happy"] = int(self.get_config("client", "shares.happy", DEP["happy"]))
-        convergence_s = self.get_or_create_private_config('convergence', _make_secret)
-        self.convergence = base32.a2b(convergence_s)
 
         self.init_client_storage_broker()
         self.history = History(self.stats_provider)
index 1639c33378dc345941991a1a90647c849e6b3afd..24aaa70ae104d21150fa524725d04fe50f8904dd 100644 (file)
@@ -21,7 +21,7 @@ class FakeClient:
         return None
     def get_history(self):
         return None
-    _secret_holder = client.SecretHolder("lease secret")
+    _secret_holder = client.SecretHolder("lease secret", "convergence secret")
 
 class Node(unittest.TestCase):
     def test_chk_filenode(self):
index 4b0c16cbe0fb2ee029657ac0463a468f4338f589..399b2ec88f75ddd4b70267cdd178e0ee07d4f57f 100644 (file)
@@ -90,7 +90,7 @@ class AssistedUpload(unittest.TestCase):
     def setUp(self):
         self.s = FakeClient()
         self.storage_broker = StorageFarmBroker(None, True)
-        self.secret_holder = client.SecretHolder("lease secret")
+        self.secret_holder = client.SecretHolder("lease secret", "convergence")
         self.s.startService()
 
         self.tub = t = Tub()
index 20d5f1cc5fd04827de0b6e261484db6e23dd8e72..7b7c0990f66aa0603dc5a16e5abccfef4c9c5d84 100644 (file)
@@ -196,7 +196,7 @@ def make_storagebroker(s=None, num_peers=10):
 
 def make_nodemaker(s=None, num_peers=10):
     storage_broker = make_storagebroker(s, num_peers)
-    sh = client.SecretHolder("lease secret")
+    sh = client.SecretHolder("lease secret", "convergence secret")
     keygen = client.KeyGenerator()
     keygen.set_default_keysize(522)
     nodemaker = NodeMaker(storage_broker, sh, None,
index 8af3487e74e7664dfcb34e7de5533bf82eb6e42b..c3b65eca9e4ce80d047bf62a7e3ffc3a8972c7ee 100644 (file)
@@ -187,7 +187,7 @@ class FakeClient:
         return self.DEFAULT_ENCODING_PARAMETERS
     def get_storage_broker(self):
         return self.storage_broker
-    _secret_holder = client.SecretHolder("lease secret")
+    _secret_holder = client.SecretHolder("lease secret", "convergence secret")
 
 class GotTooFarError(Exception):
     pass
index 2555d17abb980ec15cea09d3b01ae1b510f83f11..a2f52b1bc86659f1567a99d05e1624d061ff41ae 100644 (file)
@@ -25,7 +25,7 @@ import common_util as testutil
 from allmydata.test.no_network import GridTestMixin
 from allmydata.test.common_web import HTTPClientGETFactory, \
      HTTPClientHEADFactory
-from allmydata.client import Client
+from allmydata.client import Client, SecretHolder
 
 # create a fake uploader/downloader, and a couple of fake dirnodes, then
 # create a webserver that works against them
@@ -93,7 +93,7 @@ class FakeClient(Client):
         self.nickname = "fake_nickname"
         self.introducer_furl = "None"
         self.stats_provider = FakeStatsProvider()
-        self._secret_holder = None
+        self._secret_holder = SecretHolder("lease secret", "convergence secret")
         self.helper = None
         self.convergence = "some random string"
         self.storage_broker = StorageFarmBroker(None, permute_peers=True)
@@ -101,7 +101,7 @@ class FakeClient(Client):
         self.history = FakeHistory()
         self.uploader = FakeUploader()
         self.uploader.setServiceParent(self)
-        self.nodemaker = FakeNodeMaker(None, None, None,
+        self.nodemaker = FakeNodeMaker(None, self._secret_holder, None,
                                        self.uploader, None, None,
                                        None, None)