2018-10-30 22:35:04 +00:00
|
|
|
import aiohttp.web
|
2018-11-01 21:49:48 +00:00
|
|
|
import urllib.parse
|
2018-10-30 22:35:04 +00:00
|
|
|
from . import app, CONFIG
|
2018-10-31 18:42:42 +00:00
|
|
|
from .database import DATABASE
|
2018-10-30 22:35:04 +00:00
|
|
|
|
|
|
|
host = CONFIG['ap']['host']
|
2018-10-30 22:43:16 +00:00
|
|
|
note = CONFIG['note']
|
2018-11-01 21:49:48 +00:00
|
|
|
|
|
|
|
inboxes = DATABASE.get('relay-list', [])
|
2018-10-30 22:35:04 +00:00
|
|
|
|
|
|
|
async def default(request):
|
2018-12-10 22:14:43 +00:00
|
|
|
targets = '<br>'.join([urllib.parse.urlsplit(target).hostname for target in inboxes])
|
2018-10-30 22:35:04 +00:00
|
|
|
return aiohttp.web.Response(
|
|
|
|
status=200,
|
|
|
|
content_type="text/html",
|
|
|
|
charset="utf-8",
|
2019-01-17 23:04:07 +00:00
|
|
|
text="""
|
2018-10-30 22:35:04 +00:00
|
|
|
<html><head>
|
|
|
|
<title>ActivityPub Relay at {host}</title>
|
|
|
|
<style>
|
|
|
|
p {{ color: #FFFFFF; font-family: monospace, arial; font-size: 100%; }}
|
|
|
|
body {{ background-color: #000000; }}
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<p>This is an Activity Relay for fediverse instances.</p>
|
|
|
|
<p>{note}</p>
|
|
|
|
<p>For Mastodon instances, you may subscribe to this relay with the address: <a href="https://{host}/inbox">https://{host}/inbox</a></p>
|
|
|
|
<p>For Pleroma and other instances, you may subscribe to this relay with the address: <a href="https://{host}/actor">https://{host}/actor</a></p>
|
|
|
|
<p>To host your own relay, you may download the code at this address: <a href="https://git.pleroma.social/pleroma/relay">https://git.pleroma.social/pleroma/relay</a></p>
|
2018-11-01 21:49:48 +00:00
|
|
|
<br><p>List of {count} registered instances:<br>{targets}</p>
|
2018-10-30 22:35:04 +00:00
|
|
|
</body></html>
|
|
|
|
|
2018-11-01 21:49:48 +00:00
|
|
|
""".format(host=host, note=note,targets=targets,count=len(inboxes)))
|
2018-10-30 22:35:04 +00:00
|
|
|
|
|
|
|
app.router.add_get('/', default)
|