관리-도구
편집 파일: ipv6.cpython-39.pyc
a �����M�e�����������������������@���s����d�Z�ddlZddlZddlmZmZ�ddlZddlZe� d�Z eed�dd�Z e� d�Ze� d �Ze� d �Zdeeef�eed�d d�ZdZeed�dd�Zeeef�ed�dd�ZdS�)zIPv6 helper functions.�����N)�List�Unionz 0+([0-9a-f]+))�address�returnc�����������������C���s���t�|��dkrtd��t�|��}g�}d}t�|�}||k�rz|||d������}t�|�}|durf|�d�}|�|��|d7�}q.d}d}d} d} t d �D�]B}||�d kr�| r�|}|| �}||kr�| }|}d} q�| s�|} d} q�| r�d }|| �}||kr�| }|}|dk�r�|dk�rZ|dk�s,|d k�rZ|d �dk�rZ|dk�r<d} nd} | t j�|�dd����}n,d� |d|���d�d� |||�d����}n d� |�}|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��������Zffffz::z::ffff:�����:)�len� ValueError�binasciiZhexlify�decode� _leading_zero�match�group�append�range�dns�ipv4� inet_ntoa�join)r����hex�chunks�i�l�chunk�mZ best_startZbest_len�startZ last_was_zero�endZcurrent_len�prefixZthex��r&����,/usr/lib/python3.9/site-packages/dns/ipv6.pyr������sb���� , ��� r���s���(.*):(\d+\.\d+\.\d+\.\d+)$s���::.*s���.*::$F)�text�ignore_scoper���c����������� ��� ���C���sN��t�|�t�s|����}n|�}|rP|�d�}t|�}|dkr@|d�}n|dkrPtjj�|dkrbtjj�nH|�d�r�|�d�s�tjj�n*|� d�r�|� d�s�tjj�n|dkr�d}t �|�}|dur�tj� |�d��}d �|�d ����|d�|d �|d�|d�����}t�|�}|du�r |d d��}n t�|�}|du�r@|dd��}|�d�}t|�}|d k�rdtjj�d}g�} |D�]�} | dk�r�|�r�tjj�d}tdd |�d ��D�]}| �d���q�n>t| �}|dk�r�tjj�|dk�r�dd|��| �} | �| ���qp|d k��r|�stjj�d�| �}zt�|�W�S��tjtf�yH���tjj�Y�n0�dS�)a+��Convert an IPv6 address in text form to binary form. *text*, a ``str`` or ``bytes``, 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���::s���0::Nz{}:{:02x}{:02x}:{:02x}{:02x}r�������r ���r ���FTs���0000r�������0)� isinstance�bytes�encode�splitr���r���� exception�SyntaxError�endswith� startswith� _v4_endingr���r���� inet_atonr����formatr����_colon_colon_start�_colon_colon_endr���r���r���r���Z unhexlify�Error� TypeError) r(���r)���Zbtext�partsr ���r"����br���Z seen_emptyZ canonical�c�_Zlcr&���r&���r'���r9���h���sr���� $�� r9���s���������������c�����������������C���s ���|���t�S�)z�Is the specified address a mapped IPv4 address? *address*, a ``bytes`` is an IPv6 address in binary form. Returns a ``bool``. )r7����_mapped_prefix)r���r&���r&���r'���� is_mapped����s����rD���)r(���r���c�����������������C���s���t�j�t�j�|���S�)a��Verify that *address* is a valid text form IPv6 address and return its canonical text form. Addresses with scopes are rejected. *text*, a ``str`` or ``bytes``, the IPv6 address in textual form. Raises ``dns.exception.SyntaxError`` if the text is not valid. )r���Zipv6r���r9���)r(���r&���r&���r'����canonicalize����s����rE���)F)�__doc__r����re�typingr���r���Z dns.exceptionr���Zdns.ipv4�compiler���r1����strr���r8���r;���r<����boolr9���rC���rD���rE���r&���r&���r&���r'����<module>���s��� E ]