__init__.py 1.2 KB
Newer Older
kaniini's avatar
kaniini committed
1 2 3 4 5 6
from . import logging


import asyncio
import aiohttp
import aiohttp.web
kaniini's avatar
kaniini committed
7 8 9 10
import yaml


def load_config():
kaniini's avatar
kaniini committed
11
    with open('relay.yaml') as f:
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
        yaml_file = yaml.load(f)
        whitelist = yaml_file['ap'].get('whitelist', [])
        blocked = yaml_file['ap'].get('blocked_instances', [])

        config = {
            'db': yaml_file.get('db', 'relay.jsonld'),
            'listen': yaml_file.get('listen', '0.0.0.0'),
            'port': int(yaml_file.get('port', 8080)),
            'note': yaml_file.get('note', 'Make a note about your instance here.'),
            'ap': {
                'blocked_instances': [] if blocked is None else blocked,
                'host': yaml_file['ap'].get('host', 'localhost'),
                'whitelist': [] if whitelist is None else whitelist,
                'whitelist_enabled': yaml_file['ap'].get('whitelist_enabled', False)
            }
        }
        return config
kaniini's avatar
kaniini committed
29 30 31


CONFIG = load_config()
kaniini's avatar
kaniini committed
32 33


kaniini's avatar
kaniini committed
34 35 36 37 38 39
from .http_signatures import http_signatures_middleware


app = aiohttp.web.Application(middlewares=[
    http_signatures_middleware
])
kaniini's avatar
kaniini committed
40 41


kaniini's avatar
kaniini committed
42
from . import database
kaniini's avatar
kaniini committed
43
from . import actor
44
from . import webfinger
45
from . import default
46
from . import nodeinfo
kaniini's avatar
kaniini committed
47
from . import http_stats