HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/dig.cpython-310.pyc
o

�N�g�"�@s�dZddlZddlZddlZddlZe�e�ZdZ	dd�Z
dd�Zddd	�Zdd
d�Z
ddd
�Zddd�Zddd�Zddd�Zddd�Zddd�ZeZe
ZeZeZeZeZeZdS)zq
Compendium of generic DNS utilities.
The 'dig' command line tool must be installed in order to use this module.
�N�digcCstjj�d�r	tSdS)z3
    Only load module if dig binary is present
    r)FzMThe dig execution module cannot be loaded: the dig binary is not in the path.)�salt�utils�path�which�__virtualname__�rr�D/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/dig.py�__virtual__sr
cCs�z|�dd�}Wn
tyYdSwtjj�|d�rCzdt|d�kr-dkr.WdSWnty9YdStyBYdSwtjj�	|d�rwzdt|d�kr]dkraWdSWdSWdStymYdStyvYdSwdS)	z�
    Check if address is a valid IP. returns True if valid, otherwise False.

    CLI Example:

    .. code-block:: bash

        salt ns1 dig.check_ip 127.0.0.1
        salt ns1 dig.check_ip 1111:2222:3333:4444:5555:6666:7777:8888
    �/�Fr� T��)
�rsplit�AttributeErrorrr�networkZis_ipv4�int�
ValueError�
IndexErrorZis_ipv6)�addrrrr	�check_ips<�����	�	��rcC�pddt|�dg}|dur|�d|���td|dd�}|d	d
kr,t�d|d	�gSdd
�|d�d�D�S)z�
    Return the A record for ``host``.

    Always returns a list.

    CLI Example:

    .. code-block:: bash

        salt ns1 dig.A www.google.com
    r�+short�AN�@�cmd.run_allF�Zpython_shell�retcoder�>dig returned exit code '%s'. Returning empty list as fallback.cS�g|]}t|�r|�qSr�r��.0�xrrr	�
<listcomp>c�zA.<locals>.<listcomp>�stdout�
��str�append�__salt__�log�warning�split��host�
nameserverr�cmdrrr	rH��rcCspdddt|�g}|dur|�d|���td|dd�}|d	d
kr,t�d|d	�gSdd
�|d�d�D�S)z�
    .. versionadded:: 3006.0

    Return the PTR record for ``host``.

    Always returns a list.

    CLI Example:

    .. code-block:: bash

        salt ns1 dig.PTR 1.2.3.4
    rrz-xNrrFrrrrcS�g|]}|�qSrr�r#�irrr	r%��zPTR.<locals>.<listcomp>r'r(r)r0rrr	�PTRfs�r9cCr)z�
    Return the AAAA record for ``host``.

    Always returns a list.

    CLI Example:

    .. code-block:: bash

        salt ns1 dig.AAAA www.google.com
    rr�AAAANrrFrrrrcSr rr!r"rrr	r%�r&zAAAA.<locals>.<listcomp>r'r(r)r0rrr	r:�r4r:cCs`ddt|�dg}|dur|�d|���td|dd�}|d	d
kr,t�d|d	�gS|dS)
z�
    Return the CNAME record for ``host``.

    .. versionadded:: 3005

    CLI Example:

    .. code-block:: bash

        salt ns1 dig.CNAME mail.google.com
    rr�CNAMENrrFrrrzdig returned exit code '%s'.r')r*r+r,r-r.r0rrr	r;�s�r;TcCs�ddt|�dg}|dur|�d|���td|dd�}|d	d
kr,t�d|d	�gS|rIg}|d�d
�D]}t||�D]}|�|�q>q7|S|d�d
�S)z�
    Return a list of IPs of the nameservers for ``domain``

    If ``resolve`` is False, don't resolve names.

    CLI Example:

    .. code-block:: bash

        salt ns1 dig.NS google.com
    rr�NSNrrFrrrrr'r()r*r+r,r-r.r/r)�domain�resolver2rr3�retZns_hostZip_addrrrr	r<�s$��r<�SPFc	CsLt�d�}ddt|�|g}|dur|�d|���td|dd�}|d	d
kr1t�d|d	�gS|dd
krA|dkrAt|d|�St�dd
|d��	�}|rT|d
dkrVgS|d�
d�rit|ddd�d|�Sg}|dd�D]2}z|�|���\}	}
Wn	t
y�Yqqw|	dkr�|�t|
d|��qq|	dvr�t|
�r�|�|
�qq|S)aZ
    Return the allowed IPv4 ranges in the SPF record for ``domain``.

    If record is ``SPF`` and the SPF record is empty, the TXT record will be
    searched automatically. If you know the domain uses TXT and not SPF,
    specifying that will save a lookup.

    CLI Example:

    .. code-block:: bash

        salt ns1 dig.SPF google.com
    z(?:\+|~)?(ip[46]|include):(.+)rrNrrFrrrrr'�r@�TXT�"zv=spf1rz	redirect=�	Zinclude)Zip4Zip6)�re�compiler*r+r,r-r.r@�subr/�
startswith�match�groupsr�extendr)r=�recordr2Zspf_rer3�resultZsectionsr?�sectionZ	mechanism�addressrrr	r@�s>
��
�Fcs�ddt|�dg}�dur|�d����td|dd�}|d	d
kr,t�d|d	�gSdd
�|d�d�D�}|rC�fdd
�|D�S|S)a

    Return a list of lists for the MX of ``domain``.

    If the ``resolve`` argument is True, resolve IPs for the servers.

    It's limited to one IP, because although in practice it's very rarely a
    round robin, it is an acceptable configuration and pulling just one IP lets
    the data be similar to the non-resolved version. If you think an MX has
    multiple IPs, don't use the resolver here, resolve them in a separate step.

    CLI Example:

    .. code-block:: bash

        salt ns1 dig.MX google.com
    rr�MXNrrFrrrrcSsg|]}|���qSr)r/r"rrr	r%:szMX.<locals>.<listcomp>r'r(cs&g|]}|dt|d��dg�qS)rr)rr"�r2rr	r%=s&r))r=r>r2rr3r'rrQr	rPs�rPcCr)z�
    Return the TXT record for ``host``.

    Always returns a list.

    CLI Example:

    .. code-block:: bash

        salt ns1 dig.TXT google.com
    rrrBNrrFrrrrcSr5rrr6rrr	r%\r8zTXT.<locals>.<listcomp>r'r(r)r0rrr	rBBs�rB)N)TN)r@N)FN)�__doc__�loggingrEZsalt.utils.networkrZsalt.utils.path�	getLogger�__name__r-rr
rrr9r:r;r<r@rPrB�a�ptrZaaaaZcname�nsZspfZmxrrrr	�<module>s0

+




$
7
'