diff --git a/relay/default.py b/relay/default.py
index b3a1836..47390b1 100644
--- a/relay/default.py
+++ b/relay/default.py
@@ -1,36 +1,95 @@
import aiohttp.web
-import urllib.parse
-from . import app, CONFIG
+import urllib.parse
+import time
+import datetime
+from . import app, CONFIG
from .database import DATABASE
-
+
host = CONFIG['ap']['host']
note = CONFIG['note']
-
-inboxes = DATABASE.get('relay-list', [])
-
+
+START_TIME=time.time()
+
async def default(request):
- targets = '
'.join([urllib.parse.urlsplit(target).hostname for target in inboxes])
- return aiohttp.web.Response(
- status=200,
+ from .actor import INBOUND_STATS
+ inboxes = DATABASE.get('relay-list', [])
+ target = []
+ for t in inboxes:
+ if urllib.parse.urlsplit(t).hostname not in DATABASE.get('backoff-instances',{}):
+ target.append('%s' % (urllib.parse.urlsplit(t).hostname,urllib.parse.urlsplit(t).hostname))
+ targets = '
'.join(target)
+ err=[]
+ warn=[]
+ not_subd = ''.join(['%s' % (s,s) for s in DATABASE.get('not-subscribed',[])])
+ for instance,val in DATABASE.get('backoff-instances',{}).items():
+ if time.time() - val['ts'] > 86400:
+ err.append('%s' % (instance,instance))
+ else:
+ warn.append("%s' (%s left before stopping attempts)" % (instance,instance,str(datetime.timedelta(seconds=86400-(time.time()-val['ts']))).split(".")[0])) errs=''.join(err)
+ warns=''.join(warn)
+ banned=''.join(CONFIG['ap']['blocked_instances'])
+ return aiohttp.web.Response(
+ status=200,
content_type="text/html",
charset="utf-8",
- text="""
-
- ActivityPub Relay at {host}
+ text="""
+
+ ActivityPub Relay at {host}
+ h4 {{ color: #FFFFFF; font-family: monospace, arial; font-size: 100%; }} html, body {{
+ margin: 0;
+ height: 100%;
+ }}
+ body {{ background-color: #282c37; }}
+ #content {{
+ display: flex;
+ flex-direction: column;
+ height: 100%
+ }}
+ .greyed {{ color: #606984; }}
+
+ main {{
+ flex: 1;
+ overflow: auto;
+ }}
+ .footer {{
+ flex-shrink: 0;
+ font-size: 80%;
+ background-color: #20232C;
+ }}
+ .header {{
+ text-align: center;
+ background-color: #20232C;
+ }}
+
-This is an Activity Relay for fediverse instances.
+
+
+
+List of {count} registered and active instances:
+List of {countw} instances with errors (last failure to deliver a post is less than a day, not all posts are sent, only periodic retries):
+List of {countn} instances trying to send posts and not following the relay (those posts are ignored and nothing is sent to those instances):
+List of {counte} unreachable instances (not being delivered anything anymore till we receive a post from them again):
+There are currently {countb} instances banned in the configuration file of this relay.
+
+
+
-""".format(host=host, note=note,targets=targets,count=len(inboxes)))
+""".format(host=host, note=note,targets=targets,count=len(target),warnings=warns,countw=len(warn),errors=errs,counte=len(err),nosub=not_subd,countn=len(DATABASE.get('not-subscribed',[])),starttime=str(datetime.timede
+lta(seconds=(time.time()-START_TIME))).split(".")[0],statuscounts=INBOUND_STATS['processed']+INBOUND_STATS['rejected'],rejectcount=INBOUND_STATS['rejected'],countb=len(CONFIG['ap']['blocked_instances']),banned=banned))
app.router.add_get('/', default)