From 5a4684b01b8ad9356446d32aaabc75ad1d5a3791 Mon Sep 17 00:00:00 2001 From: Bastard Operator Date: Mon, 13 Dec 2021 23:31:40 +0100 Subject: [PATCH] Add changes to actually make it work --- relay/database.py | 13 ++++++++----- relay/http_signatures.py | 2 ++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/relay/database.py b/relay/database.py index 03e2719..11a1139 100644 --- a/relay/database.py +++ b/relay/database.py @@ -1,4 +1,5 @@ -import asyncio +import time +import threading import logging import urllib.parse import simplejson as json @@ -33,11 +34,13 @@ DATABASE['relay-list'] = following if 'actors' in DATABASE: DATABASE.pop('actors') -async def database_save(): +def database_save(): + global DATABASE + time.sleep(60) while True: + logging.info('written database file {}'.format(CONFIG['db'])) with open(CONFIG['db'], 'w') as f: json.dump(DATABASE, f) - await asyncio.sleep(30) + time.sleep(1800) - -asyncio.ensure_future(database_save()) +threading.Thread(target=database_save).start() diff --git a/relay/http_signatures.py b/relay/http_signatures.py index 377f468..075247c 100644 --- a/relay/http_signatures.py +++ b/relay/http_signatures.py @@ -96,6 +96,7 @@ async def fetch_actor_key(actor): async def validate(actor, request): + print(actor) pubkey = await fetch_actor_key(actor) if not pubkey: return False @@ -137,6 +138,7 @@ async def http_signatures_middleware(app, handler): raise aiohttp.web.HTTPUnauthorized(body='signature check failed, no actor in message') actor = data["actor"] + print(data) if not (await validate(actor, request)): logging.info('Signature validation failed for: %r', actor) raise aiohttp.web.HTTPUnauthorized(body='signature check failed, signature did not match key')