HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/dns/__pycache__/inet.cpython-310.pyc
o

!we��@s�dZddlZddlmZmZmZddlZddlZej	Z	ej
Z
dedede
fdd�Zded	e
defd
d�Zdedefdd
�Zdedefdd�Zdedefdd�Z	ddeeefdeedefdd�Zdd�ZdS)z*Generic Internet address helper functions.�N)�Any�Optional�Tuple�family�text�returncCs.|tkr
tj�|�S|tkrtj�|d�St�)aConvert the textual form of a network address into its binary form.

    *family* is an ``int``, the address family.

    *text* is a ``str``, the textual address.

    Raises ``NotImplementedError`` if the address family specified is not
    implemented.

    Returns a ``bytes``.
    T)�AF_INET�dns�ipv4�	inet_aton�AF_INET6�ipv6�NotImplementedError)rr�r�A/home/arjun/projects/env/lib/python3.10/site-packages/dns/inet.py�	inet_pton!s

r�addresscCs,|tkr
tj�|�S|tkrtj�|�St�)a0Convert the binary form of a network address into its textual form.

    *family* is an ``int``, the address family.

    *address* is a ``bytes``, the network address in binary form.

    Raises ``NotImplementedError`` if the address family specified is not
    implemented.

    Returns a ``str``.
    )rr	r
�	inet_ntoarr
r)rrrrr�	inet_ntop6s

rcCsNz	tj�|�tWSty&ztj�|d�tWYSty%t�ww)z�Determine the address family of a textual-form network address.

    *text*, a ``str``, the textual address.

    Raises ``ValueError`` if the address family cannot be determined
    from the input.

    Returns an ``int``.
    T)r	r
rr�	Exceptionr
r�
ValueError�rrrr�af_for_addressKs
��rcCsfztj�|�d}|dko|dkWSty2ztj�|d�d}|dkWYSty1t�ww)z�Is the textual-form network address a multicast address?

    *text*, a ``str``, the textual address.

    Raises ``ValueError`` if the address family cannot be determined
    from the input.

    Returns a ``bool``.
    r����T�)r	r
rrr
r)r�firstrrr�is_multicastas��rcCsPz	tj�|�WdSty'ztj�|d�WYdSty&YYdSww)z{Is the specified string an IPv4 or IPv6 address?

    *text*, a ``str``, the textual address.

    Returns a ``bool``.
    TF)r	r
rrr
rrrr�
is_addressws��r�
high_tuple�afc
Cs�|\}}|durt|�}|tkr||fS|tkrg|�d�}|dkr'||ddfS|d|�}||dd�}|��rA||dt|�fSz
||dt�|�fWStyftj	}tj
|||d�^�^}}	}|	YSwtd|����)aXGiven a "high-level" address tuple, i.e.
    an (address, port) return the appropriate "low-level" address tuple
    suitable for use in socket calls.

    If an *af* other than ``None`` is provided, it is assumed the
    address in the high-level tuple is valid and has that af.  If af
    is ``None``, then af_for_address will be called.
    N�%r�)�flags�unknown address family )rrr�find�isdigit�int�socket�if_nametoindex�AttributeError�AI_NUMERICHOST�getaddrinfor)
rr r�port�i�addrpart�scope�ai_flags�_�tuprrr�low_level_address_tuple�s*
�r4cCs*|tjkrdS|tjkrdStd|����)z:Return the 'any' address for the specified address family.z0.0.0.0z::r$)r(rrr)r rrr�
any_for_af�s


r5)N)�__doc__r(�typingrrr�dns.ipv4r	�dns.ipv6rrr'�str�bytesrrr�boolrrr4r5rrrr�<module>s*�
��
�$