403Webshell
Server IP : 216.106.184.20  /  Your IP : 216.73.216.234
Web Server : LiteSpeed
System : Linux asmodeus.in-hell.com 5.14.0-570.58.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Oct 29 06:24:11 EDT 2025 x86_64
User : sekoaid1 ( 1891)
PHP Version : 7.3.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/imunify360/venv/lib/python3.11/site-packages/im360/simple_rpc/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/imunify360/venv/lib/python3.11/site-packages/im360/simple_rpc/middleware.py
from functools import wraps

from im360.internals.strategy import Strategy
from im360.model.firewall import IPList


def add_strategy(f):
    @wraps(f)
    async def wrapper(*args, **kwargs):
        result = await f(*args, **kwargs)
        assert isinstance(result, dict), (
            "Result should be a dictionary %s" % result
        )
        result["strategy"] = Strategy.get()

        return result

    return wrapper


def replace_gray_splashscreen_with_gray(f):
    """
    Replaces 'GRAY_SPLASHSCREEN' value
    for *listname* field for queries like `graylist ip list`
    for compatibility with UI
    """

    @wraps(f)
    async def wrapper(*args, **kwargs):
        result = await f(*args, **kwargs)
        if not isinstance(result.get("items"), list):
            return result
        gray_splashscreen = IPList.GRAY_SPLASHSCREEN.lower()
        for item in result.get("items", []):
            if (
                isinstance(item, dict)
                and item.get("listname")
                and item["listname"].lower() == gray_splashscreen
            ):
                # use same case as it is
                item["listname"] = (
                    IPList.GRAY
                    if item["listname"].isupper()
                    else IPList.GRAY.lower()
                )
        return result

    return wrapper

Youez - 2016 - github.com/yon3zu
LinuXploit