diff --git a/relay/actor.py b/relay/actor.py index 49abc38..8ddcf0e 100644 --- a/relay/actor.py +++ b/relay/actor.py @@ -3,9 +3,9 @@ import aiohttp.web import asyncio import logging import uuid +import re import urllib.parse import simplejson as json -import re import cgi from Crypto.PublicKey import RSA from .database import DATABASE @@ -186,7 +186,7 @@ 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']: + if urllib.parse.urlsplit(inbox).hostname in AP_CONFIG['blocked_instances']: return if inbox not in following: diff --git a/relay/database.py b/relay/database.py index 444d4b8..0d171a0 100644 --- a/relay/database.py +++ b/relay/database.py @@ -1,6 +1,6 @@ import asyncio import logging -import re +import urllib.parse import simplejson as json @@ -16,7 +16,7 @@ except: following = DATABASE.get('relay-list', []) for inbox in following: - if re.search('https://(.*)/inbox',inbox).group(1) in CONFIG['ap']['blocked_instances']: + if urllib.parse.urlsplit(inbox).hostname in CONFIG['ap']['blocked_instances']: following.remove(inbox) DATABASE['relay-list'] = following