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
+from .http_debug import http_debug
# generate actor keys if not present
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):
logging.debug('%r >> %r', inbox, message)
- async with aiohttp.ClientSession() as session:
+ async with aiohttp.ClientSession(trace_configs=[http_debug()]) as session:
async with session.post(inbox, data=data, headers=headers) as resp:
resp_payload = await resp.text()
logging.debug('%r >> resp %r', inbox, resp_payload)
async def handle_relay(actor, data, request):
object_id = distill_object_id(data)
+ # don't relay mastodon announces -- causes LRP fake direction issues
+ if data['type'] == 'Announce' and len(data.get('cc', [])) > 0:
+ return
+
message = {
"@context": "https://www.w3.org/ns/activitystreams",
"type": "Announce",
following = DATABASE.get('relay-list', [])
inbox = get_actor_inbox(actor)
+ if urllib.parse.urlsplit(inbox).hostname in AP_CONFIG['blocked_instances']:
+ return
+
if inbox not in following:
following += [inbox]
DATABASE['relay-list'] = following