Added options to change the default listen address and port. Added default page that explains how to use the relay. Added note option to add information about the relay content and/or TOS.
This commit is contained in:
parent
827f3ee42a
commit
0e6967b34a
|
@ -2,8 +2,15 @@
|
|||
# you probably shouldn't change it, but you can if you want.
|
||||
db: relay.jsonld
|
||||
|
||||
# Listener
|
||||
listen: 0.0.0.0
|
||||
port: 8080
|
||||
|
||||
# Note
|
||||
note: "Make a note about your instance here."
|
||||
|
||||
# this section is for ActivityPub
|
||||
ap:
|
||||
# this is used for generating activitypub messages, as well as instructions for
|
||||
# linking AP identities. it should be an SSL-enabled domain reachable by https.
|
||||
host: 'relay.pleroma.site'
|
||||
host: 'relay.kitsunet.net'
|
||||
|
|
|
@ -26,4 +26,4 @@ app = aiohttp.web.Application(middlewares=[
|
|||
from . import database
|
||||
from . import actor
|
||||
from . import webfinger
|
||||
|
||||
from . import default
|
||||
|
|
|
@ -2,19 +2,25 @@ import asyncio
|
|||
import aiohttp.web
|
||||
import logging
|
||||
|
||||
from . import app
|
||||
|
||||
from . import app, CONFIG
|
||||
|
||||
async def start_webserver():
|
||||
runner = aiohttp.web.AppRunner(app)
|
||||
await runner.setup()
|
||||
try:
|
||||
listen = CONFIG['listen']
|
||||
except:
|
||||
listen = 'localhost'
|
||||
try:
|
||||
port = CONFIG['port']
|
||||
except:
|
||||
port = 8080
|
||||
|
||||
logging.info('Starting webserver at localhost:8080')
|
||||
logging.info('Starting webserver at {listen}:{port}'.format(listen=listen,port=port))
|
||||
|
||||
site = aiohttp.web.TCPSite(runner, 'localhost', 8080)
|
||||
site = aiohttp.web.TCPSite(runner, listen, port)
|
||||
await site.start()
|
||||
|
||||
|
||||
def main():
|
||||
loop = asyncio.get_event_loop()
|
||||
asyncio.ensure_future(start_webserver())
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
import aiohttp.web
|
||||
from . import app, CONFIG
|
||||
|
||||
host = CONFIG['ap']['host']
|
||||
host = CONFIG['note']
|
||||
|
||||
async def default(request):
|
||||
return aiohttp.web.Response(
|
||||
status=200,
|
||||
content_type="text/html",
|
||||
charset="utf-8",
|
||||
text="""
|
||||
<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>
|
||||
</body></html>
|
||||
|
||||
""".format(host=host))
|
||||
|
||||
app.router.add_get('/', default)
|
Loading…
Reference in New Issue