__init__.py 1.26 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:
Izalia Mae's avatar
Izalia Mae committed
12
13
14
15
16
17
18
        options = {}

        ## Prevent a warning message for pyyaml 5.1+
        if getattr(yaml, 'FullLoader', None):
            options['Loader'] = yaml.FullLoader

        yaml_file = yaml.load(f, **options)
19
20
21
22
23
24
25

        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': {
Izalia Mae's avatar
Izalia Mae committed
26
                'blocked_instances': yaml_file['ap'].get('blocked_instances', []),
27
                'host': yaml_file['ap'].get('host', 'localhost'),
Izalia Mae's avatar
Izalia Mae committed
28
                'whitelist': yaml_file['ap'].get('whitelist', []),
29
30
31
32
                'whitelist_enabled': yaml_file['ap'].get('whitelist_enabled', False)
            }
        }
        return config
kaniini's avatar
kaniini committed
33
34
35


CONFIG = load_config()
kaniini's avatar
kaniini committed
36
37


kaniini's avatar
kaniini committed
38
39
40
41
42
43
from .http_signatures import http_signatures_middleware


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


kaniini's avatar
kaniini committed
46
from . import database
kaniini's avatar
kaniini committed
47
from . import actor
48
from . import webfinger
49
from . import default
50
from . import nodeinfo
kaniini's avatar
kaniini committed
51
from . import http_stats