From 3af63d4d9f261dc815a616877b82c463f8cc51bf Mon Sep 17 00:00:00 2001 From: kaniini Date: Tue, 20 Nov 2018 00:42:31 +0000 Subject: [PATCH] relay: never relay an object back to the instance which hosts it --- relay/actor.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/relay/actor.py b/relay/actor.py index b27f6bb..ce46857 100644 --- a/relay/actor.py +++ b/relay/actor.py @@ -147,11 +147,14 @@ def strip_html(data): return cgi.escape(no_tags) -def distill_inboxes(actor): +def distill_inboxes(actor, object_id): global DATABASE + origin_hostname = urlsplit(object_id).hostname + inbox = get_actor_inbox(actor) targets = [target for target in DATABASE.get('relay-list', []) if target != inbox] + targets = [target for target in targets if urlsplit(target).hostname != origin_hostname] assert inbox not in targets @@ -194,7 +197,7 @@ async def handle_relay(actor, data, request): logging.debug('>> relay: %r', message) - inboxes = distill_inboxes(actor) + inboxes = distill_inboxes(actor, object_id) futures = [push_message_to_actor({'inbox': inbox}, message, 'https://{}/actor#main-key'.format(request.host)) for inbox in inboxes] asyncio.ensure_future(asyncio.gather(*futures))