Commit bc0914b5 authored by Izalia Mae's avatar Izalia Mae
Browse files

make software blocklist configurable

parent f0e08f26
......@@ -21,4 +21,10 @@ ap:
whitelist:
- 'good-instance.example.com'
- 'another.good-instance.example.com'
block_relays: false
# uncomment the lines below to prevent certain activitypub software from posting
# to the relay (all known relays by default). this uses the software name in nodeinfo
#blocked_software:
#- 'activityrelay'
#- 'aoderelay'
#- 'social.seattle.wa.us-relay'
#- 'unciarelay'
......@@ -23,7 +23,7 @@ def load_config():
'port': int(yaml_file.get('port', 8080)),
'note': yaml_file.get('note', 'Make a note about your instance here.'),
'ap': {
'block_relays': yaml_file['ap'].get('block_relays', False),
'blocked_software': [v.lower() for v in yaml_file['ap'].get('blocked_software', [])],
'blocked_instances': yaml_file['ap'].get('blocked_instances', []),
'host': yaml_file['ap'].get('host', 'localhost'),
'whitelist': yaml_file['ap'].get('whitelist', []),
......@@ -35,7 +35,6 @@ def load_config():
CONFIG = load_config()
from .http_signatures import http_signatures_middleware
......
......@@ -318,10 +318,10 @@ async def inbox(request):
data = await request.json()
instance = urlsplit(data['actor']).hostname
if AP_CONFIG['block_relays']:
if AP_CONFIG['blocked_software']:
software = await fetch_nodeinfo(instance)
if software and 'relay' in software.lower():
if software and software.lower() in AP_CONFIG['blocked_software']:
raise aiohttp.web.HTTPUnauthorized(body='relays have been blocked', content_type='text/plain')
if 'actor' not in data or not request['validated']:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment