templates_people_modulesdir = $(templates_peopledir)/modules
templates_static_DATA = \
- src/templates/static/blocked.html \
src/templates/static/features.html \
src/templates/static/legal.html \
src/templates/static/support.html
return blacklists
- async def is_blacklisted(self):
- logging.debug("Checking if %s is blacklisted..." % self)
-
- # Perform checks
- blacklists = { bl : self._resolve_blacklist(bl) for bl in BLOCKLISTS }
-
- # If we are blacklisted on one list, this one is screwed
- for bl in blacklists:
- code, message = await blacklists[bl]
-
- logging.debug("Response from %s is: %s (%s)" % (bl, code, message))
-
- # Exclude matches on SBLCSS
- if bl == "sbl.spamhaus.org" and code == "127.0.0.3":
- continue
-
- # Consider the host blocked for any non-zero return code
- if code:
- return True
def format_asn(asn):
network = db.get_as(asn)
+++ /dev/null
-{% extends "../base.html" %}
-
-{% block title %}{{ _("You have been blocked") }}{% end block %}
-
-{% block container %}
- <div class="container">
- <div class="row justify-content-center mt-5">
- <div class="col-12 col-md-3 text-center">
- <span class="fas fa-shield-alt fa-10x p-5"></span>
- </div>
-
- <div class="col-12 col-md-5">
- <h5 class="mb-0">{{ _("Oops") }}</h5>
- <h1>{{ _("You have been blocked") }}</h1>
-
- <p>
- {{ _("Your request has been blocked because your IP address is suspected to spread spam.") }}
- </p>
-
- <p>
- <a href="https://location.ipfire.org/lookup/{{ address }}">
- {{ _("Click here to find out more about the status of your IP address") }}
- </a>
- </p>
- </div>
- </div>
- </div>
-{% end %}
-
-{% block footer %}{% end block %}
# Export arbitrary error pages
(r"/error/([45][0-9]{2})", base.ErrorHandler),
-
- # Block page
- (r"/blocked", base.BlockedHandler),
])
# blog.ipfire.org
from ..decorators import *
from .. import util
-def blacklisted(method):
- @functools.wraps(method)
- async def wrapper(self, *args, **kwargs):
- # Check if remote is blacklisted
- is_blacklisted = await self.remote.is_blacklisted()
-
- # If so, redirect to the blocked page
- if is_blacklisted:
- logging.warning("%s is blacklisted" % self.remote)
-
- return self.redirect("https://www.ipfire.org/blocked")
-
- return method(self, *args, **kwargs)
-
- return wrapper
-
class ratelimit(object):
def __init__(self, minutes=15, requests=180):
self.minutes = minutes
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())