HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/daemons/__pycache__/__init__.cpython-310.pyc
o

�N�g��@sXdZddlZddlZddlmZmZmZe�e�Z	dd�Z
dd�Zdd
d�Zdd
�Z
dS)zs
The daemons package is used to store implementations of the Salt Master and
Minion enabling different transports.
�N)�Iterable�Mapping�SequencecC�t|t�o
t|t�S)z�
    Returns True if obj is non-string iterable, False otherwise

    Future proof way that is compatible with both Python3 and Python2 to check
    for non string iterables.
    Assumes in Python3 that, basestring = (str, bytes)
    )�
isinstance�strr��obj�r
�I/opt/saltstack/salt/lib/python3.10/site-packages/salt/daemons/__init__.py�is_non_string_iterable
�rcCr)z�
    Returns True if obj is non-string sequence, False otherwise

    Future proof way that is compatible with both Python3 and Python2 to check
    for non string sequences.
    Assumes in Python3 that, basestring = (str, bytes)
    )rrrrr
r
r�is_non_string_sequencer
r�masterTcCs�|dur
|�|�}n|�d�}zt|�}Wnty d}Ynw|s.d}t�|�t|��|�|g�}|sGd|�d�}t�|�|rGt|��g}t|�r�|D]/}t|t�rl|�dd�}	|�dd�}
|�t	|	|
d	��qOt|t
�r~|}	d}
|�t	|	|
d	��qOn-t|t�r�|�dd�}	|�dd�}
|�t	|	|
d	��nt|t
�r�|}	d}
|�t	|	|
d	��g}|D]"}|d}	|d}
|	r�t|	|�}	|	s�q�t|
|�}
|�t	|	|
d	��q�|S)
a�	
    Parses opts and generates a list of master (host,port) addresses.
    By default looks for list of masters in opts['master'] and uses
    opts['master_port'] as the default port when otherwise not provided.

    Use the opts key given by masters for the masters list, default is 'master'
    If parameter port is not None then uses the default port given by port


    Returns a list of host address dicts of the form

    [
        {
            'external': (host,port),
            'internal': (host, port)
        },
        ...

    ]

    When only one address is provided it is assigned to the external address field
    When not provided the internal address field is set to None.

    For a given master the syntax options are as follows:

    hostname [port]

    external: hostname [port]
    [internal: hostaddress [port]]

    Where the hostname string could be either an FQDN or host address
    in dotted number notation.
        master.example.com
        10.0.2.110

    And the hostadress is in dotted number notation

    The space delimited port is optional and if not provided a default is used.
    The internal address is optional and if not provided is set to None

    Examples showing the YAML in /etc/salt/master  conf file:

    1) Single host name string (fqdn or dotted address)
        a)
            master: me.example.com
        b)
            master: localhost
        c)
            master: 10.0.2.205

    2) Single host name string with port
        a)
            master: me.example.com 4506
        b)
            master: 10.0.2.205 4510

    3) Single master with external and optional internal host addresses for nat
       in a dict

        master:
            external: me.example.com 4506
            internal: 10.0.2.100 4506


    3) One or host host names with optional ports in a list

        master:
            - me.example.com 4506
            - you.example.com 4510
            - 8.8.8.8
            - they.example.com 4506
            - 8.8.4.4  4506

    4) One or more host name with external and optional internal host addresses
       for Nat  in a list of dicts

        master:
            -
                external: me.example.com 4506
                internal: 10.0.2.100 4506

            -
                external: you.example.com 4506
                internal: 10.0.2.101 4506

            -
                external: we.example.com

            - they.example.com
    N�master_portz'Invalid or missing opts['master_port'].zInvalid or missing opts['z'].�external��internal)rr)�get�int�
ValueError�log�errorrrr�append�dictr�parse_hostname)�optsZmasters�portZraise_if_emptyrZemsg�entriesZhostages�entryrrZhostager
r
r�extract_masters#sf[
�



��



�r cCs�zH|���d�\}}}|sWdS|s.|}|}|�d�dkr.|�d�\}}}|s*WdS|s.|}|��}zt|�}WntyCYWdSwW||fStyRYdSw)ae
    Parse hostname string and return a tuple of (host, port)
    If port missing in hostname string then use default_port
    If anything is not a valid then return None

    hostname should contain a host and an option space delimited port
    host port

    As an attempt to prevent foolish mistakes the parser also tries to identify
    the port when it is colon delimited not space delimited. As in host:port.
    This is problematic since IPV6 addresses may have colons in them.
    Consequently the use of colon delimited ports is strongly discouraged.
    An ipv6 address must have at least 2 colons.
    � N�:�)�strip�
rpartition�countrr�AttributeError)�hostname�default_port�host�seprr
r
rr�s0����r)rNT)�__doc__�logging�sys�collections.abcrrr�	getLogger�__name__rrrr rr
r
r
r�<module>s