From ee7f1cc190286034f7aab3cfaa159569e107036c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Mah=C3=A9?= Date: Thu, 1 Nov 2018 14:49:48 -0700 Subject: [PATCH] do not use regex to parse instances, and add count of instances to default page --- relay/default.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/relay/default.py b/relay/default.py index 172c9d3..638e0c7 100644 --- a/relay/default.py +++ b/relay/default.py @@ -1,11 +1,13 @@ import aiohttp.web -import re +import urllib.parse from . import app, CONFIG from .database import DATABASE host = CONFIG['ap']['host'] note = CONFIG['note'] -targets = '
'.join([re.search('https://(.*)/inbox',target).group(1) for target in DATABASE.get('relay-list', [])]) + +inboxes = DATABASE.get('relay-list', []) +targets = '
'.join([urllib.parse.urlsplit(target).hostname for target in inboxes]) async def default(request): return aiohttp.web.Response( @@ -26,9 +28,9 @@ async def default(request):

For Mastodon instances, you may subscribe to this relay with the address: https://{host}/inbox

For Pleroma and other instances, you may subscribe to this relay with the address: https://{host}/actor

To host your own relay, you may download the code at this address: https://git.pleroma.social/pleroma/relay

-

List of registered instances:
{targets}

+

List of {count} registered instances:
{targets}

-""".format(host=host, note=note,targets=targets)) +""".format(host=host, note=note,targets=targets,count=len(inboxes))) app.router.add_get('/', default)