very simple blocklist
This commit is contained in:
parent
12af824b56
commit
aa79a27840
|
@ -14,3 +14,7 @@ ap:
|
|||
# this is used for generating activitypub messages, as well as instructions for
|
||||
# linking AP identities. it should be an SSL-enabled domain reachable by https.
|
||||
host: 'relay.example.com'
|
||||
blocked_instances:
|
||||
- 'bad-instance.example.com'
|
||||
- 'another-bad-instance.example.com'
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ from . import app, CONFIG
|
|||
from .remote_actor import fetch_actor
|
||||
|
||||
|
||||
AP_CONFIG = CONFIG.get('ap', {'host': 'localhost'})
|
||||
AP_CONFIG = CONFIG.get('ap', {'host': 'localhost','blocked_instances':[]})
|
||||
|
||||
|
||||
async def actor(request):
|
||||
|
@ -186,6 +186,9 @@ async def handle_follow(actor, data, request):
|
|||
following = DATABASE.get('relay-list', [])
|
||||
inbox = get_actor_inbox(actor)
|
||||
|
||||
if re.search('https://(.*)/inbox',inbox).group(1) in AP_CONFIG['blocked_instances']:
|
||||
return
|
||||
|
||||
if inbox not in following:
|
||||
following += [inbox]
|
||||
DATABASE['relay-list'] = following
|
||||
|
|
|
@ -13,6 +13,11 @@ except:
|
|||
logging.info('No database was found, making a new one.')
|
||||
DATABASE = {}
|
||||
|
||||
following = DATABASE.get('relay-list', [])
|
||||
for inbox in following:
|
||||
if re.search('https://(.*)/inbox',inbox).group(1) in CONFIG['ap']['blocked_instances']:
|
||||
following.remove(inbox)
|
||||
DATABASE['relay-list'] = following
|
||||
|
||||
async def database_save():
|
||||
while True:
|
||||
|
|
Loading…
Reference in New Issue