From ecebb2841e0d177e96294b51914e6be6ed43fdb2 Mon Sep 17 00:00:00 2001 From: cynic Date: Fri, 18 Nov 2022 16:49:09 +0000 Subject: [PATCH] add baseurl directive for matching hosts and writing links when reverse proxying --- cathedral.py | 3 +-- config.json | 3 ++- towers/fiefdom.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cathedral.py b/cathedral.py index a3541b1..e142dbf 100644 --- a/cathedral.py +++ b/cathedral.py @@ -12,8 +12,7 @@ class cathedral(): async def handle_http(self, r): for t in self.towers: for h in t.hooks: - print(str(r.host)[str(r.host).find(self.cfg.get("host")):]) - if compile(h.replace("$HOST", str(r.host)[str(r.host).find(self.cfg.get("host")):])).match(str(r.url)): + if compile(h.replace("$HOST", str(r.host)[str(r.host).find(self.cfg.get("base")):])).match(str(r.url)): return web.Response(**t.run(self, r)) return web.Response(body=f"usergroup homepage") async def start_http(self): diff --git a/config.json b/config.json index 87ff5af..e2f8f1b 100644 --- a/config.json +++ b/config.json @@ -1,5 +1,6 @@ { "host": "localhost", + "base": "f.q.d.n", "port": 1337, "PLUGIN_PATH": "./towers" -} \ No newline at end of file +} diff --git a/towers/fiefdom.py b/towers/fiefdom.py index 8f6f6b7..32a06da 100644 --- a/towers/fiefdom.py +++ b/towers/fiefdom.py @@ -9,7 +9,7 @@ def run(ctx, r): if not(user in ctx.auth.get_real_users()): return { - "body": f"

404! no such user!


consult users.{ctx.cfg.get('host')} to see all registered users", + "body": f"

404! no such user!


consult users.{ctx.cfg.get('base')} to see all registered users", "status": 404, "content_type": "text/html" } @@ -32,4 +32,4 @@ def run(ctx, r): return { "content_type": "text/html", "body": f - } \ No newline at end of file + }