summary refs log tree commit diff
path: root/synapse/config/key.py
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-04-24 11:26:19 +0100
committerMark Haines <mark.haines@matrix.org>2015-04-24 11:26:19 +0100
commitb1e68add1992d0072aa37f3bdf07dc226200fe5d (patch)
tree13e7f781892d10206c521978fce43bc4b3e6c0fc /synapse/config/key.py
parentCopyright notice (diff)
downloadsynapse-b1e68add1992d0072aa37f3bdf07dc226200fe5d.tar.xz
Add a config file for perspective servers
Diffstat (limited to 'synapse/config/key.py')
-rw-r--r--synapse/config/key.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/synapse/config/key.py b/synapse/config/key.py
index 327105732a..de4e33a7f3 100644
--- a/synapse/config/key.py
+++ b/synapse/config/key.py
@@ -27,6 +27,9 @@ class KeyConfig(Config):
             args.old_signing_key_path
         )
         self.key_refresh_interval = args.key_refresh_interval
+        self.perspectives = self.read_perspectives(
+            args.perspectives_config_path
+        )
 
     @classmethod
     def add_arguments(cls, parser):
@@ -45,6 +48,15 @@ class KeyConfig(Config):
                                     " Used to set the exipiry in /key/v2/."
                                     " Controls how frequently servers will"
                                     " query what keys are still valid")
+        key_group.add_argument("--perspectives-config-path",
+                               help="The trusted servers to download signing"
+                                    " keys from")
+
+    def read_perspectives(self, perspectives_config_path):
+        servers = self.read_yaml_file(
+            perspectives_config_path, "perspectives_config_path"
+        )
+        return servers
 
     def read_signing_key(self, signing_key_path):
         signing_keys = self.read_file(signing_key_path, "signing_key")
@@ -108,3 +120,10 @@ class KeyConfig(Config):
         if not os.path.exists(args.old_signing_key_path):
             with open(args.old_signing_key_path, "w"):
                 pass
+
+        if not args.perspectives_config_path:
+            args.perspectives_config_path = base_key_name + ".perspectives"
+
+        if not os.path.exists(args.perspectives_config_path):
+            with open(args.perspectives_config_path, "w") as perspectives_file:
+                perspectives_file.write("@@@")