block behaviour reversed for whitelist support

develop
Rachel Fae Fox (foxiepaws) 2019-06-23 19:27:56 -04:00
parent 9d1c6a3fa2
commit e1dc174792
3 changed files with 7 additions and 3 deletions

View File

@ -35,7 +35,7 @@ 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','allowed_instances':[],'blocked_instances':[]})
CACHE_SIZE = CONFIG.get('cache-size', 16384)
@ -215,7 +215,8 @@ async def handle_follow(actor, data, request):
following = DATABASE.get('relay-list', [])
inbox = get_actor_inbox(actor)
if urlsplit(inbox).hostname in AP_CONFIG['blocked_instances']:
if urlsplit(inbox).hostname not in AP_CONFIG['allowed_instances']:
logging.info('>> relay follow: not allowed %s', urlsplit(inbox).hostname)
return
if inbox not in following:

View File

@ -19,6 +19,9 @@ for inbox in following:
if urllib.parse.urlsplit(inbox).hostname in CONFIG['ap']['blocked_instances']:
following.remove(inbox)
DATABASE['relay-list'] = following
if urllib.parse.urlsplit(inbox).hostname not in CONFIG['ap']['allowed_instances']:
following.remove(inbox)
DATABASE['relay-list'] = following
if 'actors' in DATABASE:
DATABASE.pop('actors')

View File

@ -2,7 +2,7 @@ import logging
logging.basicConfig(
level=logging.INFO,
level=logging.DEBUG,
format="[%(asctime)s] %(levelname)s: %(message)s",
handlers=[logging.StreamHandler()]
)