From baa693a315619ac723273106c9642fe9f1f86624 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 18 Oct 2018 12:29:31 +0100 Subject: [PATCH] Add blocked page Signed-off-by: Michael Tremer --- Makefile.am | 1 + src/templates/static/blocked.html | 26 ++++++++++++++++++++++++++ src/web/__init__.py | 3 +++ src/web/handlers_base.py | 8 ++++++++ 4 files changed, 38 insertions(+) create mode 100644 src/templates/static/blocked.html diff --git a/Makefile.am b/Makefile.am index f5bc4f17..1424e824 100644 --- a/Makefile.am +++ b/Makefile.am @@ -187,6 +187,7 @@ templates_people_ssh_keys_DATA = \ templates_people_ssh_keysdir = $(templates_peopledir)/ssh-keys templates_static_DATA = \ + src/templates/static/blocked.html \ src/templates/static/chat.html \ src/templates/static/features.html \ src/templates/static/legal.html \ diff --git a/src/templates/static/blocked.html b/src/templates/static/blocked.html new file mode 100644 index 00000000..24f440f4 --- /dev/null +++ b/src/templates/static/blocked.html @@ -0,0 +1,26 @@ +{% extends "../base.html" %} + +{% block title %}{{ _("You have been blocked") }}{% end block %} + +{% block container %} +
+
+
+
{{ _("Oops") }}
+

{{ _("You have been blocked") }}

+ +

+ {{ _("Your request has been blocked because your IP address is suspected to spread spam.") }} +

+ +

+ + {{ _("Click here to find out more about the status of your IP address") }} + +

+
+
+
+{% end %} + +{% block footer %}{% end block %} diff --git a/src/web/__init__.py b/src/web/__init__.py index e721dbfa..7072108c 100644 --- a/src/web/__init__.py +++ b/src/web/__init__.py @@ -126,6 +126,9 @@ class Application(tornado.web.Application): # Export arbitrary error pages (r"/error/([45][0-9]{2})", ErrorHandler), + + # Block page + (r"/blocked", BlockedHandler), ]) # blog.ipfire.org diff --git a/src/web/handlers_base.py b/src/web/handlers_base.py index 41692c41..26fc43e7 100644 --- a/src/web/handlers_base.py +++ b/src/web/handlers_base.py @@ -196,3 +196,11 @@ class ErrorHandler(BaseHandler): raise tornado.web.HTTPError(400) raise tornado.web.HTTPError(code) + + +class BlockedHandler(BaseHandler): + def get(self): + # 403 - Forbidden + self.set_status(403) + + self.render("static/blocked.html", address=self.get_remote_ip()) -- 2.47.2