Add changes to actually make it work
This commit is contained in:
parent
2d92a74a59
commit
5a4684b01b
|
@ -1,4 +1,5 @@
|
||||||
import asyncio
|
import time
|
||||||
|
import threading
|
||||||
import logging
|
import logging
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
import simplejson as json
|
import simplejson as json
|
||||||
|
@ -33,11 +34,13 @@ DATABASE['relay-list'] = following
|
||||||
if 'actors' in DATABASE:
|
if 'actors' in DATABASE:
|
||||||
DATABASE.pop('actors')
|
DATABASE.pop('actors')
|
||||||
|
|
||||||
async def database_save():
|
def database_save():
|
||||||
|
global DATABASE
|
||||||
|
time.sleep(60)
|
||||||
while True:
|
while True:
|
||||||
|
logging.info('written database file {}'.format(CONFIG['db']))
|
||||||
with open(CONFIG['db'], 'w') as f:
|
with open(CONFIG['db'], 'w') as f:
|
||||||
json.dump(DATABASE, f)
|
json.dump(DATABASE, f)
|
||||||
await asyncio.sleep(30)
|
time.sleep(1800)
|
||||||
|
|
||||||
|
threading.Thread(target=database_save).start()
|
||||||
asyncio.ensure_future(database_save())
|
|
||||||
|
|
|
@ -96,6 +96,7 @@ async def fetch_actor_key(actor):
|
||||||
|
|
||||||
|
|
||||||
async def validate(actor, request):
|
async def validate(actor, request):
|
||||||
|
print(actor)
|
||||||
pubkey = await fetch_actor_key(actor)
|
pubkey = await fetch_actor_key(actor)
|
||||||
if not pubkey:
|
if not pubkey:
|
||||||
return False
|
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')
|
raise aiohttp.web.HTTPUnauthorized(body='signature check failed, no actor in message')
|
||||||
|
|
||||||
actor = data["actor"]
|
actor = data["actor"]
|
||||||
|
print(data)
|
||||||
if not (await validate(actor, request)):
|
if not (await validate(actor, request)):
|
||||||
logging.info('Signature validation failed for: %r', actor)
|
logging.info('Signature validation failed for: %r', actor)
|
||||||
raise aiohttp.web.HTTPUnauthorized(body='signature check failed, signature did not match key')
|
raise aiohttp.web.HTTPUnauthorized(body='signature check failed, signature did not match key')
|
||||||
|
|
Loading…
Reference in New Issue