From 98b177e7a6f90afd19c9a6cec6c703114da4a89d Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 14 Sep 2021 15:39:47 +0200 Subject: [PATCH] f --- files/__main__.py | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/files/__main__.py b/files/__main__.py index 173a2b699a..378dea01ee 100644 --- a/files/__main__.py +++ b/files/__main__.py @@ -168,27 +168,7 @@ UA_BAN_CACHE_TTL = int(environ.get("UA_BAN_CACHE_TTL", 3600)) # import and bind all routing functions -import files.classes from files.routes import * -import files.helpers.jinja2 - -@cache.memoize(timeout=UA_BAN_CACHE_TTL) -def get_useragent_ban_response(user_agent_str): - """ - Given a user agent string, returns a tuple in the form of: - (is_user_agent_banned, (insult, status_code)) - """ - #if request.path.startswith("/socket.io/"): - # return False, (None, None) - - result = g.db.query( - files.classes.Agent).filter( - files.classes.Agent.kwd.in_( - user_agent_str.split())).first() - if result: - return True, (result.mock or "Follow the robots.txt, dumbass", - result.status_code or 418) - return False, (None, None) def drop_connection(): @@ -217,11 +197,6 @@ def before_request(): if not session.get("session_id"): session["session_id"] = secrets.token_hex(16) - ua_banned, response_tuple = get_useragent_ban_response( - request.headers.get("User-Agent", "NoAgent")) - if ua_banned and request.path != "/robots.txt": - return response_tuple - if app.config["FORCE_HTTPS"] and request.url.startswith( "http://") and "localhost" not in app.config["SERVER_NAME"]: url = request.url.replace("http://", "https://", 1)