Redirector domain support
All checks were successful
Build dev on push / build-redirector (push) Successful in 29s
Build dev on push / build-api (push) Successful in 29s
Build dev on push / build-web (push) Successful in 50s

This commit is contained in:
Sven Heidemann 2025-01-11 01:17:19 +01:00
parent 1001b6db5f
commit 8d99cd5ccf
5 changed files with 11 additions and 4 deletions

View File

@ -24,18 +24,18 @@ def get_value(
if key in source: if key in source:
value = source[key] value = source[key]
if isinstance(value, cast_type): if isinstance(value, cast_type if not hasattr(cast_type, "__origin__") else cast_type.__origin__):
return value return value
try: try:
if cast_type == bool: if cast_type == bool:
return value.lower() in ["true", "1"] return value.lower() in ["true", "1"]
if cast_type == list: if (cast_type if not hasattr(cast_type, "__origin__") else cast_type.__origin__) == list:
subtype = ( subtype = (
cast_type.__args__[0] if hasattr(cast_type, "__args__") else None cast_type.__args__[0] if hasattr(cast_type, "__args__") else None
) )
value = ast.literal_eval(value) value = value.split(list_delimiter)
return [ return [
subtype(item) if subtype is not None else item for item in value subtype(item) if subtype is not None else item for item in value
] ]

View File

@ -34,6 +34,11 @@ async def _handle_request(path: str):
if short_url is None: if short_url is None:
return render_template("404.html"), 404 return render_template("404.html"), 404
domains = Environment.get("DOMAINS", list[str], [])
domain = await short_url.domain
if domain is not None and domain.name not in domains:
return render_template("404.html"), 404
user_agent = request.headers.get("User-Agent", "").lower() user_agent = request.headers.get("User-Agent", "").lower()
if "wheregoes" in user_agent or "someothertool" in user_agent: if "wheregoes" in user_agent or "someothertool" in user_agent:

View File

@ -1 +1 @@
1.2.0 1.2.1

View File

@ -40,6 +40,7 @@
"news": "News", "news": "News",
"role": "Rolle", "role": "Rolle",
"save": "Speichern", "save": "Speichern",
"short_url": "Url",
"updated": "Bearbeitet", "updated": "Bearbeitet",
"upload": "Hochladen", "upload": "Hochladen",
"urls": "URLs", "urls": "URLs",

View File

@ -40,6 +40,7 @@
"news": "News", "news": "News",
"role": "Role", "role": "Role",
"save": "Save", "save": "Save",
"short_url": "Url",
"updated": "Updated", "updated": "Updated",
"upload": "Upload", "upload": "Upload",
"urls": "URLs", "urls": "URLs",