From f87b60f128fc17ee20c44a6fb444d665c48e5316 Mon Sep 17 00:00:00 2001 From: edraft Date: Thu, 16 Jan 2025 18:07:11 +0100 Subject: [PATCH] Added domain strict mode & reset versioning --- api/src/redirector.py | 6 ++++-- version.txt | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/api/src/redirector.py b/api/src/redirector.py index 66beee2..dbe045f 100644 --- a/api/src/redirector.py +++ b/api/src/redirector.py @@ -36,12 +36,14 @@ async def _handle_request(path: str): domains = Environment.get("DOMAINS", list[str], []) domain = await short_url.domain - logger.debug(f"Domain: {domain}, request.host: {request.host}") + logger.debug(f"Domain: {domain.name if domain is not None else None}, request.host: {request.host}") host = request.host if ":" in host: host = host.split(":")[0] - if host not in domains or domain is not None and domain.name not in domains: + + domain_strict_mode = Environment.get("DOMAIN_STRICT_MODE", bool, False) + if domain is not None and (domain.name not in domains or (domain_strict_mode and not host.endswith(domain.name))): return render_template("404.html"), 404 user_agent = request.headers.get("User-Agent", "").lower() diff --git a/version.txt b/version.txt index e2cac26..867e524 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.2.3 \ No newline at end of file +1.2.0 \ No newline at end of file