PK œqhYî¶J‚ßFßF)nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/ $#$#$#

Dir : /proc/self/root/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/
Server: Linux ngx353.inmotionhosting.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64
IP: 209.182.202.254
Choose File :

Url:
Dir : //proc/self/root/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/firewall.py

"""
State to check firewall configurations

.. versionadded:: 2016.3.0
"""


def __virtual__():
    """
    Load only if network is loaded
    """
    if "network.connect" in __salt__:
        return "firewall"
    return (False, "network module could not be loaded")


def check(name, port=None, **kwargs):
    """
    Checks if there is an open connection from the minion to the defined
    host on a specific port.

    name
      host name or ip address to test connection to

    port
      The port to test the connection on

    kwargs
      Additional parameters, parameters allowed are:
        proto (tcp or udp)
        family (ipv4 or ipv6)
        timeout

    .. code-block:: yaml

      testgoogle:
        firewall.check:
          - name: 'google.com'
          - port: 80
          - proto: 'tcp'

    """

    # set name to host as required by the module
    host = name

    ret = {"name": name, "result": True, "changes": {}, "comment": ""}

    if "test" not in kwargs:
        kwargs["test"] = __opts__.get("test", False)

    # check the connection
    if kwargs["test"]:
        ret["result"] = True
        ret["comment"] = "The connection will be tested"
    else:
        results = __salt__["network.connect"](host, port, **kwargs)
        ret["result"] = results["result"]
        ret["comment"] = results["comment"]

    return ret