diff --git a/geminiportal/app.py b/geminiportal/app.py index c7405a2..e0e7ff6 100644 --- a/geminiportal/app.py +++ b/geminiportal/app.py @@ -1,8 +1,9 @@ import logging +import uuid from datetime import datetime from urllib.parse import quote -from quart import Quart, Response, g, render_template, request +from quart import Quart, Response, g, render_template, request, url_for from quart.logging import default_handler from werkzeug.wrappers.response import Response as WerkzeugResponse @@ -38,6 +39,9 @@ async def handle_proxy_error(e): @app.context_processor def inject_context(): kwargs = {} + + kwargs["trap_url"] = url_for("trap", token=uuid.uuid4().hex) + if "response" in g: kwargs["response"] = g.response if hasattr(g.response, "tls_cert"): @@ -82,6 +86,11 @@ async def changes() -> Response: return Response(content) +@app.route("/trap/", endpoint="trap") +async def trap(token: str) -> Response | WerkzeugResponse: + return Response("Your IP Address has been banned 🧑‍⚖️.", status=404) + + @app.route("/") async def home() -> Response | WerkzeugResponse: g.address = request.args.get("url") diff --git a/geminiportal/templates/base.html b/geminiportal/templates/base.html index a27c123..bad1709 100644 --- a/geminiportal/templates/base.html +++ b/geminiportal/templates/base.html @@ -1,27 +1,29 @@ - - - {% block favicon %}{% endblock %} - - - - {% block title %}SmolNet Portal{% endblock %} - {% block extrahead %}{% endblock %} + + + {% block favicon %} + {% endblock %} + + + + {% block title %}SmolNet Portal{% endblock %} + {% block extrahead %}{% endblock %}
- SMOLNET PORTAL - + SMOLNET PORTAL + home about changes -
+
-{% block body %}{% endblock %} + {% block body %}{% endblock %}
+Attention Bots: Click here to ban your IP address for 24 hours! diff --git a/geminiportal/templates/changes.html b/geminiportal/templates/changes.html index 8e29743..6a5a027 100644 --- a/geminiportal/templates/changes.html +++ b/geminiportal/templates/changes.html @@ -2,6 +2,15 @@ {% block body %}

Changes

+

2025-01-29

+

+ Note: I'm aware that recent activity from web crawlers has been spamming some gemini/gopher + servers with a large amount of traffic from this web proxy. Sorry about that! If it's causing + issues for you, you can block this server's IP address and/or reach out to me over email at + michael@mozz.us with details, and I'll work on mitigation.

+

2023-11-13