make software blocklist configurable

master
Izalia Mae 2 years ago
parent f0e08f26b3
commit bc0914b5c1
  1. 8
      relay.yaml.example
  2. 3
      relay/__init__.py
  3. 4
      relay/actor.py

@ -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']:

Loading…
Cancel
Save