diff --git a/.gitignore b/.gitignore index 18f9b3b..5011ae1 100644 --- a/.gitignore +++ b/.gitignore @@ -96,3 +96,6 @@ ENV/ viera.yaml viera.jsonld + +relay.jsonld +relay.yaml diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..93b6f8b --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: python -m relay diff --git a/app.json b/app.json new file mode 100644 index 0000000..087b641 --- /dev/null +++ b/app.json @@ -0,0 +1,16 @@ +{ + "dokku": { + "volumes": [ + { + "host": "/var/lib/dokku/data/storage/$APP/files", + "app": "/app/files", + "phases": "deploy,run" + } + ] + }, + "scripts": { + "dokku": { + "predeploy": "./bin/pre-deploy" + } + } +} diff --git a/bin/pre-deploy b/bin/pre-deploy new file mode 100755 index 0000000..51e37f6 --- /dev/null +++ b/bin/pre-deploy @@ -0,0 +1,6 @@ +#!/bin/bash + +sed \ + -e "s/__PORT__/${PORT:-5000}/g" \ + -e "s/__HOSTNAME__/$HOSTNAME/g" \ + relay_template.yaml > relay.yaml diff --git a/relay/actor.py b/relay/actor.py index a8d6613..0804897 100644 --- a/relay/actor.py +++ b/relay/actor.py @@ -35,7 +35,11 @@ from . import app, CONFIG from .remote_actor import fetch_actor -AP_CONFIG = CONFIG.get('ap', {'host': 'localhost','blocked_instances':[]}) +AP_CONFIG = CONFIG.get('ap', { + 'host': 'localhost', + 'blocked_instances': [], + 'allowed_instances': [], +}) CACHE_SIZE = CONFIG.get('cache-size', 16384) @@ -218,6 +222,10 @@ async def handle_follow(actor, data, request): if urlsplit(inbox).hostname in AP_CONFIG['blocked_instances']: return + if AP_CONFIG['allowed_instances'] and\ + urlsplit(inbox).hostname not in AP_CONFIG['allowed_instances']: + return + if inbox not in following: following += [inbox] DATABASE['relay-list'] = following diff --git a/relay/default.py b/relay/default.py index b3a1836..6c84657 100644 --- a/relay/default.py +++ b/relay/default.py @@ -14,7 +14,7 @@ async def default(request): status=200, content_type="text/html", charset="utf-8", - text=""" + text=""" ActivityPub Relay at {host}