Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Verified Commit 3ef71f7d authored by Nicolas Gelot's avatar Nicolas Gelot
Browse files

Adjust limiter rules with etheme

parent 4bec24dc
Loading
Loading
Loading
Loading
+9 −1
Original line number Original line Diff line number Diff line
@@ -79,7 +79,15 @@ def is_accepted_request() -> bool:
            logger.debug("BLOCK %s: Accept-Encoding misses text/html", x_forwarded_for)
            logger.debug("BLOCK %s: Accept-Encoding misses text/html", x_forwarded_for)
            return False
            return False


        if request.args.get("format", "html") != "html":
        if request.args.get("format", "html") == "json" and request.args.get("categories", "general") in [
            "images",
            "videos",
        ]:
            c = incr_sliding_window(redis_client, "API media limit" + x_forwarded_for, 60)
            if c > 10:
                logger.debug("BLOCK %s: API media limit exceeded", x_forwarded_for)
                return False
        elif request.args.get("format", "html") != "html":
            c = incr_sliding_window(redis_client, "API limit" + x_forwarded_for, 3600)
            c = incr_sliding_window(redis_client, "API limit" + x_forwarded_for, 3600)
            if c > 4:
            if c > 4:
                logger.debug("BLOCK %s: API limit exceeded", x_forwarded_for)
                logger.debug("BLOCK %s: API limit exceeded", x_forwarded_for)