mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
Add a config file for perspective servers
This commit is contained in:
parent
31e262e6b4
commit
b1e68add19
@ -77,6 +77,17 @@ class Config(object):
|
|||||||
with open(file_path) as file_stream:
|
with open(file_path) as file_stream:
|
||||||
return file_stream.read()
|
return file_stream.read()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def read_yaml_file(cls, file_path, config_name):
|
||||||
|
cls.check_file(file_path, config_name)
|
||||||
|
with open(file_path) as file_stream:
|
||||||
|
try:
|
||||||
|
return yaml.load(file_stream)
|
||||||
|
except Exception as e:
|
||||||
|
raise ConfigError(
|
||||||
|
"Error parsing yaml in file %r: " % (file_path,), e
|
||||||
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def default_path(name):
|
def default_path(name):
|
||||||
return os.path.abspath(os.path.join(os.path.curdir, name))
|
return os.path.abspath(os.path.join(os.path.curdir, name))
|
||||||
|
@ -27,6 +27,9 @@ class KeyConfig(Config):
|
|||||||
args.old_signing_key_path
|
args.old_signing_key_path
|
||||||
)
|
)
|
||||||
self.key_refresh_interval = args.key_refresh_interval
|
self.key_refresh_interval = args.key_refresh_interval
|
||||||
|
self.perspectives = self.read_perspectives(
|
||||||
|
args.perspectives_config_path
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def add_arguments(cls, parser):
|
def add_arguments(cls, parser):
|
||||||
@ -45,6 +48,15 @@ class KeyConfig(Config):
|
|||||||
" Used to set the exipiry in /key/v2/."
|
" Used to set the exipiry in /key/v2/."
|
||||||
" Controls how frequently servers will"
|
" Controls how frequently servers will"
|
||||||
" query what keys are still valid")
|
" 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):
|
def read_signing_key(self, signing_key_path):
|
||||||
signing_keys = self.read_file(signing_key_path, "signing_key")
|
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):
|
if not os.path.exists(args.old_signing_key_path):
|
||||||
with open(args.old_signing_key_path, "w"):
|
with open(args.old_signing_key_path, "w"):
|
||||||
pass
|
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("@@@")
|
||||||
|
Loading…
Reference in New Issue
Block a user