ok

Mini Shell

Direktori : /opt/imunify360/venv/lib64/python3.11/site-packages/im360/internals/core/
Upload File :
Current File : //opt/imunify360/venv/lib64/python3.11/site-packages/im360/internals/core/ip_versions.py

from typing import Dict, Set

from im360.utils.net import is_ipv6_enabled
from im360.utils.validate import IP, IPVersion

_state = {}  # type: Dict[IPVersion, bool]


def init() -> None:
    global _state
    _state = {IP.V4: True, IP.V6: is_ipv6_enabled()}


def enable(ip_version: IPVersion) -> None:
    _state[ip_version] = True


def disable(ip_version: IPVersion) -> bool:
    if ip_version == IP.V6:
        _state[ip_version] = False
        return True
    return False


def is_enabled(ip_version: IPVersion) -> bool:
    return _state[ip_version]


def enabled() -> Set[IPVersion]:
    return set(k for k, v in sorted(_state.items()) if v)


def all() -> Set[IPVersion]:
    return set(_state.keys())

Zerion Mini Shell 1.0