From f397e10b04a5b94f6346122244f9a58e2053d65c Mon Sep 17 00:00:00 2001 From: Izalia Mae Date: Thu, 10 Nov 2022 12:38:08 -0500 Subject: [PATCH] reset config on load --- relay/config.py | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/relay/config.py b/relay/config.py index b363580..fd22f22 100644 --- a/relay/config.py +++ b/relay/config.py @@ -32,27 +32,15 @@ class RelayConfig(DotDict): def __init__(self, path, is_docker): + DotDict.__init__(self, {}) + if is_docker: path = '/data/relay.yaml' self._isdocker = is_docker self._path = Path(path).expanduser() - super().__init__({ - 'db': str(self._path.parent.joinpath(f'{self._path.stem}.jsonld')), - 'listen': '0.0.0.0', - 'port': 8080, - 'note': 'Make a note about your instance here.', - 'push_limit': 512, - 'host': 'relay.example.com', - 'blocked_software': [], - 'blocked_instances': [], - 'whitelist': [], - 'whitelist_enabled': False, - 'json': 1024, - 'objects': 1024, - 'digests': 1024 - }) + self.reset() def __setitem__(self, key, value): @@ -96,6 +84,24 @@ class RelayConfig(DotDict): return f'{self.actor}#main-key' + def reset(self): + self.clear() + self.update({ + 'db': str(self._path.parent.joinpath(f'{self._path.stem}.jsonld')), + 'listen': '0.0.0.0', + 'port': 8080, + 'note': 'Make a note about your instance here.', + 'push_limit': 512, + 'host': 'relay.example.com', + 'blocked_software': [], + 'blocked_instances': [], + 'whitelist': [], + 'whitelist_enabled': False, + 'json': 1024, + 'objects': 1024, + 'digests': 1024 + }) + def ban_instance(self, instance): if instance.startswith('http'): instance = urlparse(instance).hostname @@ -181,6 +187,8 @@ class RelayConfig(DotDict): def load(self): + self.reset() + options = {} try: