관리-도구
편집 파일: inet.cpython-39.pyc
a �����M�e�����������������������@���s����d�Z�ddlZddlmZmZmZ�ddlZddlZej Z ej Z eee d�dd�Zee ed�dd �Zeed �dd�Zeed �d d�Zeed �dd�Zdeeef�ee�ed�dd�Zdd��Zeed �dd�ZdS�)z*Generic Internet address helper functions.�����N)�Any�Optional�Tuple)�family�text�returnc�����������������C���s2���|�t�krtj�|�S�|�tkr*tj�|d�S�t�dS�)a��Convert 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``. TN)�AF_INET�dns�ipv4� inet_aton�AF_INET6�ipv6�NotImplementedError)r���r�����r����,/usr/lib/python3.9/site-packages/dns/inet.py� inet_pton!���s ���� r���)r����addressr���c�����������������C���s0���|�t�krtj�|�S�|�tkr(tj�|�S�t�dS�)a0��Convert 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``. N)r���r ���r ���Z inet_ntoar���r ���r���)r���r���r���r���r���� inet_ntop6���s ���� r���)r���r���c�����������������C���sZ���zt�j�|���tW�S��tyT���zt�j�|�d��tW��Y�S��tyN���t�Y�n0�Y�n0�dS�)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``. TN)r ���r ���r���r���� Exceptionr ���r���� ValueError�r���r���r���r����af_for_addressK���s���� r���c�����������������C���sr���z"t�j�|��d�}|dko |dkW�S��tyl���z t�j�|�d�d�}|dkW��Y�S��tyf���t�Y�n0�Y�n0�dS�)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����N)r ���r ���r���r���r ���r���)r����firstr���r���r����is_multicasta���s����r���c�����������������C���sX���zt�j�|���W�dS��tyR���zt�j�|�d��W�Y�dS��tyL���Y�Y�dS�0�Y�n0�dS�)z{Is the specified string an IPv4 or IPv6 address? *text*, a ``str``, the textual address. Returns a ``bool``. TFN)r ���r ���r���r���r ���r���r���r���r���� is_addressw���s����r���)� high_tuple�afr���c����������� ������C���s����|�\}}|du�rt�|�}|tkr(||fS�|tkr�|�d�}|dk�rN||ddfS�|d|��}||d�d��}|���r�||dt|�fS�z||dt�|�fW�S��ty����tj }tj |||d�^�^�}} }| �Y�S�0�ntd|�����dS�)aX��Given 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 )r���r���r����find�isdigit�int�socketZif_nametoindex�AttributeErrorZAI_NUMERICHOSTZgetaddrinfor���) r���r���r����port�iZaddrpartZscopeZai_flags�_�tupr���r���r����low_level_address_tuple����s(���� r-���c�����������������C���s.���|�t�jkrdS�|�t�jkrdS�td|������dS�)z:Return the 'any' address for the specified address family.z0.0.0.0z::r#���N)r'���r���r���r���)r���r���r���r���� any_for_af����s ���� r.���c�����������������C���sP���zt�j�|��W�S��tyJ���zt�j�|��W��Y�S��tyD���t�Y�n0�Y�n0�dS�)a���Verify that *address* is a valid text form IPv4 or IPv6 address and return its canonical text form. IPv6 addresses with scopes are rejected. *text*, a ``str``, the address in textual form. Raises ``ValueError`` if the text is not valid. N)r ���r ����canonicalizer���r ���r���r���r���r���r���r/�������s����r/���)N)�__doc__r'����typingr���r���r���Zdns.ipv4r ���Zdns.ipv6r���r���r&����str�bytesr���r���r����boolr���r���r-���r.���r/���r���r���r���r����<module>���s$������$