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__/ipv6.cpython-310.pyc
o

!we0�@s�dZddlZddlZddlmZmZddlZddlZe�	d�Z
dedefdd�Z
e�	d	�Ze�	d
�Ze�	d�Zdd
eeefdedefdd�ZdZdedefdd�ZdS)zIPv6 helper functions.�N)�List�Unionz
0+([0-9a-f]+)�address�returncCs�t|�dkr
td��t�|�}g}d}t|�}||kr@|||d���}t�|�}|dur3|�d�}|�|�|d7}||ksd}d}d}	d}
t	d	�D]!}||d
krg|
rf|}||	}||krd|	}|}d}
qL|
sm|}	d}
qL|
r~d	}||	}||kr~|	}|}|dkr�|dkr�|dks�|d
kr�|d
dkr�|dkr�d}
nd}
|
t
j�|dd��}|Sd�
|d|��dd�
|||d��}|Sd�
|�}|S)z�Convert an IPv6 address in binary form to text form.

    *address*, a ``bytes``, the IPv6 address in binary form.

    Raises ``ValueError`` if the address isn't 16 bytes long.
    Returns a ``str``.
    �z IPv6 addresses are 16 bytes longr�N����F��0T���ffffz::z::ffff:��:)�len�
ValueError�binascii�hexlify�decode�
_leading_zero�match�group�append�range�dns�ipv4�	inet_ntoa�join)r�hex�chunks�i�l�chunk�m�
best_start�best_len�start�
last_was_zero�end�current_len�prefix�thex�r-�A/home/arjun/projects/env/lib/python3.10/site-packages/dns/ipv6.pyrsl	



�
��$	����
�rs(.*):(\d+\.\d+\.\d+\.\d+)$s::.*s.*::$F�text�ignore_scopec
	Cs*t|t�s
|��}n|}|r(|�d�}t|�}|dkr |d}n|dkr(tjj�|dkr0tjj�|�d�r>|�d�s>tjj�|�	d�rL|�	d�sLtjj�|dkrRd}t
�|�}|dur|tj�
|�d��}d	�|�d
���|d|d
|d|d���}t�|�}|dur�|d
d�}nt�|�}|dur�|dd�}|�d�}t|�}|d
kr�tjj�d}g}	|D]=}
|
dkr�|r�tjj�d}tdd
|d
�D]}|	�d�q�q�t|
�}|dkr�tjj�|dkr�dd||
}
|	�|
�q�|d
kr�|s�tjj�d�|	�}zt�|�WStjtf�ytjj�w)aConvert an IPv6 address in text form to binary form.

    *text*, a ``str``, the IPv6 address in textual form.

    *ignore_scope*, a ``bool``.  If ``True``, a scope will be ignored.
    If ``False``, the default, it is an error for a scope to be present.

    Returns a ``bytes``.
    �%�r��:s::s0::Nz{}:{:02x}{:02x}:{:02x}{:02x}r�r	r
FTs0000r�0)�
isinstance�bytes�encode�splitrr�	exception�SyntaxError�endswith�
startswith�
_v4_endingrr�	inet_atonr�formatr�_colon_colon_start�_colon_colon_endrrrr�	unhexlify�Error�	TypeError)
r/r0�btext�partsr"r$�br �
seen_empty�	canonical�c�_�lcr-r-r.r@hsx




$��
	

�
�r@s��cCs
|�t�S)z�Is the specified address a mapped IPv4 address?

    *address*, a ``bytes`` is an IPv6 address in binary form.

    Returns a ``bool``.
    )r>�_mapped_prefix)rr-r-r.�	is_mapped�s
rP)F)�__doc__r�re�typingrr�
dns.exceptionr�dns.ipv4�compilerr8�strrr?rBrC�boolr@rOrPr-r-r-r.�<module>s

E

 ]