XylotrechusZ
�
ǒ�g� � � � d Z ddlZddlmZmZmZ ddlZddlZej Z ej Z
dedede
fd�Zdede
defd �Zdedefd
�Zdedefd�Zdedefd�Z dd
eeef dee defd�Zd� Zdedefd�Zy)z*Generic Internet address helper functions.� N)�Any�Optional�Tuple�family�text�returnc � � | t k( rt j j |� S | t k( r t j
j |d� S t �)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``.
T)�AF_INET�dns�ipv4� inet_aton�AF_INET6�ipv6�NotImplementedError)r r s �7/opt/hc_python/lib/python3.12/site-packages/dns/inet.py� inet_ptonr ! sF � � ����x�x�!�!�$�'�'� �8� ��x�x�!�!�$��-�-�!�!� �addressc � � | t k( rt j j |� S | t k( rt j
j |� S t �)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``.
)r
r r � inet_ntoar r r )r r s r � inet_ntopr 6 sD � � ����x�x�!�!�'�*�*� �8� ��x�x�!�!�'�*�*�!�!r c �� � t j j | � t S # t $ r= t j
j | d� t cY S # t $ r t �w xY ww xY w)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 r
r
� Exceptionr r �
ValueError�r s r �af_for_addressr K s` � �������4� ����� � ��H�H���t�T�*��O��� ��� �� �s �$'