Redirector domain support
This commit is contained in:
parent
1001b6db5f
commit
8d99cd5ccf
@ -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
|
||||||
]
|
]
|
||||||
|
@ -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:
|
||||||
|
@ -1 +1 @@
|
|||||||
1.2.0
|
1.2.1
|
@ -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",
|
||||||
|
@ -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",
|
||||||
|
Loading…
Reference in New Issue
Block a user